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-2015, 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 | #include "TLibCommon/TComChromaFormat.h" |
---|
42 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
43 | #include "TLibCommon/TComCodingStatistics.h" |
---|
44 | #endif |
---|
45 | #if NH_MV |
---|
46 | #include "TDecTop.h" |
---|
47 | #endif |
---|
48 | |
---|
49 | //! \ingroup TLibDecoder |
---|
50 | //! \{ |
---|
51 | |
---|
52 | #if ENC_DEC_TRACE |
---|
53 | #if !H_MV_ENC_DEC_TRAC |
---|
54 | Void xTraceVPSHeader () |
---|
55 | { |
---|
56 | fprintf( g_hTrace, "=========== Video Parameter Set ===========\n" ); |
---|
57 | } |
---|
58 | |
---|
59 | Void xTraceSPSHeader () |
---|
60 | { |
---|
61 | fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" ); |
---|
62 | } |
---|
63 | |
---|
64 | Void xTracePPSHeader () |
---|
65 | { |
---|
66 | fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n"); |
---|
67 | } |
---|
68 | #endif |
---|
69 | #endif |
---|
70 | // ==================================================================================================================== |
---|
71 | // Constructor / destructor / create / destroy |
---|
72 | // ==================================================================================================================== |
---|
73 | |
---|
74 | TDecCavlc::TDecCavlc() |
---|
75 | { |
---|
76 | } |
---|
77 | |
---|
78 | TDecCavlc::~TDecCavlc() |
---|
79 | { |
---|
80 | |
---|
81 | } |
---|
82 | |
---|
83 | // ==================================================================================================================== |
---|
84 | // Public member functions |
---|
85 | // ==================================================================================================================== |
---|
86 | |
---|
87 | Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
88 | { |
---|
89 | UInt code; |
---|
90 | UInt interRPSPred; |
---|
91 | if (idx > 0) |
---|
92 | { |
---|
93 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
94 | } |
---|
95 | else |
---|
96 | { |
---|
97 | interRPSPred = false; |
---|
98 | rps->setInterRPSPrediction(false); |
---|
99 | } |
---|
100 | |
---|
101 | if (interRPSPred) |
---|
102 | { |
---|
103 | UInt bit; |
---|
104 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
105 | { |
---|
106 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
107 | } |
---|
108 | else |
---|
109 | { |
---|
110 | code = 0; |
---|
111 | } |
---|
112 | 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 |
---|
113 | Int rIdx = idx - 1 - code; |
---|
114 | 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 |
---|
115 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
116 | Int k = 0, k0 = 0, k1 = 0; |
---|
117 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
118 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
119 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
120 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
121 | { |
---|
122 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
123 | Int refIdc = bit; |
---|
124 | if (refIdc == 0) |
---|
125 | { |
---|
126 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
127 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
128 | } |
---|
129 | if (refIdc == 1 || refIdc == 2) |
---|
130 | { |
---|
131 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
132 | rps->setDeltaPOC(k, deltaPOC); |
---|
133 | rps->setUsed(k, (refIdc == 1)); |
---|
134 | |
---|
135 | if (deltaPOC < 0) |
---|
136 | { |
---|
137 | k0++; |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | k1++; |
---|
142 | } |
---|
143 | k++; |
---|
144 | } |
---|
145 | rps->setRefIdc(j,refIdc); |
---|
146 | } |
---|
147 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
148 | rps->setNumberOfPictures(k); |
---|
149 | rps->setNumberOfNegativePictures(k0); |
---|
150 | rps->setNumberOfPositivePictures(k1); |
---|
151 | rps->sortDeltaPOC(); |
---|
152 | } |
---|
153 | else |
---|
154 | { |
---|
155 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
156 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
157 | Int prev = 0; |
---|
158 | Int poc; |
---|
159 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
160 | { |
---|
161 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
162 | poc = prev-code-1; |
---|
163 | prev = poc; |
---|
164 | rps->setDeltaPOC(j,poc); |
---|
165 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
166 | } |
---|
167 | prev = 0; |
---|
168 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
169 | { |
---|
170 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
171 | poc = prev+code+1; |
---|
172 | prev = poc; |
---|
173 | rps->setDeltaPOC(j,poc); |
---|
174 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
175 | } |
---|
176 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
177 | } |
---|
178 | #if PRINT_RPS_INFO |
---|
179 | rps->printDeltaPOC(); |
---|
180 | #endif |
---|
181 | } |
---|
182 | |
---|
183 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
184 | { |
---|
185 | #if ENC_DEC_TRACE |
---|
186 | #if H_MV_ENC_DEC_TRAC |
---|
187 | tracePSHeader( "PPS", pcPPS->getLayerId() ); |
---|
188 | #else |
---|
189 | xTracePPSHeader (); |
---|
190 | #endif |
---|
191 | #endif |
---|
192 | UInt uiCode; |
---|
193 | |
---|
194 | Int iCode; |
---|
195 | |
---|
196 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
197 | assert(uiCode <= 63); |
---|
198 | pcPPS->setPPSId (uiCode); |
---|
199 | |
---|
200 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
201 | assert(uiCode <= 15); |
---|
202 | pcPPS->setSPSId (uiCode); |
---|
203 | |
---|
204 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
205 | |
---|
206 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
207 | |
---|
208 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
209 | |
---|
210 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
211 | |
---|
212 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
213 | |
---|
214 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
215 | assert(uiCode <= 14); |
---|
216 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
217 | |
---|
218 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
219 | assert(uiCode <= 14); |
---|
220 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
221 | |
---|
222 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
223 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
224 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
225 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
226 | |
---|
227 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
228 | if( pcPPS->getUseDQP() ) |
---|
229 | { |
---|
230 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
231 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
232 | } |
---|
233 | else |
---|
234 | { |
---|
235 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
236 | } |
---|
237 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
238 | pcPPS->setQpOffset(COMPONENT_Cb, iCode); |
---|
239 | assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 ); |
---|
240 | assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 ); |
---|
241 | |
---|
242 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
243 | pcPPS->setQpOffset(COMPONENT_Cr, iCode); |
---|
244 | assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 ); |
---|
245 | assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 ); |
---|
246 | |
---|
247 | assert(MAX_NUM_COMPONENT<=3); |
---|
248 | |
---|
249 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
250 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
251 | |
---|
252 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
253 | pcPPS->setUseWP( uiCode==1 ); |
---|
254 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
255 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
256 | |
---|
257 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
258 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
259 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
260 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
261 | |
---|
262 | if( pcPPS->getTilesEnabledFlag() ) |
---|
263 | { |
---|
264 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumTileColumnsMinus1( uiCode ); |
---|
265 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumTileRowsMinus1( uiCode ); |
---|
266 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); |
---|
267 | |
---|
268 | const UInt tileColumnsMinus1 = pcPPS->getNumTileColumnsMinus1(); |
---|
269 | const UInt tileRowsMinus1 = pcPPS->getNumTileRowsMinus1(); |
---|
270 | |
---|
271 | if ( !pcPPS->getTileUniformSpacingFlag()) |
---|
272 | { |
---|
273 | if (tileColumnsMinus1 > 0) |
---|
274 | { |
---|
275 | std::vector<Int> columnWidth(tileColumnsMinus1); |
---|
276 | for(UInt i = 0; i < tileColumnsMinus1; i++) |
---|
277 | { |
---|
278 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
279 | columnWidth[i] = uiCode+1; |
---|
280 | } |
---|
281 | pcPPS->setTileColumnWidth(columnWidth); |
---|
282 | } |
---|
283 | |
---|
284 | if (tileRowsMinus1 > 0) |
---|
285 | { |
---|
286 | std::vector<Int> rowHeight (tileRowsMinus1); |
---|
287 | for(UInt i = 0; i < tileRowsMinus1; i++) |
---|
288 | { |
---|
289 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
290 | rowHeight[i] = uiCode + 1; |
---|
291 | } |
---|
292 | pcPPS->setTileRowHeight(rowHeight); |
---|
293 | } |
---|
294 | } |
---|
295 | |
---|
296 | if ((tileColumnsMinus1 + tileRowsMinus1) != 0) |
---|
297 | { |
---|
298 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
299 | } |
---|
300 | } |
---|
301 | READ_FLAG( uiCode, "pps_loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
302 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
303 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
304 | { |
---|
305 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
306 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
307 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
308 | { |
---|
309 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
310 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
311 | } |
---|
312 | } |
---|
313 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
314 | if(pcPPS->getScalingListPresentFlag ()) |
---|
315 | { |
---|
316 | parseScalingList( &(pcPPS->getScalingList()) ); |
---|
317 | } |
---|
318 | |
---|
319 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
320 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
321 | |
---|
322 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
323 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
324 | |
---|
325 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
326 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
327 | |
---|
328 | READ_FLAG( uiCode, "pps_extension_present_flag"); |
---|
329 | if (uiCode) |
---|
330 | { |
---|
331 | #if NH_MV |
---|
332 | READ_FLAG( uiCode, "pps_range_extensions_flag" ); pcPPS->setPpsRangeExtensionsFlag( uiCode == 1 ); |
---|
333 | READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); pcPPS->setPpsMultilayerExtensionFlag( uiCode == 1 ); |
---|
334 | READ_FLAG( uiCode, "pps_3d_extension_flag" ); pcPPS->setPps3dExtensionFlag( uiCode == 1 ); |
---|
335 | READ_CODE( 5, uiCode, "pps_extension_5bits" ); pcPPS->setPpsExtension5bits( uiCode ); |
---|
336 | if ( pcPPS->getPpsRangeExtensionsFlag() ) |
---|
337 | { |
---|
338 | TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); |
---|
339 | |
---|
340 | if (pcPPS->getUseTransformSkip()) |
---|
341 | { |
---|
342 | READ_UVLC( uiCode, "log2_max_transform_skip_block_size_minus2"); |
---|
343 | ppsRangeExtension.setLog2MaxTransformSkipBlockSize(uiCode+2); |
---|
344 | } |
---|
345 | |
---|
346 | READ_FLAG( uiCode, "cross_component_prediction_enabled_flag"); |
---|
347 | ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0); |
---|
348 | |
---|
349 | READ_FLAG( uiCode, "chroma_qp_offset_list_enabled_flag"); |
---|
350 | if (uiCode == 0) |
---|
351 | { |
---|
352 | ppsRangeExtension.clearChromaQpOffsetList(); |
---|
353 | ppsRangeExtension.setDiffCuChromaQpOffsetDepth(0); |
---|
354 | } |
---|
355 | else |
---|
356 | { |
---|
357 | READ_UVLC(uiCode, "diff_cu_chroma_qp_offset_depth"); ppsRangeExtension.setDiffCuChromaQpOffsetDepth(uiCode); |
---|
358 | UInt tableSizeMinus1 = 0; |
---|
359 | READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); |
---|
360 | assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE); |
---|
361 | |
---|
362 | for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) |
---|
363 | { |
---|
364 | Int cbOffset; |
---|
365 | Int crOffset; |
---|
366 | READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); |
---|
367 | assert(cbOffset >= -12 && cbOffset <= 12); |
---|
368 | READ_SVLC(crOffset, "cr_qp_offset_list[i]"); |
---|
369 | assert(crOffset >= -12 && crOffset <= 12); |
---|
370 | // table uses +1 for index (see comment inside the function) |
---|
371 | ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset); |
---|
372 | } |
---|
373 | assert(ppsRangeExtension.getChromaQpOffsetListLen() == tableSizeMinus1 + 1); |
---|
374 | } |
---|
375 | |
---|
376 | READ_UVLC( uiCode, "log2_sao_offset_scale_luma"); |
---|
377 | ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode); |
---|
378 | READ_UVLC( uiCode, "log2_sao_offset_scale_chroma"); |
---|
379 | ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, uiCode); } |
---|
380 | |
---|
381 | if ( pcPPS->getPpsMultilayerExtensionFlag() ) |
---|
382 | { |
---|
383 | parsePpsMultilayerExtension( pcPPS ); |
---|
384 | } |
---|
385 | |
---|
386 | if ( pcPPS->getPps3dExtensionFlag() ) |
---|
387 | { |
---|
388 | #if NH_3D |
---|
389 | parsePps3dExtension( pcPPS ); |
---|
390 | #endif |
---|
391 | } |
---|
392 | #if NH_3D |
---|
393 | if ( pcPPS->getPpsExtension5bits() ) |
---|
394 | #else |
---|
395 | if ( pcPPS->getPpsExtension5bits() || pcPPS->getPps3dExtensionFlag() ) |
---|
396 | #endif |
---|
397 | { |
---|
398 | while ( xMoreRbspData() ) |
---|
399 | { |
---|
400 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
401 | } |
---|
402 | } |
---|
403 | |
---|
404 | #else |
---|
405 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
406 | static const char *syntaxStrings[]={ "pps_range_extension_flag", |
---|
407 | "pps_multilayer_extension_flag", |
---|
408 | "pps_extension_6bits[0]", |
---|
409 | "pps_extension_6bits[1]", |
---|
410 | "pps_extension_6bits[2]", |
---|
411 | "pps_extension_6bits[3]", |
---|
412 | "pps_extension_6bits[4]", |
---|
413 | "pps_extension_6bits[5]" }; |
---|
414 | #endif |
---|
415 | |
---|
416 | Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]; |
---|
417 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
418 | { |
---|
419 | READ_FLAG( uiCode, syntaxStrings[i] ); |
---|
420 | pps_extension_flags[i] = uiCode!=0; |
---|
421 | } |
---|
422 | |
---|
423 | Bool bSkipTrailingExtensionBits=false; |
---|
424 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
425 | { |
---|
426 | if (pps_extension_flags[i]) |
---|
427 | { |
---|
428 | switch (PPSExtensionFlagIndex(i)) |
---|
429 | { |
---|
430 | case PPS_EXT__REXT: |
---|
431 | { |
---|
432 | TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); |
---|
433 | assert(!bSkipTrailingExtensionBits); |
---|
434 | |
---|
435 | if (pcPPS->getUseTransformSkip()) |
---|
436 | { |
---|
437 | READ_UVLC( uiCode, "log2_max_transform_skip_block_size_minus2"); |
---|
438 | ppsRangeExtension.setLog2MaxTransformSkipBlockSize(uiCode+2); |
---|
439 | } |
---|
440 | |
---|
441 | READ_FLAG( uiCode, "cross_component_prediction_enabled_flag"); |
---|
442 | ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0); |
---|
443 | |
---|
444 | READ_FLAG( uiCode, "chroma_qp_offset_list_enabled_flag"); |
---|
445 | if (uiCode == 0) |
---|
446 | { |
---|
447 | ppsRangeExtension.clearChromaQpOffsetList(); |
---|
448 | ppsRangeExtension.setDiffCuChromaQpOffsetDepth(0); |
---|
449 | } |
---|
450 | else |
---|
451 | { |
---|
452 | READ_UVLC(uiCode, "diff_cu_chroma_qp_offset_depth"); ppsRangeExtension.setDiffCuChromaQpOffsetDepth(uiCode); |
---|
453 | UInt tableSizeMinus1 = 0; |
---|
454 | READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); |
---|
455 | assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE); |
---|
456 | |
---|
457 | for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) |
---|
458 | { |
---|
459 | Int cbOffset; |
---|
460 | Int crOffset; |
---|
461 | READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); |
---|
462 | assert(cbOffset >= -12 && cbOffset <= 12); |
---|
463 | READ_SVLC(crOffset, "cr_qp_offset_list[i]"); |
---|
464 | assert(crOffset >= -12 && crOffset <= 12); |
---|
465 | // table uses +1 for index (see comment inside the function) |
---|
466 | ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset); |
---|
467 | } |
---|
468 | assert(ppsRangeExtension.getChromaQpOffsetListLen() == tableSizeMinus1 + 1); |
---|
469 | } |
---|
470 | |
---|
471 | READ_UVLC( uiCode, "log2_sao_offset_scale_luma"); |
---|
472 | ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode); |
---|
473 | READ_UVLC( uiCode, "log2_sao_offset_scale_chroma"); |
---|
474 | ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, uiCode); |
---|
475 | } |
---|
476 | break; |
---|
477 | default: |
---|
478 | bSkipTrailingExtensionBits=true; |
---|
479 | break; |
---|
480 | } |
---|
481 | } |
---|
482 | } |
---|
483 | if (bSkipTrailingExtensionBits) |
---|
484 | { |
---|
485 | while ( xMoreRbspData() ) |
---|
486 | { |
---|
487 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
488 | } |
---|
489 | } |
---|
490 | #endif |
---|
491 | } |
---|
492 | xReadRbspTrailingBits(); |
---|
493 | } |
---|
494 | |
---|
495 | #if NH_3D |
---|
496 | Void TDecCavlc::parsePps3dExtension( TComPPS* pcPPS ) |
---|
497 | { |
---|
498 | #if NH_3D_DLT |
---|
499 | UInt uiCode = 0; |
---|
500 | // |
---|
501 | TComDLT* pcDLT = pcPPS->getDLT(); |
---|
502 | |
---|
503 | READ_FLAG(uiCode, "dlts_present_flag"); |
---|
504 | pcDLT->setDltPresentFlag( (uiCode == 1) ? true : false ); |
---|
505 | |
---|
506 | if ( pcDLT->getDltPresentFlag() ) |
---|
507 | { |
---|
508 | READ_CODE(6, uiCode, "pps_depth_layers_minus1"); |
---|
509 | pcDLT->setNumDepthViews( uiCode+1 ); |
---|
510 | |
---|
511 | READ_CODE(4, uiCode, "pps_bit_depth_for_depth_layers_minus8"); |
---|
512 | pcDLT->setDepthViewBitDepth( (uiCode+8) ); |
---|
513 | |
---|
514 | for( Int i = 0; i <= pcDLT->getNumDepthViews(); i++ ) |
---|
515 | { |
---|
516 | Int layerId = pcDLT->getDepthIdxToLayerId(i); |
---|
517 | |
---|
518 | READ_FLAG(uiCode, "dlt_flag[i]"); |
---|
519 | pcDLT->setUseDLTFlag(layerId, (uiCode == 1) ? true : false); |
---|
520 | |
---|
521 | if ( pcDLT->getUseDLTFlag( layerId ) ) |
---|
522 | { |
---|
523 | Bool bDltBitMapRepFlag = false; |
---|
524 | UInt uiMaxDiff = MAX_INT; |
---|
525 | UInt uiMinDiff = 0; |
---|
526 | UInt uiCodeLength = 0; |
---|
527 | |
---|
528 | READ_FLAG(uiCode, "dlt_pred_flag[i]"); |
---|
529 | |
---|
530 | if( uiCode ) |
---|
531 | { |
---|
532 | assert( pcDLT->getUseDLTFlag( 1 )); |
---|
533 | } |
---|
534 | pcDLT->setInterViewDltPredEnableFlag( layerId, (uiCode == 1) ? true : false ); |
---|
535 | |
---|
536 | if ( pcDLT->getInterViewDltPredEnableFlag( layerId ) == false ) |
---|
537 | { |
---|
538 | READ_FLAG(uiCode, "dlt_val_flags_present_flag[i]"); |
---|
539 | bDltBitMapRepFlag = (uiCode == 1) ? true : false; |
---|
540 | } |
---|
541 | else |
---|
542 | { |
---|
543 | bDltBitMapRepFlag = false; |
---|
544 | } |
---|
545 | |
---|
546 | UInt uiNumDepthValues = 0; |
---|
547 | std::vector<Int> aiIdx2DepthValue(256, 0); |
---|
548 | |
---|
549 | // Bit map |
---|
550 | if ( bDltBitMapRepFlag ) |
---|
551 | { |
---|
552 | for (UInt d=0; d<256; d++) |
---|
553 | { |
---|
554 | READ_FLAG(uiCode, "dlt_value_flag[i][j]"); |
---|
555 | if (uiCode == 1) |
---|
556 | { |
---|
557 | aiIdx2DepthValue[uiNumDepthValues] = d; |
---|
558 | uiNumDepthValues++; |
---|
559 | } |
---|
560 | } |
---|
561 | } |
---|
562 | // Diff Coding |
---|
563 | else |
---|
564 | { |
---|
565 | READ_CODE(8, uiNumDepthValues, "num_val_delta_dlt"); // num_entry |
---|
566 | |
---|
567 | { |
---|
568 | // The condition if( pcVPS->getNumDepthValues(i) > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. |
---|
569 | |
---|
570 | if (uiNumDepthValues > 1) |
---|
571 | { |
---|
572 | READ_CODE(8, uiCode, "max_diff"); |
---|
573 | uiMaxDiff = uiCode; |
---|
574 | } |
---|
575 | else |
---|
576 | { |
---|
577 | uiMaxDiff = 0; // when there is only one value in DLT |
---|
578 | } |
---|
579 | |
---|
580 | if (uiNumDepthValues > 2) |
---|
581 | { |
---|
582 | uiCodeLength = (UInt) gCeilLog2(uiMaxDiff + 1); |
---|
583 | READ_CODE(uiCodeLength, uiCode, "min_diff_minus1"); |
---|
584 | uiMinDiff = uiCode + 1; |
---|
585 | } |
---|
586 | else |
---|
587 | { |
---|
588 | uiMinDiff = uiMaxDiff; // when there are only one or two values in DLT |
---|
589 | } |
---|
590 | |
---|
591 | READ_CODE(8, uiCode, "delta_dlt_val0"); // entry0 |
---|
592 | aiIdx2DepthValue[0] = uiCode; |
---|
593 | |
---|
594 | if (uiMaxDiff == uiMinDiff) |
---|
595 | { |
---|
596 | for (UInt d=1; d<uiNumDepthValues; d++) |
---|
597 | { |
---|
598 | aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + 0; |
---|
599 | } |
---|
600 | } |
---|
601 | else |
---|
602 | { |
---|
603 | uiCodeLength = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1); |
---|
604 | for (UInt d=1; d<uiNumDepthValues; d++) |
---|
605 | { |
---|
606 | READ_CODE(uiCodeLength, uiCode, "delta_val_diff_minus_min[k]"); |
---|
607 | aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + uiCode; |
---|
608 | } |
---|
609 | } |
---|
610 | |
---|
611 | } |
---|
612 | } |
---|
613 | |
---|
614 | if( pcDLT->getInterViewDltPredEnableFlag( layerId ) ) |
---|
615 | { |
---|
616 | // interpret decoded values as delta DLT |
---|
617 | AOF( layerId > 1 ); |
---|
618 | // assumes ref layer id to be 1 |
---|
619 | std::vector<Int> viRefDLT = pcDLT->idx2DepthValue( 1 ); |
---|
620 | UInt uiRefNum = pcDLT->getNumDepthValues( 1 ); |
---|
621 | pcDLT->setDeltaDLT(layerId, viRefDLT, uiRefNum, aiIdx2DepthValue, uiNumDepthValues); |
---|
622 | } |
---|
623 | else |
---|
624 | { |
---|
625 | // store final DLT |
---|
626 | pcDLT->setDepthLUTs(layerId, aiIdx2DepthValue, uiNumDepthValues); |
---|
627 | } |
---|
628 | } |
---|
629 | } |
---|
630 | } |
---|
631 | #endif |
---|
632 | } |
---|
633 | #endif |
---|
634 | |
---|
635 | |
---|
636 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
637 | { |
---|
638 | #if ENC_DEC_TRACE |
---|
639 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
640 | #endif |
---|
641 | UInt uiCode; |
---|
642 | |
---|
643 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
644 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
645 | { |
---|
646 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
647 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
648 | { |
---|
649 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
650 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
651 | } |
---|
652 | } |
---|
653 | |
---|
654 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
655 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
656 | { |
---|
657 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
658 | } |
---|
659 | |
---|
660 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
661 | #if NH_MV |
---|
662 | assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); |
---|
663 | #endif |
---|
664 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
665 | { |
---|
666 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
667 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
668 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
669 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
670 | { |
---|
671 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
672 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
673 | READ_CODE(8, uiCode, "matrix_coeffs"); pcVUI->setMatrixCoefficients(uiCode); |
---|
674 | } |
---|
675 | } |
---|
676 | |
---|
677 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
678 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
679 | { |
---|
680 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
681 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
682 | } |
---|
683 | |
---|
684 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
685 | |
---|
686 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
687 | |
---|
688 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
689 | |
---|
690 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
691 | if (uiCode != 0) |
---|
692 | { |
---|
693 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
694 | #if NH_MV |
---|
695 | defDisp.setScaledFlag( false ); |
---|
696 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode ); |
---|
697 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode ); |
---|
698 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode ); |
---|
699 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode ); |
---|
700 | #else |
---|
701 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
702 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
703 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
704 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
705 | #endif |
---|
706 | } |
---|
707 | |
---|
708 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
709 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
710 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
711 | { |
---|
712 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
713 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
714 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
715 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
716 | { |
---|
717 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
718 | } |
---|
719 | |
---|
720 | READ_FLAG( uiCode, "vui_hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
721 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
722 | { |
---|
723 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
724 | } |
---|
725 | } |
---|
726 | |
---|
727 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
728 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
729 | { |
---|
730 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
731 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
732 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
733 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
734 | assert(uiCode < 4096); |
---|
735 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
736 | READ_UVLC( uiCode, "max_bits_per_min_cu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
737 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
738 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
739 | } |
---|
740 | } |
---|
741 | |
---|
742 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
743 | { |
---|
744 | UInt uiCode; |
---|
745 | if( commonInfPresentFlag ) |
---|
746 | { |
---|
747 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
748 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
749 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
750 | { |
---|
751 | READ_FLAG( uiCode, "sub_pic_hrd_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
752 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
753 | { |
---|
754 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
755 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_increment_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
756 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
757 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
758 | } |
---|
759 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
760 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
761 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
762 | { |
---|
763 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
764 | } |
---|
765 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
766 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
767 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
768 | } |
---|
769 | } |
---|
770 | Int i, j, nalOrVcl; |
---|
771 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
772 | { |
---|
773 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
774 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
775 | { |
---|
776 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
777 | } |
---|
778 | else |
---|
779 | { |
---|
780 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
781 | } |
---|
782 | |
---|
783 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
784 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
785 | |
---|
786 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
787 | { |
---|
788 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
789 | } |
---|
790 | else |
---|
791 | { |
---|
792 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
793 | } |
---|
794 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
795 | { |
---|
796 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
797 | } |
---|
798 | |
---|
799 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
800 | { |
---|
801 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
802 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
803 | { |
---|
804 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
805 | { |
---|
806 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
807 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
808 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
809 | { |
---|
810 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
811 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
812 | } |
---|
813 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
814 | } |
---|
815 | } |
---|
816 | } |
---|
817 | } |
---|
818 | } |
---|
819 | |
---|
820 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
821 | { |
---|
822 | #if ENC_DEC_TRACE |
---|
823 | #if H_MV_ENC_DEC_TRAC |
---|
824 | tracePSHeader( "SPS", pcSPS->getLayerId() ); |
---|
825 | #else |
---|
826 | xTraceSPSHeader (); |
---|
827 | #endif |
---|
828 | #endif |
---|
829 | |
---|
830 | UInt uiCode; |
---|
831 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
832 | |
---|
833 | #if NH_MV |
---|
834 | if ( pcSPS->getLayerId() == 0 ) |
---|
835 | { |
---|
836 | #endif |
---|
837 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
838 | assert(uiCode <= 6); |
---|
839 | #if NH_MV |
---|
840 | } |
---|
841 | else |
---|
842 | { |
---|
843 | READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); pcSPS->setSpsExtOrMaxSubLayersMinus1( uiCode ); |
---|
844 | pcSPS->inferSpsMaxSubLayersMinus1( false, NULL ); |
---|
845 | } |
---|
846 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
847 | { |
---|
848 | #endif |
---|
849 | |
---|
850 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
851 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
852 | { |
---|
853 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
854 | assert( uiCode == 1 ); |
---|
855 | } |
---|
856 | |
---|
857 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
858 | #if NH_MV |
---|
859 | pcSPS->getPTL()->inferGeneralValues ( true, 0, NULL ); |
---|
860 | pcSPS->getPTL()->inferSubLayerValues( pcSPS->getMaxTLayers() - 1, 0, NULL ); |
---|
861 | } |
---|
862 | #endif |
---|
863 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
864 | assert(uiCode <= 15); |
---|
865 | #if NH_MV |
---|
866 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
867 | { |
---|
868 | READ_FLAG( uiCode, "update_rep_format_flag" ); pcSPS->setUpdateRepFormatFlag( uiCode == 1 ); |
---|
869 | if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
870 | { |
---|
871 | READ_CODE( 8, uiCode, "sps_rep_format_idx" ); pcSPS->setSpsRepFormatIdx( uiCode ); |
---|
872 | } |
---|
873 | } |
---|
874 | else |
---|
875 | { |
---|
876 | #endif |
---|
877 | |
---|
878 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); |
---|
879 | assert(uiCode <= 3); |
---|
880 | if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) |
---|
881 | { |
---|
882 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
883 | } |
---|
884 | |
---|
885 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
886 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
887 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
888 | if (uiCode != 0) |
---|
889 | { |
---|
890 | Window &conf = pcSPS->getConformanceWindow(); |
---|
891 | #if NH_MV |
---|
892 | // Needs to be scaled later, when ChromaFormatIdc is known. |
---|
893 | conf.setScaledFlag( false ); |
---|
894 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
895 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
896 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
897 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
898 | } |
---|
899 | #else |
---|
900 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
901 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
902 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
903 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
904 | #endif |
---|
905 | } |
---|
906 | |
---|
907 | #if NH_MV |
---|
908 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
909 | { |
---|
910 | #endif |
---|
911 | |
---|
912 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
913 | #if O0043_BEST_EFFORT_DECODING |
---|
914 | pcSPS->setStreamBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); |
---|
915 | const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth(); |
---|
916 | if (forceDecodeBitDepth != 0) |
---|
917 | { |
---|
918 | uiCode = forceDecodeBitDepth - 8; |
---|
919 | } |
---|
920 | #endif |
---|
921 | assert(uiCode <= 8); |
---|
922 | pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); |
---|
923 | |
---|
924 | #if O0043_BEST_EFFORT_DECODING |
---|
925 | pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_LUMA)-8)) ); |
---|
926 | #else |
---|
927 | pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) ); |
---|
928 | #endif |
---|
929 | |
---|
930 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
931 | #if O0043_BEST_EFFORT_DECODING |
---|
932 | pcSPS->setStreamBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); |
---|
933 | if (forceDecodeBitDepth != 0) |
---|
934 | { |
---|
935 | uiCode = forceDecodeBitDepth - 8; |
---|
936 | } |
---|
937 | #endif |
---|
938 | assert(uiCode <= 8); |
---|
939 | pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); |
---|
940 | #if O0043_BEST_EFFORT_DECODING |
---|
941 | pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_CHROMA)-8)) ); |
---|
942 | #else |
---|
943 | pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) ); |
---|
944 | #endif |
---|
945 | #if NH_MV |
---|
946 | } |
---|
947 | #endif |
---|
948 | |
---|
949 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
950 | assert(uiCode <= 12); |
---|
951 | |
---|
952 | #if NH_MV |
---|
953 | if ( !pcSPS->getMultiLayerExtSpsFlag()) |
---|
954 | { |
---|
955 | #endif |
---|
956 | UInt subLayerOrderingInfoPresentFlag; |
---|
957 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
958 | |
---|
959 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
960 | { |
---|
961 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
962 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
963 | READ_UVLC ( uiCode, "sps_max_num_reorder_pics[i]" ); |
---|
964 | pcSPS->setNumReorderPics(uiCode, i); |
---|
965 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
---|
966 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
967 | |
---|
968 | if (!subLayerOrderingInfoPresentFlag) |
---|
969 | { |
---|
970 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
971 | { |
---|
972 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
973 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
974 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
975 | } |
---|
976 | break; |
---|
977 | } |
---|
978 | } |
---|
979 | #if NH_MV |
---|
980 | } |
---|
981 | #endif |
---|
982 | |
---|
983 | READ_UVLC( uiCode, "log2_min_luma_coding_block_size_minus3" ); |
---|
984 | Int log2MinCUSize = uiCode + 3; |
---|
985 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
986 | READ_UVLC( uiCode, "log2_diff_max_min_luma_coding_block_size" ); |
---|
987 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
988 | |
---|
989 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
---|
990 | { |
---|
991 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
---|
992 | } |
---|
993 | |
---|
994 | Int maxCUDepthDelta = uiCode; |
---|
995 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
996 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
997 | READ_UVLC( uiCode, "log2_min_luma_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
998 | |
---|
999 | READ_UVLC( uiCode, "log2_diff_max_min_luma_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
1000 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
1001 | |
---|
1002 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
1003 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
1004 | |
---|
1005 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
1006 | pcSPS->setMaxTotalCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
1007 | |
---|
1008 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
1009 | if(pcSPS->getScalingListFlag()) |
---|
1010 | { |
---|
1011 | #if NH_MV |
---|
1012 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
1013 | { |
---|
1014 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setSpsInferScalingListFlag( uiCode == 1 ); |
---|
1015 | } |
---|
1016 | |
---|
1017 | if ( pcSPS->getSpsInferScalingListFlag() ) |
---|
1018 | { |
---|
1019 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setSpsScalingListRefLayerId( uiCode ); |
---|
1020 | } |
---|
1021 | else |
---|
1022 | { |
---|
1023 | #endif |
---|
1024 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
1025 | if(pcSPS->getScalingListPresentFlag ()) |
---|
1026 | { |
---|
1027 | parseScalingList( &(pcSPS->getScalingList()) ); |
---|
1028 | } |
---|
1029 | #if NH_MV |
---|
1030 | } |
---|
1031 | #endif |
---|
1032 | } |
---|
1033 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
1034 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
1035 | |
---|
1036 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
1037 | if( pcSPS->getUsePCM() ) |
---|
1038 | { |
---|
1039 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode ); |
---|
1040 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode ); |
---|
1041 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
1042 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
1043 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
1044 | } |
---|
1045 | |
---|
1046 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
1047 | assert(uiCode <= 64); |
---|
1048 | pcSPS->createRPSList(uiCode); |
---|
1049 | |
---|
1050 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
1051 | TComReferencePictureSet* rps; |
---|
1052 | |
---|
1053 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
1054 | { |
---|
1055 | rps = rpsList->getReferencePictureSet(i); |
---|
1056 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
1057 | } |
---|
1058 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
1059 | if (pcSPS->getLongTermRefsPresent()) |
---|
1060 | { |
---|
1061 | READ_UVLC( uiCode, "num_long_term_ref_pics_sps" ); |
---|
1062 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
1063 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
1064 | { |
---|
1065 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
1066 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
1067 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
1068 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
1069 | } |
---|
1070 | } |
---|
1071 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
1072 | |
---|
1073 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
1074 | |
---|
1075 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
1076 | |
---|
1077 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
1078 | { |
---|
1079 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
1080 | } |
---|
1081 | |
---|
1082 | READ_FLAG( uiCode, "sps_extension_present_flag"); |
---|
1083 | #if NH_MV |
---|
1084 | pcSPS->setSpsExtensionPresentFlag( uiCode ); |
---|
1085 | if (pcSPS->getSpsExtensionPresentFlag( ) ) |
---|
1086 | { |
---|
1087 | READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 ); |
---|
1088 | READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 ); |
---|
1089 | READ_FLAG( uiCode , "sps_3d_extension_flag" ); pcSPS->setSps3dExtensionFlag( uiCode == 1 ); |
---|
1090 | READ_CODE( 5, uiCode, "sps_extension_5bits" ) ; pcSPS->setSpsExtension5bits( uiCode ); |
---|
1091 | |
---|
1092 | if ( pcSPS->getSpsRangeExtensionsFlag() ) |
---|
1093 | { |
---|
1094 | TComSPSRExt &spsRangeExtension = pcSPS->getSpsRangeExtension(); |
---|
1095 | READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); spsRangeExtension.setTransformSkipRotationEnabledFlag(uiCode != 0); |
---|
1096 | READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); spsRangeExtension.setTransformSkipContextEnabledFlag (uiCode != 0); |
---|
1097 | READ_FLAG( uiCode, "implicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); |
---|
1098 | READ_FLAG( uiCode, "explicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); |
---|
1099 | READ_FLAG( uiCode, "extended_precision_processing_flag"); spsRangeExtension.setExtendedPrecisionProcessingFlag (uiCode != 0); |
---|
1100 | READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); spsRangeExtension.setIntraSmoothingDisabledFlag (uiCode != 0); |
---|
1101 | READ_FLAG( uiCode, "high_precision_offsets_enabled_flag"); spsRangeExtension.setHighPrecisionOffsetsEnabledFlag (uiCode != 0); |
---|
1102 | READ_FLAG( uiCode, "persistent_rice_adaptation_enabled_flag"); spsRangeExtension.setPersistentRiceAdaptationEnabledFlag (uiCode != 0); |
---|
1103 | READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); spsRangeExtension.setCabacBypassAlignmentEnabledFlag (uiCode != 0); |
---|
1104 | } |
---|
1105 | |
---|
1106 | if ( pcSPS->getSpsMultilayerExtensionFlag() ) |
---|
1107 | { |
---|
1108 | parseSpsMultilayerExtension( pcSPS ); |
---|
1109 | } |
---|
1110 | |
---|
1111 | if ( pcSPS->getSps3dExtensionFlag() ) |
---|
1112 | { |
---|
1113 | #if NH_3D |
---|
1114 | parseSps3dExtension( pcSPS ); |
---|
1115 | #endif |
---|
1116 | } |
---|
1117 | |
---|
1118 | #if NH_3D |
---|
1119 | if ( pcSPS->getSpsExtension5bits() ) |
---|
1120 | #else |
---|
1121 | if ( pcSPS->getSpsExtension5bits() || pcSPS->getSps3dExtensionFlag() ) |
---|
1122 | #endif |
---|
1123 | { |
---|
1124 | while ( xMoreRbspData() ) |
---|
1125 | { |
---|
1126 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
1127 | } |
---|
1128 | } |
---|
1129 | } |
---|
1130 | #else |
---|
1131 | if (uiCode) |
---|
1132 | { |
---|
1133 | |
---|
1134 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
1135 | static const char *syntaxStrings[]={ "sps_range_extension_flag", |
---|
1136 | "sps_multilayer_extension_flag", |
---|
1137 | "sps_extension_6bits[0]", |
---|
1138 | "sps_extension_6bits[1]", |
---|
1139 | "sps_extension_6bits[2]", |
---|
1140 | "sps_extension_6bits[3]", |
---|
1141 | "sps_extension_6bits[4]", |
---|
1142 | "sps_extension_6bits[5]" }; |
---|
1143 | #endif |
---|
1144 | Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]; |
---|
1145 | |
---|
1146 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
1147 | { |
---|
1148 | READ_FLAG( uiCode, syntaxStrings[i] ); |
---|
1149 | sps_extension_flags[i] = uiCode!=0; |
---|
1150 | } |
---|
1151 | |
---|
1152 | Bool bSkipTrailingExtensionBits=false; |
---|
1153 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
1154 | { |
---|
1155 | if (sps_extension_flags[i]) |
---|
1156 | { |
---|
1157 | switch (SPSExtensionFlagIndex(i)) |
---|
1158 | { |
---|
1159 | case SPS_EXT__REXT: |
---|
1160 | assert(!bSkipTrailingExtensionBits); |
---|
1161 | { |
---|
1162 | TComSPSRExt &spsRangeExtension = pcSPS->getSpsRangeExtension(); |
---|
1163 | READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); spsRangeExtension.setTransformSkipRotationEnabledFlag(uiCode != 0); |
---|
1164 | READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); spsRangeExtension.setTransformSkipContextEnabledFlag (uiCode != 0); |
---|
1165 | READ_FLAG( uiCode, "implicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); |
---|
1166 | READ_FLAG( uiCode, "explicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); |
---|
1167 | READ_FLAG( uiCode, "extended_precision_processing_flag"); spsRangeExtension.setExtendedPrecisionProcessingFlag (uiCode != 0); |
---|
1168 | READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); spsRangeExtension.setIntraSmoothingDisabledFlag (uiCode != 0); |
---|
1169 | READ_FLAG( uiCode, "high_precision_offsets_enabled_flag"); spsRangeExtension.setHighPrecisionOffsetsEnabledFlag (uiCode != 0); |
---|
1170 | READ_FLAG( uiCode, "persistent_rice_adaptation_enabled_flag"); spsRangeExtension.setPersistentRiceAdaptationEnabledFlag (uiCode != 0); |
---|
1171 | READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); spsRangeExtension.setCabacBypassAlignmentEnabledFlag (uiCode != 0); |
---|
1172 | } |
---|
1173 | break; |
---|
1174 | default: |
---|
1175 | bSkipTrailingExtensionBits=true; |
---|
1176 | break; |
---|
1177 | } |
---|
1178 | } |
---|
1179 | } |
---|
1180 | if (bSkipTrailingExtensionBits) |
---|
1181 | { |
---|
1182 | while ( xMoreRbspData() ) |
---|
1183 | { |
---|
1184 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
1185 | } |
---|
1186 | } |
---|
1187 | } |
---|
1188 | #endif |
---|
1189 | xReadRbspTrailingBits(); |
---|
1190 | } |
---|
1191 | |
---|
1192 | #if NH_MV |
---|
1193 | Void TDecCavlc::parseSpsMultilayerExtension( TComSPS* pcSPS ) |
---|
1194 | { |
---|
1195 | UInt uiCode; |
---|
1196 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); |
---|
1197 | } |
---|
1198 | |
---|
1199 | #if NH_3D |
---|
1200 | Void TDecCavlc::parseSps3dExtension( TComSPS* pcSPS ) |
---|
1201 | { |
---|
1202 | TComSps3dExtension sps3dExt; |
---|
1203 | UInt uiCode; |
---|
1204 | for( Int d = 0; d <= 1; d++ ) |
---|
1205 | { |
---|
1206 | READ_FLAG( uiCode, "iv_mv_pred_flag" ); sps3dExt.setIvMvPredFlag( d, uiCode == 1 ); |
---|
1207 | READ_FLAG( uiCode, "iv_mv_scaling_flag" ); sps3dExt.setIvMvScalingFlag( d, uiCode == 1 ); |
---|
1208 | if( d == 0 ) |
---|
1209 | { |
---|
1210 | READ_UVLC( uiCode, "log2_sub_pb_size_minus3" ); sps3dExt.setLog2SubPbSizeMinus3( d, uiCode ); |
---|
1211 | READ_FLAG( uiCode, "iv_res_pred_flag" ); sps3dExt.setIvResPredFlag( d, uiCode == 1 ); |
---|
1212 | READ_FLAG( uiCode, "depth_refinement_flag" ); sps3dExt.setDepthRefinementFlag( d, uiCode == 1 ); |
---|
1213 | READ_FLAG( uiCode, "view_synthesis_pred_flag" ); sps3dExt.setViewSynthesisPredFlag( d, uiCode == 1 ); |
---|
1214 | READ_FLAG( uiCode, "depth_based_blk_part_flag" ); sps3dExt.setDepthBasedBlkPartFlag( d, uiCode == 1 ); |
---|
1215 | } |
---|
1216 | else |
---|
1217 | { |
---|
1218 | READ_FLAG( uiCode, "mpi_flag" ); sps3dExt.setMpiFlag( d, uiCode == 1 ); |
---|
1219 | READ_UVLC( uiCode, "log2_mpi_sub_pb_size_minus3" ); sps3dExt.setLog2MpiSubPbSizeMinus3( d, uiCode ); |
---|
1220 | READ_FLAG( uiCode, "intra_contour_flag" ); sps3dExt.setIntraContourFlag( d, uiCode == 1 ); |
---|
1221 | READ_FLAG( uiCode, "intra_sdc_wedge_flag" ); sps3dExt.setIntraSdcWedgeFlag( d, uiCode == 1 ); |
---|
1222 | READ_FLAG( uiCode, "qt_pred_flag" ); sps3dExt.setQtPredFlag( d, uiCode == 1 ); |
---|
1223 | READ_FLAG( uiCode, "inter_sdc_flag" ); sps3dExt.setInterSdcFlag( d, uiCode == 1 ); |
---|
1224 | READ_FLAG( uiCode, "intra_skip_flag" ); sps3dExt.setDepthIntraSkipFlag( d, uiCode == 1 ); |
---|
1225 | } |
---|
1226 | } |
---|
1227 | pcSPS->setSps3dExtension( sps3dExt ); |
---|
1228 | } |
---|
1229 | #endif |
---|
1230 | |
---|
1231 | Void TDecCavlc::parsePpsMultilayerExtension(TComPPS* pcPPS) |
---|
1232 | { |
---|
1233 | UInt uiCode = 0; |
---|
1234 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 ); |
---|
1235 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); pcPPS->setPpsInferScalingListFlag( uiCode == 1 ); |
---|
1236 | if (pcPPS->getPpsInferScalingListFlag()) |
---|
1237 | { |
---|
1238 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setPpsScalingListRefLayerId( uiCode ); |
---|
1239 | } |
---|
1240 | |
---|
1241 | UInt numRefLocOffsets;; |
---|
1242 | READ_UVLC( numRefLocOffsets, "num_ref_loc_offsets" ); |
---|
1243 | |
---|
1244 | // All of the following stuff is not needed, but allowed to be present. |
---|
1245 | for (Int i = 0; i < numRefLocOffsets; i++ ) |
---|
1246 | { |
---|
1247 | Int iCode = 0; |
---|
1248 | READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); |
---|
1249 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); |
---|
1250 | |
---|
1251 | if (uiCode) |
---|
1252 | { |
---|
1253 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); |
---|
1254 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); |
---|
1255 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); |
---|
1256 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); |
---|
1257 | } |
---|
1258 | |
---|
1259 | READ_FLAG( uiCode, "ref_region_offset_present_flag" ); |
---|
1260 | if (uiCode) |
---|
1261 | { |
---|
1262 | READ_SVLC( iCode, "ref_region_left_offset" ); |
---|
1263 | READ_SVLC( iCode, "ref_region_top_offset" ); |
---|
1264 | READ_SVLC( iCode, "ref_region_right_offset" ); |
---|
1265 | READ_SVLC( iCode, "ref_region_bottom_offset" ); |
---|
1266 | } |
---|
1267 | |
---|
1268 | READ_FLAG( uiCode, "resample_phase_set_present_flag" ); |
---|
1269 | if (uiCode) |
---|
1270 | { |
---|
1271 | READ_UVLC( uiCode, "phase_hor_luma" ); |
---|
1272 | READ_UVLC( uiCode, "phase_ver_luma" ); |
---|
1273 | READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); |
---|
1274 | READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); |
---|
1275 | } |
---|
1276 | } |
---|
1277 | READ_FLAG( uiCode, "colour_mapping_enabled_flag" ); |
---|
1278 | // This is required to equal to 0 for Multiview Main profile. |
---|
1279 | assert( uiCode == 0 ); |
---|
1280 | } |
---|
1281 | |
---|
1282 | #endif |
---|
1283 | |
---|
1284 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
1285 | { |
---|
1286 | #if ENC_DEC_TRACE |
---|
1287 | #if H_MV_ENC_DEC_TRAC |
---|
1288 | tracePSHeader( "VPS", getDecTop()->getLayerId() ); |
---|
1289 | #else |
---|
1290 | xTraceVPSHeader (); |
---|
1291 | #endif |
---|
1292 | #endif |
---|
1293 | |
---|
1294 | UInt uiCode; |
---|
1295 | |
---|
1296 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
1297 | #if NH_MV |
---|
1298 | READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); pcVPS->setVpsBaseLayerInternalFlag( uiCode == 1 ); |
---|
1299 | READ_FLAG( uiCode, "vps_base_layer_available_flag" ); pcVPS->setVpsBaseLayerAvailableFlag( uiCode == 1 ); |
---|
1300 | #else |
---|
1301 | READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); assert(uiCode == 1); |
---|
1302 | READ_FLAG( uiCode, "vps_base_layer_available_flag" ); assert(uiCode == 1); |
---|
1303 | #endif |
---|
1304 | #if NH_MV |
---|
1305 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) ) ); |
---|
1306 | #else |
---|
1307 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); |
---|
1308 | #endif |
---|
1309 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); |
---|
1310 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
1311 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
1312 | READ_CODE( 16, uiCode, "vps_reserved_0xffff_16bits" ); assert(uiCode == 0xffff); |
---|
1313 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
1314 | #if NH_MV |
---|
1315 | pcVPS->getPTL()->inferGeneralValues ( true, 0, NULL ); |
---|
1316 | pcVPS->getPTL()->inferSubLayerValues( pcVPS->getMaxTLayers() - 1, 0, NULL ); |
---|
1317 | #endif |
---|
1318 | UInt subLayerOrderingInfoPresentFlag; |
---|
1319 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
1320 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1321 | { |
---|
1322 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
1323 | READ_UVLC( uiCode, "vps_max_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
1324 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1325 | |
---|
1326 | if (!subLayerOrderingInfoPresentFlag) |
---|
1327 | { |
---|
1328 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1329 | { |
---|
1330 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
1331 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
1332 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
1333 | } |
---|
1334 | break; |
---|
1335 | } |
---|
1336 | } |
---|
1337 | |
---|
1338 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
1339 | #if NH_MV |
---|
1340 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
1341 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setVpsMaxLayerId( uiCode ); |
---|
1342 | |
---|
1343 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setVpsNumLayerSetsMinus1( uiCode ); |
---|
1344 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
1345 | { |
---|
1346 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
1347 | #else |
---|
1348 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
1349 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
1350 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
1351 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
1352 | { |
---|
1353 | // Operation point set |
---|
1354 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
1355 | #endif |
---|
1356 | { |
---|
1357 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
1358 | } |
---|
1359 | } |
---|
1360 | #if NH_MV |
---|
1361 | pcVPS->deriveLayerSetLayerIdList(); |
---|
1362 | #endif |
---|
1363 | |
---|
1364 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
1365 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
1366 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
1367 | { |
---|
1368 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
1369 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
1370 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
1371 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
1372 | { |
---|
1373 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
1374 | } |
---|
1375 | |
---|
1376 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
1377 | |
---|
1378 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
1379 | { |
---|
1380 | pcVPS->createHrdParamBuffer(); |
---|
1381 | } |
---|
1382 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
1383 | { |
---|
1384 | READ_UVLC( uiCode, "hrd_layer_set_idx[i]" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
1385 | if( i > 0 ) |
---|
1386 | { |
---|
1387 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
1388 | } |
---|
1389 | else |
---|
1390 | { |
---|
1391 | pcVPS->setCprmsPresentFlag( true, i ); |
---|
1392 | } |
---|
1393 | |
---|
1394 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
1395 | } |
---|
1396 | } |
---|
1397 | #if NH_MV |
---|
1398 | READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode == 1 ? true : false ); |
---|
1399 | if ( pcVPS->getVpsExtensionFlag() ) |
---|
1400 | #else |
---|
1401 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
1402 | if (uiCode) |
---|
1403 | #endif |
---|
1404 | { |
---|
1405 | #if NH_MV |
---|
1406 | m_pcBitstream->readOutTrailingBits(); |
---|
1407 | parseVPSExtension( pcVPS ); |
---|
1408 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
1409 | if (uiCode) |
---|
1410 | { |
---|
1411 | #if NH_3D |
---|
1412 | READ_FLAG( uiCode, "vps_3d_extension_flag" ); |
---|
1413 | if ( uiCode ) |
---|
1414 | { |
---|
1415 | m_pcBitstream->readOutTrailingBits(); |
---|
1416 | pcVPS->createCamPars(pcVPS->getNumViews()); |
---|
1417 | parseVps3dExtension( pcVPS ); |
---|
1418 | } |
---|
1419 | READ_FLAG( uiCode, "vps_extension3_flag" ); |
---|
1420 | if (uiCode) |
---|
1421 | { |
---|
1422 | #endif |
---|
1423 | #endif |
---|
1424 | while ( xMoreRbspData() ) |
---|
1425 | { |
---|
1426 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1427 | } |
---|
1428 | #if NH_MV |
---|
1429 | #if NH_3D |
---|
1430 | } |
---|
1431 | #endif |
---|
1432 | } |
---|
1433 | #endif |
---|
1434 | } |
---|
1435 | |
---|
1436 | xReadRbspTrailingBits(); |
---|
1437 | } |
---|
1438 | |
---|
1439 | #if NH_MV |
---|
1440 | Void TDecCavlc::parseVPSExtension( TComVPS* pcVPS ) |
---|
1441 | { |
---|
1442 | UInt uiCode; |
---|
1443 | |
---|
1444 | if( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
1445 | { |
---|
1446 | parsePTL( pcVPS->getPTL( 1 ),0, pcVPS->getMaxSubLayersMinus1() ); |
---|
1447 | |
---|
1448 | pcVPS->getPTL( 1 )->inferGeneralValues ( false, 1, pcVPS->getPTL( 0 ) ); |
---|
1449 | pcVPS->getPTL( 1 )->inferSubLayerValues( pcVPS->getMaxSubLayersMinus1(), 1, pcVPS->getPTL( 0 ) ); |
---|
1450 | } |
---|
1451 | |
---|
1452 | READ_FLAG( uiCode, "splitting_flag" ); pcVPS->setSplittingFlag( uiCode == 1 ? true : false ); |
---|
1453 | |
---|
1454 | for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ ) |
---|
1455 | { |
---|
1456 | READ_FLAG( uiCode, "scalability_mask_flag[i]" ); pcVPS->setScalabilityMaskFlag( sIdx, uiCode == 1 ? true : false ); |
---|
1457 | } |
---|
1458 | |
---|
1459 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
1460 | { |
---|
1461 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); pcVPS->setDimensionIdLen( sIdx, uiCode + 1 ); |
---|
1462 | } |
---|
1463 | |
---|
1464 | if ( pcVPS->getSplittingFlag() ) |
---|
1465 | { |
---|
1466 | pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() ); |
---|
1467 | } |
---|
1468 | |
---|
1469 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false ); |
---|
1470 | |
---|
1471 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1472 | { |
---|
1473 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() ) |
---|
1474 | { |
---|
1475 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); pcVPS->setLayerIdInNuh( i, uiCode ); |
---|
1476 | } |
---|
1477 | else |
---|
1478 | { |
---|
1479 | pcVPS->setLayerIdInNuh( i, i );; |
---|
1480 | } |
---|
1481 | |
---|
1482 | pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); |
---|
1483 | |
---|
1484 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
1485 | { |
---|
1486 | if ( !pcVPS->getSplittingFlag() ) |
---|
1487 | { |
---|
1488 | READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" ); pcVPS->setDimensionId( i, j, uiCode ); |
---|
1489 | } |
---|
1490 | else |
---|
1491 | { |
---|
1492 | pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j) ); |
---|
1493 | } |
---|
1494 | } |
---|
1495 | } |
---|
1496 | |
---|
1497 | pcVPS->initNumViews(); |
---|
1498 | |
---|
1499 | READ_CODE( 4, uiCode, "view_id_len" ); pcVPS->setViewIdLen( uiCode ); |
---|
1500 | |
---|
1501 | if ( pcVPS->getViewIdLen( ) > 0 ) |
---|
1502 | { |
---|
1503 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1504 | { |
---|
1505 | READ_CODE( pcVPS->getViewIdLen( ), uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode ); |
---|
1506 | } |
---|
1507 | } |
---|
1508 | else |
---|
1509 | { |
---|
1510 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1511 | { |
---|
1512 | pcVPS->setViewIdVal( i, 0 ); |
---|
1513 | } |
---|
1514 | } |
---|
1515 | |
---|
1516 | #if NH_3D |
---|
1517 | pcVPS->initViewCompLayer( ); |
---|
1518 | #endif |
---|
1519 | |
---|
1520 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1521 | { |
---|
1522 | for( Int j = 0; j < i; j++ ) |
---|
1523 | { |
---|
1524 | READ_FLAG( uiCode, "direct_dependency_flag[i][j]" ); pcVPS->setDirectDependencyFlag( i, j, uiCode ); |
---|
1525 | } |
---|
1526 | } |
---|
1527 | pcVPS->setRefLayers(); |
---|
1528 | |
---|
1529 | if ( pcVPS->getNumIndependentLayers() > 1 ) |
---|
1530 | { |
---|
1531 | READ_UVLC( uiCode, "num_add_layer_sets" ); pcVPS->setNumAddLayerSets( uiCode ); |
---|
1532 | } |
---|
1533 | for (Int i = 0; i < pcVPS->getNumAddLayerSets(); i++) |
---|
1534 | { |
---|
1535 | for (Int j = 1; j < pcVPS->getNumIndependentLayers(); j++) |
---|
1536 | { |
---|
1537 | READ_CODE( pcVPS->getHighestLayerIdxPlus1Len( j ) , uiCode, "highest_layer_idx_plus1" ); pcVPS->setHighestLayerIdxPlus1( i, j, uiCode ); |
---|
1538 | } |
---|
1539 | pcVPS->deriveAddLayerSetLayerIdList( i ); |
---|
1540 | } |
---|
1541 | |
---|
1542 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag" ); pcVPS->setVpsSubLayersMaxMinus1PresentFlag( uiCode == 1 ); |
---|
1543 | if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() ) |
---|
1544 | { |
---|
1545 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1546 | { |
---|
1547 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode ); |
---|
1548 | pcVPS->checkSubLayersVpsMaxMinus1( i ); |
---|
1549 | } |
---|
1550 | } |
---|
1551 | else |
---|
1552 | { |
---|
1553 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1554 | { |
---|
1555 | pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1); |
---|
1556 | } |
---|
1557 | } |
---|
1558 | READ_FLAG( uiCode, "max_tid_ref_present_flag" ); pcVPS->setMaxTidRefPresentFlag( uiCode == 1 ); |
---|
1559 | |
---|
1560 | if ( pcVPS->getMaxTidRefPresentFlag() ) |
---|
1561 | { |
---|
1562 | for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1563 | { |
---|
1564 | for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ ) |
---|
1565 | { |
---|
1566 | if ( pcVPS->getDirectDependencyFlag(j,i) ) |
---|
1567 | { |
---|
1568 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1" ); pcVPS->setMaxTidIlRefPicsPlus1( i, j, uiCode ); |
---|
1569 | } |
---|
1570 | } |
---|
1571 | } |
---|
1572 | } |
---|
1573 | |
---|
1574 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); pcVPS->setAllRefLayersActiveFlag( uiCode == 1 ); |
---|
1575 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1" ); pcVPS->setVpsNumProfileTierLevelMinus1( uiCode ); |
---|
1576 | |
---|
1577 | Int offsetVal = ( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) ? 2 : 1; |
---|
1578 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 2 : 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
1579 | { |
---|
1580 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 ); |
---|
1581 | parsePTL ( pcVPS->getPTL( offsetVal ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1); |
---|
1582 | pcVPS->getPTL( offsetVal )->inferGeneralValues ( pcVPS->getVpsProfilePresentFlag( i ), offsetVal, pcVPS->getPTL( offsetVal - 1 ) ); |
---|
1583 | pcVPS->getPTL( offsetVal )->inferSubLayerValues( pcVPS->getMaxSubLayersMinus1() , offsetVal, pcVPS->getPTL( offsetVal - 1 ) ); |
---|
1584 | offsetVal++; |
---|
1585 | } |
---|
1586 | |
---|
1587 | |
---|
1588 | if (pcVPS->getNumLayerSets() > 1) |
---|
1589 | { |
---|
1590 | READ_UVLC( uiCode, "num_add_olss" ); pcVPS->setNumAddOlss( uiCode ); |
---|
1591 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); pcVPS->setDefaultOutputLayerIdc( std::min( uiCode, (UInt) 2 ) ); |
---|
1592 | } |
---|
1593 | |
---|
1594 | pcVPS->initTargetLayerIdLists( ); |
---|
1595 | |
---|
1596 | |
---|
1597 | pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); |
---|
1598 | pcVPS->setLayerSetIdxForOlsMinus1(0, -1); |
---|
1599 | |
---|
1600 | pcVPS->deriveNecessaryLayerFlags( 0 ); |
---|
1601 | pcVPS->deriveTargetLayerIdList( 0 ); |
---|
1602 | |
---|
1603 | if (pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
1604 | { |
---|
1605 | pcVPS->setProfileTierLevelIdx(0,0, pcVPS->inferProfileTierLevelIdx(0,0) ); |
---|
1606 | } |
---|
1607 | for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ ) |
---|
1608 | { |
---|
1609 | if( pcVPS->getNumLayerSets() > 2 && i >= pcVPS->getNumLayerSets( ) ) |
---|
1610 | { |
---|
1611 | READ_CODE( pcVPS->getLayerSetIdxForOlsMinus1Len( i ), uiCode, "layer_set_idx_for_ols_minus1[i]" ); pcVPS->setLayerSetIdxForOlsMinus1( i, uiCode ); |
---|
1612 | } |
---|
1613 | |
---|
1614 | if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultOutputLayerIdc() == 2 ) |
---|
1615 | { |
---|
1616 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
1617 | { |
---|
1618 | READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); |
---|
1619 | } |
---|
1620 | } |
---|
1621 | else |
---|
1622 | { |
---|
1623 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
1624 | { |
---|
1625 | pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); |
---|
1626 | } |
---|
1627 | } |
---|
1628 | pcVPS->deriveNecessaryLayerFlags( i ); |
---|
1629 | pcVPS->deriveTargetLayerIdList( i ); |
---|
1630 | |
---|
1631 | for ( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx(i)); j++ ) |
---|
1632 | { |
---|
1633 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() > 0 ) |
---|
1634 | { |
---|
1635 | READ_CODE( pcVPS->getProfileTierLevelIdxLen(), uiCode,"profile_tier_level_idx[ i ][ j ]" ); pcVPS->setProfileTierLevelIdx( i, j, uiCode ); |
---|
1636 | } |
---|
1637 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() == 0 ) |
---|
1638 | { |
---|
1639 | pcVPS->setProfileTierLevelIdx( i , j, pcVPS->inferProfileTierLevelIdx( i, j) ); |
---|
1640 | } |
---|
1641 | } |
---|
1642 | |
---|
1643 | if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
1644 | { |
---|
1645 | READ_FLAG( uiCode, "alt_output_layer_flag[ i ]" ); pcVPS->setAltOutputLayerFlag( i, uiCode == 1 ); |
---|
1646 | } |
---|
1647 | } |
---|
1648 | |
---|
1649 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode ); |
---|
1650 | |
---|
1651 | std::vector<TComRepFormat> repFormats; |
---|
1652 | repFormats.resize( pcVPS->getVpsNumRepFormatsMinus1() + 1 ); |
---|
1653 | for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) |
---|
1654 | { |
---|
1655 | TComRepFormat* curRepFormat = &repFormats[i]; |
---|
1656 | TComRepFormat* prevRepFormat = i > 0 ? &repFormats[ i - 1] : NULL; |
---|
1657 | parseRepFormat( i, curRepFormat , prevRepFormat); |
---|
1658 | } |
---|
1659 | pcVPS->setRepFormat( repFormats ); |
---|
1660 | |
---|
1661 | if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) |
---|
1662 | { |
---|
1663 | READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 ); |
---|
1664 | } |
---|
1665 | if( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
1666 | { |
---|
1667 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1668 | { |
---|
1669 | READ_CODE( pcVPS->getVpsRepFormatIdxLen(), uiCode, "vps_rep_format_idx[i]" ); pcVPS->setVpsRepFormatIdx( i, uiCode ); |
---|
1670 | } |
---|
1671 | } |
---|
1672 | else |
---|
1673 | { |
---|
1674 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1675 | { |
---|
1676 | pcVPS->setVpsRepFormatIdx( i, pcVPS->inferVpsRepFormatIdx( i ) ); |
---|
1677 | } |
---|
1678 | } |
---|
1679 | |
---|
1680 | READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); |
---|
1681 | |
---|
1682 | READ_FLAG( uiCode, "vps_poc_lsb_aligned_flag" ); pcVPS->setVpsPocLsbAlignedFlag( uiCode == 1 ); |
---|
1683 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1684 | { |
---|
1685 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) == 0 ) |
---|
1686 | { |
---|
1687 | READ_FLAG( uiCode, "poc_lsb_not_present_flag" ); pcVPS->setPocLsbNotPresentFlag( i, uiCode == 1 ); |
---|
1688 | } |
---|
1689 | } |
---|
1690 | |
---|
1691 | parseDpbSize( pcVPS ); |
---|
1692 | |
---|
1693 | READ_UVLC( uiCode, "direct_dep_type_len_minus2") ; pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); |
---|
1694 | |
---|
1695 | READ_FLAG( uiCode, "default_direct_dependency_flag" ); pcVPS->setDefaultDirectDependencyFlag( uiCode == 1 ); |
---|
1696 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1697 | { |
---|
1698 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "default_direct_dependency_type" ); pcVPS->setDefaultDirectDependencyType( uiCode ); |
---|
1699 | } |
---|
1700 | |
---|
1701 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1702 | { |
---|
1703 | for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
1704 | { |
---|
1705 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
1706 | { |
---|
1707 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1708 | { |
---|
1709 | pcVPS->setDirectDependencyType( i, j , pcVPS->getDefaultDirectDependencyType( ) ); |
---|
1710 | } |
---|
1711 | else |
---|
1712 | { |
---|
1713 | |
---|
1714 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode); |
---|
1715 | } |
---|
1716 | } |
---|
1717 | } |
---|
1718 | } |
---|
1719 | READ_UVLC( uiCode, "vps_non_vui_extension_length" ); pcVPS->setVpsNonVuiExtensionLength( uiCode ); |
---|
1720 | for ( Int i = 1; i <= pcVPS->getVpsNonVuiExtensionLength(); i++ ) |
---|
1721 | { |
---|
1722 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); |
---|
1723 | } |
---|
1724 | READ_FLAG( uiCode, "vps_vui_present_flag" ); pcVPS->setVpsVuiPresentFlag( uiCode == 1 ); |
---|
1725 | |
---|
1726 | TComVPSVUI vpsVui; |
---|
1727 | if( pcVPS->getVpsVuiPresentFlag() ) |
---|
1728 | { |
---|
1729 | m_pcBitstream->readOutTrailingBits(); // vps_vui_alignment_bit_equal_to_one |
---|
1730 | parseVPSVUI( pcVPS, &vpsVui ); |
---|
1731 | } |
---|
1732 | else |
---|
1733 | { |
---|
1734 | // inference of syntax elements that differ from default inference (as done in constructor), when VPS VUI is not present |
---|
1735 | vpsVui.setCrossLayerIrapAlignedFlag( false ); |
---|
1736 | } |
---|
1737 | pcVPS->setVPSVUI( vpsVui ); |
---|
1738 | pcVPS->checkVPSExtensionSyntax(); |
---|
1739 | } |
---|
1740 | |
---|
1741 | Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, const TComRepFormat* pcPrevRepFormat ) |
---|
1742 | { |
---|
1743 | assert( pcRepFormat ); |
---|
1744 | |
---|
1745 | UInt uiCode; |
---|
1746 | |
---|
1747 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
1748 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
1749 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); pcRepFormat->setChromaAndBitDepthVpsPresentFlag( uiCode == 1 ); |
---|
1750 | |
---|
1751 | pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); |
---|
1752 | |
---|
1753 | if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
1754 | { |
---|
1755 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); pcRepFormat->setChromaFormatVpsIdc ( uiCode ); |
---|
1756 | if ( pcRepFormat->getChromaFormatVpsIdc() == 3 ) |
---|
1757 | { |
---|
1758 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); pcRepFormat->setSeparateColourPlaneVpsFlag( uiCode == 1 ); |
---|
1759 | } |
---|
1760 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); pcRepFormat->setBitDepthVpsLumaMinus8 ( uiCode ); |
---|
1761 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); pcRepFormat->setBitDepthVpsChromaMinus8 ( uiCode ); |
---|
1762 | } |
---|
1763 | else |
---|
1764 | { |
---|
1765 | pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat ); |
---|
1766 | } |
---|
1767 | READ_FLAG( uiCode, "conformance_window_vps_flag" ); pcRepFormat->setConformanceWindowVpsFlag( uiCode == 1 ); |
---|
1768 | if ( pcRepFormat->getConformanceWindowVpsFlag() ) |
---|
1769 | { |
---|
1770 | READ_UVLC( uiCode, "conf_win_vps_left_offset" ); pcRepFormat->setConfWinVpsLeftOffset( uiCode ); |
---|
1771 | READ_UVLC( uiCode, "conf_win_vps_right_offset" ); pcRepFormat->setConfWinVpsRightOffset( uiCode ); |
---|
1772 | READ_UVLC( uiCode, "conf_win_vps_top_offset" ); pcRepFormat->setConfWinVpsTopOffset( uiCode ); |
---|
1773 | READ_UVLC( uiCode, "conf_win_vps_bottom_offset" ); pcRepFormat->setConfWinVpsBottomOffset( uiCode ); |
---|
1774 | } |
---|
1775 | } |
---|
1776 | |
---|
1777 | |
---|
1778 | Void TDecCavlc::parseVPSVUI( const TComVPS* pcVPS, TComVPSVUI* vpsVui ) |
---|
1779 | { |
---|
1780 | assert( pcVPS ); |
---|
1781 | assert( vpsVui ); |
---|
1782 | |
---|
1783 | vpsVui->init(pcVPS->getNumAddLayerSets(),pcVPS->getMaxSubLayersMinus1() + 1, pcVPS->getMaxLayersMinus1() + 1 ); |
---|
1784 | |
---|
1785 | UInt uiCode; |
---|
1786 | READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); vpsVui->setCrossLayerPicTypeAlignedFlag( uiCode == 1 ); |
---|
1787 | if ( !vpsVui->getCrossLayerPicTypeAlignedFlag() ) |
---|
1788 | { |
---|
1789 | READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); vpsVui->setCrossLayerIrapAlignedFlag( uiCode == 1 ); |
---|
1790 | } |
---|
1791 | if( vpsVui->getCrossLayerIrapAlignedFlag( ) ) |
---|
1792 | { |
---|
1793 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); vpsVui->setAllLayersIdrAlignedFlag( uiCode == 1 ); |
---|
1794 | } |
---|
1795 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vpsVui->setBitRatePresentVpsFlag( uiCode == 1 ); |
---|
1796 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vpsVui->setPicRatePresentVpsFlag( uiCode == 1 ); |
---|
1797 | if( vpsVui->getBitRatePresentVpsFlag( ) || vpsVui->getPicRatePresentVpsFlag( ) ) |
---|
1798 | { |
---|
1799 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i < pcVPS->getNumLayerSets(); i++ ) |
---|
1800 | { |
---|
1801 | for( Int j = 0; j <= pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) |
---|
1802 | { |
---|
1803 | if( vpsVui->getBitRatePresentVpsFlag( ) ) |
---|
1804 | { |
---|
1805 | READ_FLAG( uiCode, "bit_rate_present_flag" ); vpsVui->setBitRatePresentFlag( i, j, uiCode == 1 ); |
---|
1806 | } |
---|
1807 | if( vpsVui->getPicRatePresentVpsFlag( ) ) |
---|
1808 | { |
---|
1809 | READ_FLAG( uiCode, "pic_rate_present_flag" ); vpsVui->setPicRatePresentFlag( i, j, uiCode == 1 ); |
---|
1810 | } |
---|
1811 | if( vpsVui->getBitRatePresentFlag( i, j ) ) |
---|
1812 | { |
---|
1813 | READ_CODE( 16, uiCode, "avg_bit_rate" ); vpsVui->setAvgBitRate( i, j, uiCode ); |
---|
1814 | READ_CODE( 16, uiCode, "max_bit_rate" ); vpsVui->setMaxBitRate( i, j, uiCode ); |
---|
1815 | } |
---|
1816 | if( vpsVui->getPicRatePresentFlag( i, j ) ) |
---|
1817 | { |
---|
1818 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); vpsVui->setConstantPicRateIdc( i, j, uiCode ); |
---|
1819 | READ_CODE( 16, uiCode, "avg_pic_rate" ); vpsVui->setAvgPicRate( i, j, uiCode ); |
---|
1820 | } |
---|
1821 | } |
---|
1822 | } |
---|
1823 | } |
---|
1824 | |
---|
1825 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vpsVui->setVideoSignalInfoIdxPresentFlag( uiCode == 1 ); |
---|
1826 | if( vpsVui->getVideoSignalInfoIdxPresentFlag() ) |
---|
1827 | { |
---|
1828 | READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); vpsVui->setVpsNumVideoSignalInfoMinus1( uiCode ); |
---|
1829 | } |
---|
1830 | else |
---|
1831 | { |
---|
1832 | vpsVui->setVpsNumVideoSignalInfoMinus1( (pcVPS->getMaxLayersMinus1() - pcVPS->getVpsBaseLayerInternalFlag()) ? 0 : 1 ); |
---|
1833 | } |
---|
1834 | |
---|
1835 | std::vector<TComVideoSignalInfo> videoSignalInfos; |
---|
1836 | videoSignalInfos.resize(vpsVui->getVpsNumVideoSignalInfoMinus1() + 1 ); |
---|
1837 | |
---|
1838 | for( Int i = 0; i <= vpsVui->getVpsNumVideoSignalInfoMinus1(); i++ ) |
---|
1839 | { |
---|
1840 | parseVideoSignalInfo( &videoSignalInfos[i] ); |
---|
1841 | } |
---|
1842 | vpsVui->setVideoSignalInfo( videoSignalInfos ); |
---|
1843 | |
---|
1844 | if( vpsVui->getVideoSignalInfoIdxPresentFlag() && vpsVui->getVpsNumVideoSignalInfoMinus1() > 0 ) |
---|
1845 | { |
---|
1846 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1847 | { |
---|
1848 | READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); vpsVui->setVpsVideoSignalInfoIdx( i, uiCode ); |
---|
1849 | } |
---|
1850 | } |
---|
1851 | else if ( !vpsVui->getVideoSignalInfoIdxPresentFlag() ) |
---|
1852 | { |
---|
1853 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1854 | { |
---|
1855 | vpsVui->setVpsVideoSignalInfoIdx( i, i ); |
---|
1856 | } |
---|
1857 | } |
---|
1858 | else |
---|
1859 | { |
---|
1860 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1861 | { |
---|
1862 | vpsVui->setVpsVideoSignalInfoIdx( i, 0 ); |
---|
1863 | } |
---|
1864 | } |
---|
1865 | |
---|
1866 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vpsVui->setTilesNotInUseFlag( uiCode == 1 ); |
---|
1867 | if( !vpsVui->getTilesNotInUseFlag() ) |
---|
1868 | { |
---|
1869 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1870 | { |
---|
1871 | READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); vpsVui->setTilesInUseFlag( i, uiCode == 1 ); |
---|
1872 | if( vpsVui->getTilesInUseFlag( i ) ) |
---|
1873 | { |
---|
1874 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); vpsVui->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 ); |
---|
1875 | } |
---|
1876 | } |
---|
1877 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1878 | { |
---|
1879 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ ) |
---|
1880 | { |
---|
1881 | Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getIdDirectRefLayer(pcVPS->getLayerIdInNuh( i ) , j )); |
---|
1882 | if( vpsVui->getTilesInUseFlag( i ) && vpsVui->getTilesInUseFlag( layerIdx ) ) |
---|
1883 | { |
---|
1884 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vpsVui->setTileBoundariesAlignedFlag( i, j, uiCode == 1 ); |
---|
1885 | } |
---|
1886 | } |
---|
1887 | } |
---|
1888 | } |
---|
1889 | |
---|
1890 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vpsVui->setWppNotInUseFlag( uiCode == 1 ); |
---|
1891 | |
---|
1892 | if( !vpsVui->getWppNotInUseFlag( )) |
---|
1893 | { |
---|
1894 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1895 | { |
---|
1896 | READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); vpsVui->setWppInUseFlag( i, uiCode == 1 ); |
---|
1897 | } |
---|
1898 | } |
---|
1899 | READ_FLAG( uiCode, "single_layer_for_non_irap_flag" ); vpsVui->setSingleLayerForNonIrapFlag( uiCode == 1 ); |
---|
1900 | READ_FLAG( uiCode, "higher_layer_irap_skip_flag" ); vpsVui->setHigherLayerIrapSkipFlag( uiCode == 1 ); |
---|
1901 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vpsVui->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
1902 | |
---|
1903 | if( vpsVui->getIlpRestrictedRefLayersFlag( ) ) |
---|
1904 | { |
---|
1905 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1906 | { |
---|
1907 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
1908 | { |
---|
1909 | if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getIdDirectRefLayer( pcVPS->getLayerIdInNuh( i ), j ) > 0 ) |
---|
1910 | { |
---|
1911 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); vpsVui->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
1912 | if( vpsVui->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
1913 | { |
---|
1914 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); vpsVui->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 ); |
---|
1915 | if( vpsVui->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
1916 | { |
---|
1917 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); vpsVui->setMinHorizontalCtuOffsetPlus1( i, j, uiCode ); |
---|
1918 | } |
---|
1919 | } |
---|
1920 | } |
---|
1921 | } |
---|
1922 | } |
---|
1923 | } |
---|
1924 | |
---|
1925 | READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); vpsVui->setVpsVuiBspHrdPresentFlag( uiCode == 1 ); |
---|
1926 | if ( vpsVui->getVpsVuiBspHrdPresentFlag( ) ) |
---|
1927 | { |
---|
1928 | assert(pcVPS->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
---|
1929 | parseVpsVuiBspHrdParameters( pcVPS, vpsVui ); |
---|
1930 | } |
---|
1931 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1932 | { |
---|
1933 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) |
---|
1934 | { |
---|
1935 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); vpsVui->setBaseLayerParameterSetCompatibilityFlag( i, uiCode == 1 ); |
---|
1936 | } |
---|
1937 | } |
---|
1938 | } |
---|
1939 | |
---|
1940 | Void TDecCavlc::parseVpsVuiBspHrdParameters( const TComVPS* pcVPS, TComVPSVUI* vpsVui ) |
---|
1941 | { |
---|
1942 | assert( pcVPS ); |
---|
1943 | assert( vpsVui ); |
---|
1944 | |
---|
1945 | TComVpsVuiBspHrdParameters vpsVuiBspHrdP; |
---|
1946 | |
---|
1947 | UInt uiCode; |
---|
1948 | READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vpsVuiBspHrdP.setVpsNumAddHrdParams( uiCode ); |
---|
1949 | vpsVuiBspHrdP.createAfterVpsNumAddHrdParams( pcVPS ); |
---|
1950 | for( Int i = pcVPS->getNumHrdParameters(); i < pcVPS->getNumHrdParameters() + vpsVuiBspHrdP.getVpsNumAddHrdParams(); i++ ) |
---|
1951 | { |
---|
1952 | if( i > 0 ) |
---|
1953 | { |
---|
1954 | READ_FLAG( uiCode, "cprms_add_present_flag" ); vpsVuiBspHrdP.setCprmsAddPresentFlag( i, uiCode == 1 ); |
---|
1955 | } |
---|
1956 | else |
---|
1957 | { |
---|
1958 | vpsVuiBspHrdP.setCprmsAddPresentFlag( i, true ); |
---|
1959 | } |
---|
1960 | |
---|
1961 | READ_UVLC( uiCode, "num_sub_layer_hrd_minus1" ); vpsVuiBspHrdP.setNumSubLayerHrdMinus1( i, uiCode ); |
---|
1962 | |
---|
1963 | TComHRD hrdParameters; |
---|
1964 | parseHrdParameters( &hrdParameters, vpsVuiBspHrdP.getCprmsAddPresentFlag( i ), vpsVuiBspHrdP.getNumSubLayerHrdMinus1( i ) ); |
---|
1965 | vpsVuiBspHrdP.setHrdParametermeters( i, hrdParameters ); |
---|
1966 | } |
---|
1967 | |
---|
1968 | vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( 0, 0, 0); |
---|
1969 | vpsVuiBspHrdP.createAfterNumPartitionsInSchemeMinus1( pcVPS, 0, 0 ); |
---|
1970 | |
---|
1971 | for( Int h = 0; h < pcVPS->getNumOutputLayerSets(); h++ ) |
---|
1972 | { |
---|
1973 | if ( h == 0) |
---|
1974 | { |
---|
1975 | vpsVuiBspHrdP.setNumSignalledPartitioningSchemes( h, 0 ); |
---|
1976 | } |
---|
1977 | else |
---|
1978 | { |
---|
1979 | READ_UVLC( uiCode, "num_signalled_partitioning_schemes" ); vpsVuiBspHrdP.setNumSignalledPartitioningSchemes( h, uiCode ); |
---|
1980 | } |
---|
1981 | vpsVuiBspHrdP.createAfterNumSignalledPartitioningSchemes( pcVPS, h ); |
---|
1982 | |
---|
1983 | for( Int j = 0; j < vpsVuiBspHrdP.getNumSignalledPartitioningSchemes( h ) + 1; j++ ) |
---|
1984 | { |
---|
1985 | if ( j == 0 && h == 0 ) |
---|
1986 | { |
---|
1987 | vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( h, j, uiCode ); |
---|
1988 | } |
---|
1989 | else if( j == 0 ) |
---|
1990 | { |
---|
1991 | vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( h, j, pcVPS->getNumLayersInIdList( h ) - 1 ); |
---|
1992 | } |
---|
1993 | else |
---|
1994 | { |
---|
1995 | READ_UVLC( uiCode, "num_partitions_in_scheme_minus1" ); vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( h, j, uiCode ); |
---|
1996 | } |
---|
1997 | vpsVuiBspHrdP.createAfterNumPartitionsInSchemeMinus1(pcVPS, h, j ); |
---|
1998 | |
---|
1999 | for( Int k = 0; k <= vpsVuiBspHrdP.getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
2000 | { |
---|
2001 | for( Int r = 0; r < pcVPS->getNumLayersInIdList(pcVPS->olsIdxToLsIdx( h ) ) ; r++ ) |
---|
2002 | { |
---|
2003 | if( h == 0 && j == 0 && k == 0 && r == 0 ) |
---|
2004 | { |
---|
2005 | vpsVuiBspHrdP.setLayerIncludedInPartitionFlag( h, j, k, r, true ); |
---|
2006 | } |
---|
2007 | else if ( h > 0 && j == 0 ) |
---|
2008 | { |
---|
2009 | vpsVuiBspHrdP.setLayerIncludedInPartitionFlag( h, j, k, r, (k == r) ); |
---|
2010 | } |
---|
2011 | else |
---|
2012 | { |
---|
2013 | READ_FLAG( uiCode, "layer_included_in_partition_flag" ); vpsVuiBspHrdP.setLayerIncludedInPartitionFlag( h, j, k, r, uiCode == 1 ); |
---|
2014 | } |
---|
2015 | } |
---|
2016 | } |
---|
2017 | } |
---|
2018 | if ( h > 0 ) |
---|
2019 | { |
---|
2020 | for( Int i = 0; i < vpsVuiBspHrdP.getNumSignalledPartitioningSchemes( h ) + 1; i++ ) |
---|
2021 | { |
---|
2022 | for( Int t = 0; t <= pcVPS->getMaxSubLayersInLayerSetMinus1( pcVPS->olsIdxToLsIdx( i ) ); t++ ) |
---|
2023 | { |
---|
2024 | READ_UVLC( uiCode, "num_bsp_schedules_minus1" ); vpsVuiBspHrdP.setNumBspSchedulesMinus1( h, i, t, uiCode ); |
---|
2025 | vpsVuiBspHrdP.createAfterNumBspSchedulesMinus1(pcVPS, h, i, t ); |
---|
2026 | for( Int j = 0; j <= vpsVuiBspHrdP.getNumBspSchedulesMinus1( h, i, t ); j++ ) |
---|
2027 | { |
---|
2028 | for( Int k = 0; k <= vpsVuiBspHrdP.getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
2029 | { |
---|
2030 | READ_CODE( vpsVuiBspHrdP.getBspHrdIdxLen( pcVPS ), uiCode, "bsp_hrd_idx" ); vpsVuiBspHrdP.setBspHrdIdx( h, i, t, j, k, uiCode ); |
---|
2031 | READ_UVLC( uiCode, "bsp_sched_idx" ); vpsVuiBspHrdP.setBspSchedIdx( h, i, t, j, k, uiCode ); |
---|
2032 | } |
---|
2033 | } |
---|
2034 | } |
---|
2035 | } |
---|
2036 | } |
---|
2037 | } |
---|
2038 | vpsVui->setVpsVuiBspHrdParameters( vpsVuiBspHrdP ); |
---|
2039 | } |
---|
2040 | |
---|
2041 | Void TDecCavlc::parseVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo ) |
---|
2042 | { |
---|
2043 | UInt uiCode; |
---|
2044 | READ_CODE( 3, uiCode, "video_vps_format" ); pcVideoSignalInfo->setVideoVpsFormat( uiCode ); |
---|
2045 | READ_FLAG( uiCode, "video_full_range_vps_flag" ); pcVideoSignalInfo->setVideoFullRangeVpsFlag( uiCode == 1 ); |
---|
2046 | READ_CODE( 8, uiCode, "colour_primaries_vps" ); pcVideoSignalInfo->setColourPrimariesVps( uiCode ); |
---|
2047 | READ_CODE( 8, uiCode, "transfer_characteristics_vps" ); pcVideoSignalInfo->setTransferCharacteristicsVps( uiCode ); |
---|
2048 | READ_CODE( 8, uiCode, "matrix_coeffs_vps" ); pcVideoSignalInfo->setMatrixCoeffsVps( uiCode ); |
---|
2049 | } |
---|
2050 | |
---|
2051 | Void TDecCavlc::parseDpbSize( TComVPS* vps ) |
---|
2052 | { |
---|
2053 | UInt uiCode; |
---|
2054 | TComDpbSize dpbSize; |
---|
2055 | |
---|
2056 | dpbSize.init( vps->getNumOutputLayerSets(), vps->getVpsMaxLayerId() + 1, vps->getMaxSubLayersMinus1() + 1 ) ; |
---|
2057 | |
---|
2058 | for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
2059 | { |
---|
2060 | Int currLsIdx = vps->olsIdxToLsIdx( i ); |
---|
2061 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize.setSubLayerFlagInfoPresentFlag( i, uiCode == 1 ); |
---|
2062 | for( Int j = 0; j <= vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) |
---|
2063 | { |
---|
2064 | if( j > 0 && dpbSize.getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
2065 | { |
---|
2066 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize.setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 ); |
---|
2067 | } |
---|
2068 | if( dpbSize.getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
2069 | { |
---|
2070 | for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ ) |
---|
2071 | { |
---|
2072 | if ( vps->getNecessaryLayerFlag( i, k ) && ( vps->getVpsBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(vps->olsIdxToLsIdx(i),k) != 0 ) )) |
---|
2073 | { |
---|
2074 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize.setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
2075 | } |
---|
2076 | else |
---|
2077 | { |
---|
2078 | if ( vps->getNecessaryLayerFlag( i, k ) && ( j == 0 ) && ( k == 0 )) |
---|
2079 | { |
---|
2080 | dpbSize.setMaxVpsDecPicBufferingMinus1(i ,k, j, 0 ); |
---|
2081 | } |
---|
2082 | } |
---|
2083 | } |
---|
2084 | READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize.setMaxVpsNumReorderPics( i, j, uiCode ); |
---|
2085 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize.setMaxVpsLatencyIncreasePlus1( i, j, uiCode ); |
---|
2086 | } |
---|
2087 | else |
---|
2088 | { |
---|
2089 | if ( j > 0 ) |
---|
2090 | { |
---|
2091 | for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ ) |
---|
2092 | { |
---|
2093 | if ( vps->getNecessaryLayerFlag(i, k ) ) |
---|
2094 | { |
---|
2095 | dpbSize.setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize.getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) ); |
---|
2096 | } |
---|
2097 | } |
---|
2098 | dpbSize.setMaxVpsNumReorderPics ( i, j, dpbSize.getMaxVpsNumReorderPics ( i, j - 1 ) ); |
---|
2099 | dpbSize.setMaxVpsLatencyIncreasePlus1( i, j, dpbSize.getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
2100 | } |
---|
2101 | } |
---|
2102 | } |
---|
2103 | } |
---|
2104 | vps->setDpbSize( dpbSize ); |
---|
2105 | } |
---|
2106 | |
---|
2107 | #if NH_3D |
---|
2108 | Void TDecCavlc::parseVps3dExtension( TComVPS* pcVPS ) |
---|
2109 | { |
---|
2110 | UInt uiCode; |
---|
2111 | READ_UVLC( uiCode, "cp_precision"); pcVPS->setCpPrecision( uiCode ) ; |
---|
2112 | |
---|
2113 | for (Int n = 1; n < pcVPS->getNumViews(); n++) |
---|
2114 | { |
---|
2115 | Int i = pcVPS->getViewOIdxList( n ); |
---|
2116 | Int iInVps = pcVPS->getVoiInVps( i ); |
---|
2117 | READ_CODE( 6, uiCode, "num_cp" ); pcVPS->setNumCp( iInVps, uiCode ); |
---|
2118 | |
---|
2119 | if( pcVPS->getNumCp( iInVps ) > 0 ) |
---|
2120 | { |
---|
2121 | READ_FLAG( uiCode, "cp_in_slice_segment_header_flag" ); pcVPS->setCpInSliceSegmentHeaderFlag( iInVps, uiCode == 1 ); |
---|
2122 | for( Int m = 0; m < pcVPS->getNumCp( iInVps ); m++ ) |
---|
2123 | { |
---|
2124 | READ_UVLC( uiCode, "cp_ref_voi" ); pcVPS->setCpRefVoi( iInVps, m, uiCode ); |
---|
2125 | if( !pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) ) |
---|
2126 | { |
---|
2127 | Int j = pcVPS->getCpRefVoi( iInVps, m ); |
---|
2128 | Int jInVps = pcVPS->getVoiInVps( j ); |
---|
2129 | Int iCode; |
---|
2130 | READ_SVLC( iCode, "vps_cp_scale" ); pcVPS->setVpsCpScale ( iInVps, jInVps, iCode ); |
---|
2131 | READ_SVLC( iCode, "vps_cp_off" ); pcVPS->setVpsCpOff ( iInVps, jInVps, iCode ); |
---|
2132 | READ_SVLC( iCode, "vps_cp_inv_scale_plus_scale" ); pcVPS->setVpsCpInvScale( iInVps, jInVps, iCode - pcVPS->getVpsCpScale( iInVps, jInVps ) ); |
---|
2133 | READ_SVLC( iCode, "vps_cp_inv_off_plus_off" ); pcVPS->setVpsCpInvOff ( iInVps, jInVps, iCode - pcVPS->getVpsCpOff ( iInVps, jInVps ) ); |
---|
2134 | } |
---|
2135 | } |
---|
2136 | } |
---|
2137 | } |
---|
2138 | pcVPS->deriveCpPresentFlag(); |
---|
2139 | } |
---|
2140 | #endif |
---|
2141 | #endif |
---|
2142 | |
---|
2143 | Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC) |
---|
2144 | { |
---|
2145 | UInt uiCode; |
---|
2146 | Int iCode; |
---|
2147 | |
---|
2148 | #if ENC_DEC_TRACE |
---|
2149 | #if NH_MV |
---|
2150 | tracePSHeader( "Slice", pcSlice->getLayerId() ); |
---|
2151 | #else |
---|
2152 | xTraceSliceHeader(); |
---|
2153 | #endif |
---|
2154 | #endif |
---|
2155 | TComPPS* pps = NULL; |
---|
2156 | TComSPS* sps = NULL; |
---|
2157 | #if NH_MV |
---|
2158 | TComVPS* vps = NULL; |
---|
2159 | #endif |
---|
2160 | |
---|
2161 | UInt firstSliceSegmentInPic; |
---|
2162 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
2163 | if( pcSlice->getRapPicFlag()) |
---|
2164 | { |
---|
2165 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already |
---|
2166 | pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); |
---|
2167 | } |
---|
2168 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode); |
---|
2169 | pps = parameterSetManager->getPPS(uiCode); |
---|
2170 | //!KS: need to add error handling code here, if PPS is not available |
---|
2171 | assert(pps!=0); |
---|
2172 | sps = parameterSetManager->getSPS(pps->getSPSId()); |
---|
2173 | //!KS: need to add error handling code here, if SPS is not available |
---|
2174 | assert(sps!=0); |
---|
2175 | #if NH_MV |
---|
2176 | vps = parameterSetManager->getVPS(sps->getVPSId()); |
---|
2177 | assert( vps != NULL ); |
---|
2178 | m_decTop->initFromActiveVps( vps ); |
---|
2179 | Int targetOlsIdx = m_decTop->getTargetOlsIdx(); |
---|
2180 | |
---|
2181 | // Do inference |
---|
2182 | sps->inferRepFormat ( vps , pcSlice->getLayerId(), false ); |
---|
2183 | sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
2184 | sps->inferSpsMaxDecPicBufferingMinus1( vps, targetOlsIdx, pcSlice->getLayerId(), false ); |
---|
2185 | |
---|
2186 | if( sps->getMultiLayerExtSpsFlag() ) |
---|
2187 | { |
---|
2188 | sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true ); |
---|
2189 | } |
---|
2190 | |
---|
2191 | if ( sps->getVuiParametersPresentFlag() ) |
---|
2192 | { |
---|
2193 | sps->getVuiParameters()->inferVideoSignalInfo( vps, pcSlice->getLayerId() ); |
---|
2194 | } |
---|
2195 | |
---|
2196 | |
---|
2197 | pcSlice->setVPS(vps); |
---|
2198 | pcSlice->setSPS(sps); |
---|
2199 | pcSlice->setPPS(pps); |
---|
2200 | |
---|
2201 | pcSlice->setViewId ( vps->getViewId ( pcSlice->getLayerId() ) ); |
---|
2202 | pcSlice->setViewIndex( vps->getViewIndex( pcSlice->getLayerId() ) ); |
---|
2203 | #if NH_3D |
---|
2204 | pcSlice->setIsDepth ( vps->getDepthId ( pcSlice->getLayerId() ) == 1 ); |
---|
2205 | #endif |
---|
2206 | #endif |
---|
2207 | |
---|
2208 | const ChromaFormat chFmt = sps->getChromaFormatIdc(); |
---|
2209 | const UInt numValidComp=getNumberValidComponents(chFmt); |
---|
2210 | const Bool bChroma=(chFmt!=CHROMA_400); |
---|
2211 | |
---|
2212 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
2213 | { |
---|
2214 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
2215 | } |
---|
2216 | else |
---|
2217 | { |
---|
2218 | pcSlice->setDependentSliceSegmentFlag(false); |
---|
2219 | } |
---|
2220 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
2221 | UInt sliceSegmentAddress = 0; |
---|
2222 | Int bitsSliceSegmentAddress = 0; |
---|
2223 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
2224 | { |
---|
2225 | bitsSliceSegmentAddress++; |
---|
2226 | } |
---|
2227 | |
---|
2228 | if(!firstSliceSegmentInPic) |
---|
2229 | { |
---|
2230 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
2231 | } |
---|
2232 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
2233 | pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. |
---|
2234 | pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture. |
---|
2235 | |
---|
2236 | #if NH_MV |
---|
2237 | UInt slicePicOrderCntLsb = 0; |
---|
2238 | #endif |
---|
2239 | |
---|
2240 | |
---|
2241 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
2242 | { |
---|
2243 | pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. |
---|
2244 | pcSlice->setSliceCurEndCtuTsAddr(numCTUs); |
---|
2245 | } |
---|
2246 | |
---|
2247 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
2248 | { |
---|
2249 | #if NH_MV |
---|
2250 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
2251 | |
---|
2252 | if ( pps->getNumExtraSliceHeaderBits() > esb ) |
---|
2253 | { |
---|
2254 | esb++; |
---|
2255 | READ_FLAG( uiCode, "discardable_flag" ); pcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
2256 | if ( uiCode == 1 ) |
---|
2257 | { |
---|
2258 | assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
---|
2259 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
---|
2260 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
---|
2261 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
---|
2262 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
---|
2263 | } |
---|
2264 | } |
---|
2265 | |
---|
2266 | if ( pps->getNumExtraSliceHeaderBits() > esb ) |
---|
2267 | { |
---|
2268 | esb++; |
---|
2269 | READ_FLAG( uiCode, "cross_layer_bla_flag" ); pcSlice->setCrossLayerBlaFlag( uiCode == 1 ); |
---|
2270 | } |
---|
2271 | pcSlice->checkCrossLayerBlaFlag( ); |
---|
2272 | |
---|
2273 | |
---|
2274 | for (; esb < pps->getNumExtraSliceHeaderBits(); esb++) |
---|
2275 | #else |
---|
2276 | for (Int i = 0; i < pps->getNumExtraSliceHeaderBits(); i++) |
---|
2277 | #endif |
---|
2278 | { |
---|
2279 | READ_FLAG(uiCode, "slice_reserved_flag[]"); // ignored |
---|
2280 | } |
---|
2281 | |
---|
2282 | READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); |
---|
2283 | if( pps->getOutputFlagPresentFlag() ) |
---|
2284 | { |
---|
2285 | READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
2286 | } |
---|
2287 | else |
---|
2288 | { |
---|
2289 | pcSlice->setPicOutputFlag( true ); |
---|
2290 | } |
---|
2291 | |
---|
2292 | // if (separate_colour_plane_flag == 1) |
---|
2293 | // read colour_plane_id |
---|
2294 | // (separate_colour_plane_flag == 1) is not supported in this version of the standard. |
---|
2295 | |
---|
2296 | #if NH_MV |
---|
2297 | Int iPOClsb = slicePicOrderCntLsb; // Needed later |
---|
2298 | if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() ) |
---|
2299 | { |
---|
2300 | READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb"); |
---|
2301 | } |
---|
2302 | pcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb ); |
---|
2303 | |
---|
2304 | Bool picOrderCntMSBZeroFlag = false; |
---|
2305 | |
---|
2306 | // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered?? |
---|
2307 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP ); |
---|
2308 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); |
---|
2309 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ); |
---|
2310 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || pcSlice->getIdrPicFlag(); |
---|
2311 | |
---|
2312 | // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 && !rpcSlice->getFirstPicInLayerDecodedFlag() ); |
---|
2313 | |
---|
2314 | Int picOrderCntMSB = 0; |
---|
2315 | |
---|
2316 | if ( !picOrderCntMSBZeroFlag ) |
---|
2317 | { |
---|
2318 | Int prevPicOrderCnt = prevTid0POC; |
---|
2319 | Int maxPicOrderCntLsb = 1 << sps->getBitsForPOC(); |
---|
2320 | Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1); |
---|
2321 | Int prevPicOrderCntMsb = prevPicOrderCnt - prevPicOrderCntLsb; |
---|
2322 | |
---|
2323 | if( ( slicePicOrderCntLsb < prevPicOrderCntLsb ) && ( ( prevPicOrderCntLsb - slicePicOrderCntLsb ) >= ( maxPicOrderCntLsb / 2 ) ) ) |
---|
2324 | { |
---|
2325 | picOrderCntMSB = prevPicOrderCntMsb + maxPicOrderCntLsb; |
---|
2326 | } |
---|
2327 | else if( (slicePicOrderCntLsb > prevPicOrderCntLsb ) && ( (slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) ) |
---|
2328 | { |
---|
2329 | picOrderCntMSB = prevPicOrderCntMsb - maxPicOrderCntLsb; |
---|
2330 | } |
---|
2331 | else |
---|
2332 | { |
---|
2333 | picOrderCntMSB = prevPicOrderCntMsb; |
---|
2334 | } |
---|
2335 | } |
---|
2336 | |
---|
2337 | pcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb ); |
---|
2338 | if ( pcSlice->getPocResetFlag() ) |
---|
2339 | { |
---|
2340 | pcSlice->setPocBeforeReset ( pcSlice->getPOC() ); |
---|
2341 | pcSlice->setPOC ( 0 ); |
---|
2342 | } |
---|
2343 | #endif |
---|
2344 | |
---|
2345 | if( pcSlice->getIdrPicFlag() ) |
---|
2346 | { |
---|
2347 | #if !NH_MV |
---|
2348 | pcSlice->setPOC(0); |
---|
2349 | #endif |
---|
2350 | TComReferencePictureSet* rps = pcSlice->getLocalRPS(); |
---|
2351 | (*rps)=TComReferencePictureSet(); |
---|
2352 | pcSlice->setRPS(rps); |
---|
2353 | #if NH_MV |
---|
2354 | pcSlice->setEnableTMVPFlag(false); |
---|
2355 | #endif |
---|
2356 | } |
---|
2357 | else |
---|
2358 | { |
---|
2359 | #if !NH_MV |
---|
2360 | READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb"); |
---|
2361 | Int iPOClsb = uiCode; |
---|
2362 | Int iPrevPOC = prevTid0POC; |
---|
2363 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
2364 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
2365 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
2366 | Int iPOCmsb; |
---|
2367 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
2368 | { |
---|
2369 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
2370 | } |
---|
2371 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
2372 | { |
---|
2373 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
2374 | } |
---|
2375 | else |
---|
2376 | { |
---|
2377 | iPOCmsb = iPrevPOCmsb; |
---|
2378 | } |
---|
2379 | if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2380 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
2381 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
2382 | { |
---|
2383 | // For BLA picture types, POCmsb is set to 0. |
---|
2384 | iPOCmsb = 0; |
---|
2385 | } |
---|
2386 | pcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
2387 | #endif |
---|
2388 | TComReferencePictureSet* rps; |
---|
2389 | rps = pcSlice->getLocalRPS(); |
---|
2390 | (*rps)=TComReferencePictureSet(); |
---|
2391 | |
---|
2392 | pcSlice->setRPS(rps); |
---|
2393 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
2394 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
2395 | { |
---|
2396 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
2397 | #if NH_MV |
---|
2398 | if ( !rps->getInterRPSPrediction( ) ) |
---|
2399 | { // check sum of num_positive_pics and num_negative_pics |
---|
2400 | rps->checkMaxNumPics( |
---|
2401 | vps->getVpsExtensionFlag(), |
---|
2402 | MAX_INT, // To be replaced by MaxDbpSize |
---|
2403 | pcSlice->getLayerId(), |
---|
2404 | sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
2405 | } |
---|
2406 | #endif |
---|
2407 | |
---|
2408 | } |
---|
2409 | else // use reference to short-term reference picture set in PPS |
---|
2410 | { |
---|
2411 | Int numBits = 0; |
---|
2412 | while ((1 << numBits) < sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
2413 | { |
---|
2414 | numBits++; |
---|
2415 | } |
---|
2416 | if (numBits > 0) |
---|
2417 | { |
---|
2418 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
2419 | } |
---|
2420 | else |
---|
2421 | { |
---|
2422 | uiCode = 0; |
---|
2423 | |
---|
2424 | } |
---|
2425 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
2426 | } |
---|
2427 | if(sps->getLongTermRefsPresent()) |
---|
2428 | { |
---|
2429 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
2430 | UInt numOfLtrp = 0; |
---|
2431 | UInt numLtrpInSPS = 0; |
---|
2432 | if (sps->getNumLongTermRefPicSPS() > 0) |
---|
2433 | { |
---|
2434 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
2435 | numLtrpInSPS = uiCode; |
---|
2436 | numOfLtrp += numLtrpInSPS; |
---|
2437 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
2438 | } |
---|
2439 | Int bitsForLtrpInSPS = 0; |
---|
2440 | while (sps->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
2441 | { |
---|
2442 | bitsForLtrpInSPS++; |
---|
2443 | } |
---|
2444 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
2445 | numOfLtrp += uiCode; |
---|
2446 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
2447 | Int maxPicOrderCntLSB = 1 << sps->getBitsForPOC(); |
---|
2448 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; |
---|
2449 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
2450 | { |
---|
2451 | Int pocLsbLt; |
---|
2452 | if (k < numLtrpInSPS) |
---|
2453 | { |
---|
2454 | uiCode = 0; |
---|
2455 | if (bitsForLtrpInSPS > 0) |
---|
2456 | { |
---|
2457 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
2458 | } |
---|
2459 | Bool usedByCurrFromSPS=sps->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
2460 | |
---|
2461 | pocLsbLt = sps->getLtRefPicPocLsbSps(uiCode); |
---|
2462 | rps->setUsed(j,usedByCurrFromSPS); |
---|
2463 | } |
---|
2464 | else |
---|
2465 | { |
---|
2466 | READ_CODE(sps->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
2467 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
2468 | } |
---|
2469 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
2470 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
2471 | if(mSBPresentFlag) |
---|
2472 | { |
---|
2473 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
2474 | Bool deltaFlag = false; |
---|
2475 | // First LTRP || First LTRP from SH |
---|
2476 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
2477 | { |
---|
2478 | deltaFlag = true; |
---|
2479 | } |
---|
2480 | if(deltaFlag) |
---|
2481 | { |
---|
2482 | deltaPocMSBCycleLT = uiCode; |
---|
2483 | } |
---|
2484 | else |
---|
2485 | { |
---|
2486 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
2487 | } |
---|
2488 | |
---|
2489 | Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
2490 | - iPOClsb + pocLsbLt; |
---|
2491 | rps->setPOC (j, pocLTCurr); |
---|
2492 | rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr); |
---|
2493 | rps->setCheckLTMSBPresent(j,true); |
---|
2494 | } |
---|
2495 | else |
---|
2496 | { |
---|
2497 | rps->setPOC (j, pocLsbLt); |
---|
2498 | rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt); |
---|
2499 | rps->setCheckLTMSBPresent(j,false); |
---|
2500 | |
---|
2501 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
2502 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
2503 | { |
---|
2504 | deltaPocMSBCycleLT = 0; |
---|
2505 | } |
---|
2506 | } |
---|
2507 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
2508 | } |
---|
2509 | offset += rps->getNumberOfLongtermPictures(); |
---|
2510 | rps->setNumberOfPictures(offset); |
---|
2511 | } |
---|
2512 | #if NH_MV |
---|
2513 | if ( !rps->getInterRPSPrediction( ) ) |
---|
2514 | { // check sum of NumPositivePics, NumNegativePics, num_long_term_sps and num_long_term_pics |
---|
2515 | rps->checkMaxNumPics( |
---|
2516 | vps->getVpsExtensionFlag(), |
---|
2517 | MAX_INT, // To be replaced by MaxDbpsize |
---|
2518 | pcSlice->getLayerId(), |
---|
2519 | sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
2520 | } |
---|
2521 | #endif |
---|
2522 | |
---|
2523 | if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2524 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
2525 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
2526 | { |
---|
2527 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
2528 | rps = pcSlice->getLocalRPS(); |
---|
2529 | (*rps)=TComReferencePictureSet(); |
---|
2530 | pcSlice->setRPS(rps); |
---|
2531 | } |
---|
2532 | if (sps->getTMVPFlagsPresent()) |
---|
2533 | { |
---|
2534 | #if NH_MV |
---|
2535 | READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); |
---|
2536 | #else |
---|
2537 | READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); |
---|
2538 | #endif |
---|
2539 | pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
2540 | } |
---|
2541 | else |
---|
2542 | { |
---|
2543 | pcSlice->setEnableTMVPFlag(false); |
---|
2544 | } |
---|
2545 | } |
---|
2546 | #if NH_MV |
---|
2547 | Bool interLayerPredLayerIdcPresentFlag = false; |
---|
2548 | Int layerId = pcSlice->getLayerId(); |
---|
2549 | #if NH_3D |
---|
2550 | if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 ) |
---|
2551 | #else |
---|
2552 | if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) |
---|
2553 | #endif |
---|
2554 | { |
---|
2555 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); pcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
2556 | #if NH_3D |
---|
2557 | if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 ) |
---|
2558 | #else |
---|
2559 | if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
2560 | #endif |
---|
2561 | { |
---|
2562 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
2563 | { |
---|
2564 | READ_CODE( pcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); pcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
2565 | } |
---|
2566 | #if NH_3D |
---|
2567 | if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) ) |
---|
2568 | #else |
---|
2569 | if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
2570 | #endif |
---|
2571 | { |
---|
2572 | interLayerPredLayerIdcPresentFlag = true; |
---|
2573 | for( Int idx = 0; idx < pcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
2574 | { |
---|
2575 | READ_CODE( pcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); pcSlice->setInterLayerPredLayerIdc( idx, uiCode ); |
---|
2576 | } |
---|
2577 | } |
---|
2578 | } |
---|
2579 | } |
---|
2580 | if ( !interLayerPredLayerIdcPresentFlag ) |
---|
2581 | { |
---|
2582 | for( Int i = 0; i < pcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
2583 | { |
---|
2584 | pcSlice->setInterLayerPredLayerIdc( i, pcSlice->getRefLayerPicIdc( i ) ); |
---|
2585 | } |
---|
2586 | } |
---|
2587 | #if NH_3D |
---|
2588 | if ( getDecTop()->decProcAnnexI() ) |
---|
2589 | { |
---|
2590 | pcSlice->deriveInCmpPredAndCpAvailFlag( ); |
---|
2591 | if ( pcSlice->getInCmpPredAvailFlag() ) |
---|
2592 | { |
---|
2593 | READ_FLAG(uiCode, "in_comp_pred_flag"); pcSlice->setInCompPredFlag((Bool)uiCode); |
---|
2594 | } |
---|
2595 | pcSlice->init3dToolParameters(); |
---|
2596 | } |
---|
2597 | #endif |
---|
2598 | #endif |
---|
2599 | if(sps->getUseSAO()) |
---|
2600 | { |
---|
2601 | READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (Bool)uiCode); |
---|
2602 | |
---|
2603 | if (bChroma) |
---|
2604 | { |
---|
2605 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (Bool)uiCode); |
---|
2606 | } |
---|
2607 | } |
---|
2608 | |
---|
2609 | if (pcSlice->getIdrPicFlag()) |
---|
2610 | { |
---|
2611 | pcSlice->setEnableTMVPFlag(false); |
---|
2612 | } |
---|
2613 | if (!pcSlice->isIntra()) |
---|
2614 | { |
---|
2615 | |
---|
2616 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
2617 | if (uiCode) |
---|
2618 | { |
---|
2619 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
2620 | if (pcSlice->isInterB()) |
---|
2621 | { |
---|
2622 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
2623 | } |
---|
2624 | else |
---|
2625 | { |
---|
2626 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
2627 | } |
---|
2628 | } |
---|
2629 | else |
---|
2630 | { |
---|
2631 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, pps->getNumRefIdxL0DefaultActive()); |
---|
2632 | if (pcSlice->isInterB()) |
---|
2633 | { |
---|
2634 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, pps->getNumRefIdxL1DefaultActive()); |
---|
2635 | } |
---|
2636 | else |
---|
2637 | { |
---|
2638 | pcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
2639 | } |
---|
2640 | } |
---|
2641 | } |
---|
2642 | // } |
---|
2643 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
2644 | if(!pcSlice->isIntra()) |
---|
2645 | { |
---|
2646 | if( !pps->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2647 | { |
---|
2648 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
2649 | } |
---|
2650 | else |
---|
2651 | { |
---|
2652 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
2653 | } |
---|
2654 | |
---|
2655 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
2656 | { |
---|
2657 | uiCode = 0; |
---|
2658 | Int i = 0; |
---|
2659 | Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); |
---|
2660 | if ( numRpsCurrTempList0 > 1 ) |
---|
2661 | { |
---|
2662 | Int length = 1; |
---|
2663 | numRpsCurrTempList0 --; |
---|
2664 | while ( numRpsCurrTempList0 >>= 1) |
---|
2665 | { |
---|
2666 | length ++; |
---|
2667 | } |
---|
2668 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2669 | { |
---|
2670 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
2671 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
2672 | } |
---|
2673 | } |
---|
2674 | else |
---|
2675 | { |
---|
2676 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2677 | { |
---|
2678 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
2679 | } |
---|
2680 | } |
---|
2681 | } |
---|
2682 | } |
---|
2683 | else |
---|
2684 | { |
---|
2685 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
2686 | } |
---|
2687 | if(pcSlice->isInterB()) |
---|
2688 | { |
---|
2689 | if( !pps->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2690 | { |
---|
2691 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
2692 | } |
---|
2693 | else |
---|
2694 | { |
---|
2695 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
2696 | } |
---|
2697 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
2698 | { |
---|
2699 | uiCode = 0; |
---|
2700 | Int i = 0; |
---|
2701 | Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); |
---|
2702 | if ( numRpsCurrTempList1 > 1 ) |
---|
2703 | { |
---|
2704 | Int length = 1; |
---|
2705 | numRpsCurrTempList1 --; |
---|
2706 | while ( numRpsCurrTempList1 >>= 1) |
---|
2707 | { |
---|
2708 | length ++; |
---|
2709 | } |
---|
2710 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2711 | { |
---|
2712 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
2713 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
2714 | } |
---|
2715 | } |
---|
2716 | else |
---|
2717 | { |
---|
2718 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2719 | { |
---|
2720 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
2721 | } |
---|
2722 | } |
---|
2723 | } |
---|
2724 | } |
---|
2725 | else |
---|
2726 | { |
---|
2727 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
2728 | } |
---|
2729 | if (pcSlice->isInterB()) |
---|
2730 | { |
---|
2731 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); pcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
2732 | } |
---|
2733 | |
---|
2734 | pcSlice->setCabacInitFlag( false ); // default |
---|
2735 | if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra()) |
---|
2736 | { |
---|
2737 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
2738 | pcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
2739 | } |
---|
2740 | |
---|
2741 | if ( pcSlice->getEnableTMVPFlag() ) |
---|
2742 | { |
---|
2743 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
2744 | { |
---|
2745 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
2746 | pcSlice->setColFromL0Flag(uiCode); |
---|
2747 | } |
---|
2748 | else |
---|
2749 | { |
---|
2750 | pcSlice->setColFromL0Flag( 1 ); |
---|
2751 | } |
---|
2752 | |
---|
2753 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
2754 | ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
2755 | (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
2756 | { |
---|
2757 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
2758 | pcSlice->setColRefIdx(uiCode); |
---|
2759 | } |
---|
2760 | else |
---|
2761 | { |
---|
2762 | pcSlice->setColRefIdx(0); |
---|
2763 | } |
---|
2764 | } |
---|
2765 | if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) |
---|
2766 | { |
---|
2767 | xParsePredWeightTable(pcSlice, sps); |
---|
2768 | pcSlice->initWpScaling(sps); |
---|
2769 | } |
---|
2770 | |
---|
2771 | #if NH_3D_IC |
---|
2772 | else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) |
---|
2773 | && !pcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0 |
---|
2774 | && getDecTop()->decProcAnnexI() |
---|
2775 | ) |
---|
2776 | { |
---|
2777 | UInt uiCodeTmp = 0; |
---|
2778 | |
---|
2779 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
2780 | pcSlice->setApplyIC( uiCodeTmp ); |
---|
2781 | |
---|
2782 | if ( uiCodeTmp ) |
---|
2783 | { |
---|
2784 | READ_FLAG ( uiCodeTmp, "slice_ic_disabled_merge_zero_idx_flag" ); |
---|
2785 | pcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
2786 | } |
---|
2787 | } |
---|
2788 | #endif |
---|
2789 | |
---|
2790 | if (!pcSlice->isIntra()) |
---|
2791 | { |
---|
2792 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
2793 | #if NH_3D_IV_MERGE |
---|
2794 | pcSlice->setMaxNumMergeCand(( ( pcSlice->getMpiFlag() || pcSlice->getIvMvPredFlag() || pcSlice->getViewSynthesisPredFlag() ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
2795 | #else |
---|
2796 | pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
2797 | #endif |
---|
2798 | } |
---|
2799 | |
---|
2800 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
2801 | pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
2802 | |
---|
2803 | assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) ); |
---|
2804 | assert( pcSlice->getSliceQp() <= 51 ); |
---|
2805 | |
---|
2806 | if (pps->getSliceChromaQpFlag()) |
---|
2807 | { |
---|
2808 | if (numValidComp>COMPONENT_Cb) |
---|
2809 | { |
---|
2810 | READ_SVLC( iCode, "slice_cb_qp_offset" ); |
---|
2811 | pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode ); |
---|
2812 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >= -12 ); |
---|
2813 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) <= 12 ); |
---|
2814 | assert( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >= -12 ); |
---|
2815 | assert( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) <= 12 ); |
---|
2816 | } |
---|
2817 | |
---|
2818 | if (numValidComp>COMPONENT_Cr) |
---|
2819 | { |
---|
2820 | READ_SVLC( iCode, "slice_cr_qp_offset" ); |
---|
2821 | pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode ); |
---|
2822 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >= -12 ); |
---|
2823 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) <= 12 ); |
---|
2824 | assert( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >= -12 ); |
---|
2825 | assert( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) <= 12 ); |
---|
2826 | } |
---|
2827 | } |
---|
2828 | |
---|
2829 | if (pps->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag()) |
---|
2830 | { |
---|
2831 | READ_FLAG(uiCode, "cu_chroma_qp_offset_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0); |
---|
2832 | } |
---|
2833 | else |
---|
2834 | { |
---|
2835 | pcSlice->setUseChromaQpAdj(false); |
---|
2836 | } |
---|
2837 | |
---|
2838 | if (pps->getDeblockingFilterControlPresentFlag()) |
---|
2839 | { |
---|
2840 | if(pps->getDeblockingFilterOverrideEnabledFlag()) |
---|
2841 | { |
---|
2842 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
2843 | } |
---|
2844 | else |
---|
2845 | { |
---|
2846 | pcSlice->setDeblockingFilterOverrideFlag(0); |
---|
2847 | } |
---|
2848 | if(pcSlice->getDeblockingFilterOverrideFlag()) |
---|
2849 | { |
---|
2850 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
2851 | if(!pcSlice->getDeblockingFilterDisable()) |
---|
2852 | { |
---|
2853 | READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
2854 | assert(pcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
2855 | pcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
2856 | READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
2857 | assert(pcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
2858 | pcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
2859 | } |
---|
2860 | } |
---|
2861 | else |
---|
2862 | { |
---|
2863 | pcSlice->setDeblockingFilterDisable ( pps->getPicDisableDeblockingFilterFlag() ); |
---|
2864 | pcSlice->setDeblockingFilterBetaOffsetDiv2( pps->getDeblockingFilterBetaOffsetDiv2() ); |
---|
2865 | pcSlice->setDeblockingFilterTcOffsetDiv2 ( pps->getDeblockingFilterTcOffsetDiv2() ); |
---|
2866 | } |
---|
2867 | } |
---|
2868 | else |
---|
2869 | { |
---|
2870 | pcSlice->setDeblockingFilterDisable ( false ); |
---|
2871 | pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
2872 | pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
2873 | } |
---|
2874 | |
---|
2875 | Bool isSAOEnabled = sps->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (bChroma && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); |
---|
2876 | Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); |
---|
2877 | |
---|
2878 | if(pps->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
2879 | { |
---|
2880 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
2881 | } |
---|
2882 | else |
---|
2883 | { |
---|
2884 | uiCode = pps->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
2885 | } |
---|
2886 | pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
2887 | |
---|
2888 | #if NH_3D |
---|
2889 | if ( getDecTop()->decProcAnnexI() ) |
---|
2890 | { |
---|
2891 | Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() ); |
---|
2892 | if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) && !pcSlice->getIsDepth() ) |
---|
2893 | { |
---|
2894 | for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ ) |
---|
2895 | { |
---|
2896 | Int jInVps = vps->getVoiInVps( vps->getCpRefVoi( voiInVps, m )); |
---|
2897 | READ_SVLC( iCode, "cp_scale" ); pcSlice->setCpScale ( jInVps, iCode ); |
---|
2898 | READ_SVLC( iCode, "cp_off" ); pcSlice->setCpOff ( jInVps, iCode ); |
---|
2899 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); pcSlice->setCpInvScale( jInVps, iCode - pcSlice->getCpScale ( jInVps )); |
---|
2900 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); pcSlice->setCpInvOff ( jInVps, iCode - pcSlice->getCpOff ( jInVps )); |
---|
2901 | } |
---|
2902 | } |
---|
2903 | } |
---|
2904 | #endif |
---|
2905 | |
---|
2906 | } |
---|
2907 | |
---|
2908 | std::vector<UInt> entryPointOffset; |
---|
2909 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2910 | { |
---|
2911 | UInt numEntryPointOffsets; |
---|
2912 | UInt offsetLenMinus1; |
---|
2913 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
2914 | if (numEntryPointOffsets>0) |
---|
2915 | { |
---|
2916 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2917 | entryPointOffset.resize(numEntryPointOffsets); |
---|
2918 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2919 | { |
---|
2920 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
2921 | entryPointOffset[ idx ] = uiCode + 1; |
---|
2922 | } |
---|
2923 | } |
---|
2924 | } |
---|
2925 | |
---|
2926 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2927 | { |
---|
2928 | #if NH_MV |
---|
2929 | READ_UVLC( uiCode, "slice_segment_header_extension_length" ); pcSlice->setSliceSegmentHeaderExtensionLength( uiCode ); |
---|
2930 | UInt posFollSliceSegHeaderExtLen = m_pcBitstream->getNumBitsRead(); |
---|
2931 | |
---|
2932 | if( pps->getPocResetInfoPresentFlag() ) |
---|
2933 | { |
---|
2934 | READ_CODE( 2, uiCode, "poc_reset_idc" ); pcSlice->setPocResetIdc( uiCode ); |
---|
2935 | } |
---|
2936 | else |
---|
2937 | { |
---|
2938 | pcSlice->setPocResetIdc( 0 ); |
---|
2939 | } |
---|
2940 | pcSlice->checkPocResetIdc(); |
---|
2941 | |
---|
2942 | if ( pcSlice->getVPS()->getPocLsbNotPresentFlag(pcSlice->getLayerId()) && slicePicOrderCntLsb > 0 ) |
---|
2943 | { |
---|
2944 | assert( pcSlice->getPocResetIdc() != 2 ); |
---|
2945 | } |
---|
2946 | |
---|
2947 | if( pcSlice->getPocResetIdc() != 0 ) |
---|
2948 | { |
---|
2949 | READ_CODE( 6, uiCode, "poc_reset_period_id" ); pcSlice->setPocResetPeriodId( uiCode ); |
---|
2950 | } |
---|
2951 | else |
---|
2952 | { |
---|
2953 | // TODO Copy poc_reset_period from earlier picture |
---|
2954 | pcSlice->setPocResetPeriodId( 0 ); |
---|
2955 | } |
---|
2956 | |
---|
2957 | if( pcSlice->getPocResetIdc() == 3 ) |
---|
2958 | { |
---|
2959 | READ_FLAG( uiCode, "full_poc_reset_flag" ); pcSlice->setFullPocResetFlag( uiCode == 1 ); |
---|
2960 | READ_CODE( pcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); pcSlice->setPocLsbVal( uiCode ); |
---|
2961 | } |
---|
2962 | pcSlice->checkPocLsbVal(); |
---|
2963 | |
---|
2964 | // Derive the value of PocMs8bValRequiredFlag |
---|
2965 | |
---|
2966 | if( !pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
2967 | { |
---|
2968 | READ_FLAG( uiCode, "poc_msb_val_present_flag" ); pcSlice->setPocMsbValPresentFlag( uiCode == 1 ); |
---|
2969 | } |
---|
2970 | else |
---|
2971 | { |
---|
2972 | pcSlice->setPocMsbValPresentFlag( pcSlice->inferPocMsbValPresentFlag( ) ); |
---|
2973 | } |
---|
2974 | |
---|
2975 | |
---|
2976 | if( pcSlice->getPocMsbValPresentFlag() ) |
---|
2977 | { |
---|
2978 | READ_UVLC( uiCode, "poc_msb_val" ); pcSlice->setPocMsbVal( uiCode ); |
---|
2979 | } |
---|
2980 | |
---|
2981 | while( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) < pcSlice->getSliceSegmentHeaderExtensionLength() * 8 ) |
---|
2982 | { |
---|
2983 | READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); |
---|
2984 | } |
---|
2985 | assert( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) == pcSlice->getSliceSegmentHeaderExtensionLength() * 8 ); |
---|
2986 | } |
---|
2987 | #else |
---|
2988 | |
---|
2989 | READ_UVLC(uiCode,"slice_segment_header_extension_length"); |
---|
2990 | for(Int i=0; i<uiCode; i++) |
---|
2991 | { |
---|
2992 | UInt ignore; |
---|
2993 | READ_CODE(8,ignore,"slice_segment_header_extension_data_byte"); |
---|
2994 | } |
---|
2995 | } |
---|
2996 | #endif |
---|
2997 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2998 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,m_pcBitstream->readByteAlignment(),0); |
---|
2999 | #else |
---|
3000 | m_pcBitstream->readByteAlignment(); |
---|
3001 | #endif |
---|
3002 | |
---|
3003 | pcSlice->clearSubstreamSizes(); |
---|
3004 | |
---|
3005 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
3006 | { |
---|
3007 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
3008 | |
---|
3009 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
3010 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
3011 | { |
---|
3012 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
3013 | { |
---|
3014 | endOfSliceHeaderLocation++; |
---|
3015 | } |
---|
3016 | } |
---|
3017 | |
---|
3018 | Int curEntryPointOffset = 0; |
---|
3019 | Int prevEntryPointOffset = 0; |
---|
3020 | for (UInt idx=0; idx<entryPointOffset.size(); idx++) |
---|
3021 | { |
---|
3022 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
3023 | |
---|
3024 | Int emulationPreventionByteCount = 0; |
---|
3025 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
3026 | { |
---|
3027 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
3028 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
3029 | { |
---|
3030 | emulationPreventionByteCount++; |
---|
3031 | } |
---|
3032 | } |
---|
3033 | |
---|
3034 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
3035 | prevEntryPointOffset = curEntryPointOffset; |
---|
3036 | pcSlice->addSubstreamSize(entryPointOffset [ idx ] ); |
---|
3037 | } |
---|
3038 | } |
---|
3039 | |
---|
3040 | return; |
---|
3041 | } |
---|
3042 | |
---|
3043 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
3044 | { |
---|
3045 | UInt uiCode; |
---|
3046 | if(profilePresentFlag) |
---|
3047 | { |
---|
3048 | parseProfileTier(rpcPTL->getGeneralPTL(), false); |
---|
3049 | } |
---|
3050 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(Level::Name(uiCode)); |
---|
3051 | |
---|
3052 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
3053 | { |
---|
3054 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
3055 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
3056 | #if NH_MV |
---|
3057 | // When profilePresentFlag is equal to 0, sub_layer_profile_present_flag[ i ] shall be equal to 0. |
---|
3058 | assert( profilePresentFlag || !rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
3059 | #endif |
---|
3060 | } |
---|
3061 | |
---|
3062 | if (maxNumSubLayersMinus1 > 0) |
---|
3063 | { |
---|
3064 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
3065 | { |
---|
3066 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
3067 | assert(uiCode == 0); |
---|
3068 | } |
---|
3069 | } |
---|
3070 | |
---|
3071 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
3072 | { |
---|
3073 | if( rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
3074 | { |
---|
3075 | parseProfileTier(rpcPTL->getSubLayerPTL(i), true); |
---|
3076 | } |
---|
3077 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
3078 | { |
---|
3079 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(Level::Name(uiCode)); |
---|
3080 | } |
---|
3081 | } |
---|
3082 | } |
---|
3083 | |
---|
3084 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
3085 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl, const Bool bIsSubLayer) |
---|
3086 | #define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt) |
---|
3087 | #else |
---|
3088 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl, const Bool /*bIsSubLayer*/) |
---|
3089 | #define PTL_TRACE_TEXT(txt) txt |
---|
3090 | #endif |
---|
3091 | { |
---|
3092 | UInt uiCode; |
---|
3093 | READ_CODE(2 , uiCode, PTL_TRACE_TEXT("profile_space" )); ptl->setProfileSpace(uiCode); |
---|
3094 | READ_FLAG( uiCode, PTL_TRACE_TEXT("tier_flag" )); ptl->setTierFlag (uiCode ? Level::HIGH : Level::MAIN); |
---|
3095 | READ_CODE(5 , uiCode, PTL_TRACE_TEXT("profile_idc" )); ptl->setProfileIdc (Profile::Name(uiCode)); |
---|
3096 | for(Int j = 0; j < 32; j++) |
---|
3097 | { |
---|
3098 | READ_FLAG( uiCode, PTL_TRACE_TEXT("profile_compatibility_flag[][j]" )); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
3099 | } |
---|
3100 | READ_FLAG(uiCode, PTL_TRACE_TEXT("progressive_source_flag" )); ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
3101 | |
---|
3102 | READ_FLAG(uiCode, PTL_TRACE_TEXT("interlaced_source_flag" )); ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
3103 | |
---|
3104 | READ_FLAG(uiCode, PTL_TRACE_TEXT("non_packed_constraint_flag" )); ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
3105 | |
---|
3106 | READ_FLAG(uiCode, PTL_TRACE_TEXT("frame_only_constraint_flag" )); ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
3107 | #if NH_MV |
---|
3108 | if( ptl->getV2ConstraintsPresentFlag() ) |
---|
3109 | { |
---|
3110 | READ_FLAG( uiCode, "max_12bit_constraint_flag" ); ptl->setMax12bitConstraintFlag ( uiCode == 1 ); |
---|
3111 | READ_FLAG( uiCode, "max_10bit_constraint_flag" ); ptl->setMax10bitConstraintFlag ( uiCode == 1 ); |
---|
3112 | READ_FLAG( uiCode, "max_8bit_constraint_flag" ); ptl->setMax8bitConstraintFlag ( uiCode == 1 ); |
---|
3113 | READ_FLAG( uiCode, "max_422chroma_constraint_flag" ); ptl->setMax422chromaConstraintFlag ( uiCode == 1 ); |
---|
3114 | READ_FLAG( uiCode, "max_420chroma_constraint_flag" ); ptl->setMax420chromaConstraintFlag ( uiCode == 1 ); |
---|
3115 | READ_FLAG( uiCode, "max_monochrome_constraint_flag" ); ptl->setMaxMonochromeConstraintFlag ( uiCode == 1 ); |
---|
3116 | READ_FLAG( uiCode, "intra_constraint_flag" ); ptl->setIntraConstraintFlag ( uiCode == 1 ); |
---|
3117 | READ_FLAG( uiCode, "one_picture_only_constraint_flag" ); ptl->setOnePictureOnlyConstraintFlag( uiCode == 1 ); |
---|
3118 | READ_FLAG( uiCode, "lower_bit_rate_constraint_flag" ); ptl->setLowerBitRateConstraintFlag ( uiCode == 1 ); |
---|
3119 | READ_CODE(16, uiCode, "XXX_reserved_zero_34bits[0..15]"); |
---|
3120 | READ_CODE(16, uiCode, "XXX_reserved_zero_34bits[16..31]"); |
---|
3121 | READ_CODE(2 , uiCode, "XXX_reserved_zero_34bits[32..33]"); |
---|
3122 | } |
---|
3123 | else |
---|
3124 | { |
---|
3125 | READ_CODE(16, uiCode, "XXX_reserved_zero_43bits[0..15]"); |
---|
3126 | READ_CODE(16, uiCode, "XXX_reserved_zero_43bits[16..31]"); |
---|
3127 | READ_CODE(11, uiCode, "XXX_reserved_zero_43bits[32..42]"); |
---|
3128 | } |
---|
3129 | if( ptl->getInbldPresentFlag() ) |
---|
3130 | { |
---|
3131 | READ_FLAG( uiCode, "inbld_flag" ); ptl->setInbldFlag( uiCode == 1 ); |
---|
3132 | } |
---|
3133 | else |
---|
3134 | { |
---|
3135 | READ_FLAG(uiCode, "reserved_zero_bit"); |
---|
3136 | } |
---|
3137 | #else |
---|
3138 | |
---|
3139 | if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileCompatibilityFlag(Profile::MAINREXT) || |
---|
3140 | ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT || ptl->getProfileCompatibilityFlag(Profile::HIGHTHROUGHPUTREXT)) |
---|
3141 | { |
---|
3142 | UInt maxBitDepth=16; |
---|
3143 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_12bit_constraint_flag" )); if (uiCode) maxBitDepth=12; |
---|
3144 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_10bit_constraint_flag" )); if (uiCode) maxBitDepth=10; |
---|
3145 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_8bit_constraint_flag" )); if (uiCode) maxBitDepth=8; |
---|
3146 | ptl->setBitDepthConstraint(maxBitDepth); |
---|
3147 | ChromaFormat chromaFmtConstraint=CHROMA_444; |
---|
3148 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_422chroma_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_422; |
---|
3149 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_420chroma_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_420; |
---|
3150 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_monochrome_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_400; |
---|
3151 | ptl->setChromaFormatConstraint(chromaFmtConstraint); |
---|
3152 | READ_FLAG( uiCode, PTL_TRACE_TEXT("intra_constraint_flag" )); ptl->setIntraConstraintFlag(uiCode != 0); |
---|
3153 | READ_FLAG( uiCode, PTL_TRACE_TEXT("one_picture_only_constraint_flag")); ptl->setOnePictureOnlyConstraintFlag(uiCode != 0); |
---|
3154 | READ_FLAG( uiCode, PTL_TRACE_TEXT("lower_bit_rate_constraint_flag" )); ptl->setLowerBitRateConstraintFlag(uiCode != 0); |
---|
3155 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]" )); |
---|
3156 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]" )); |
---|
3157 | READ_CODE(2, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]" )); |
---|
3158 | } |
---|
3159 | else |
---|
3160 | { |
---|
3161 | ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); |
---|
3162 | ptl->setChromaFormatConstraint(CHROMA_420); |
---|
3163 | ptl->setIntraConstraintFlag(false); |
---|
3164 | ptl->setLowerBitRateConstraintFlag(true); |
---|
3165 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]" )); |
---|
3166 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]" )); |
---|
3167 | READ_CODE(11, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]" )); |
---|
3168 | } |
---|
3169 | |
---|
3170 | if ((ptl->getProfileIdc() >= Profile::MAIN && ptl->getProfileIdc() <= Profile::HIGHTHROUGHPUTREXT) || |
---|
3171 | ptl->getProfileCompatibilityFlag(Profile::MAIN) || |
---|
3172 | ptl->getProfileCompatibilityFlag(Profile::MAIN10) || |
---|
3173 | ptl->getProfileCompatibilityFlag(Profile::MAINSTILLPICTURE) || |
---|
3174 | ptl->getProfileCompatibilityFlag(Profile::MAINREXT) || |
---|
3175 | ptl->getProfileCompatibilityFlag(Profile::HIGHTHROUGHPUTREXT) ) |
---|
3176 | { |
---|
3177 | READ_FLAG( uiCode, PTL_TRACE_TEXT("inbld_flag" )); assert(uiCode == 0); |
---|
3178 | } |
---|
3179 | else |
---|
3180 | { |
---|
3181 | READ_FLAG( uiCode, PTL_TRACE_TEXT("reserved_zero_bit" )); |
---|
3182 | } |
---|
3183 | #undef PTL_TRACE_TEXT |
---|
3184 | #endif |
---|
3185 | } |
---|
3186 | |
---|
3187 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
3188 | { |
---|
3189 | ruiBit = false; |
---|
3190 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
3191 | if(iBitsLeft <= 8) |
---|
3192 | { |
---|
3193 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
3194 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
3195 | { |
---|
3196 | ruiBit = true; |
---|
3197 | } |
---|
3198 | } |
---|
3199 | } |
---|
3200 | |
---|
3201 | Void TDecCavlc::parseRemainingBytes( Bool noTrailingBytesExpected ) |
---|
3202 | { |
---|
3203 | if (noTrailingBytesExpected) |
---|
3204 | { |
---|
3205 | const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); |
---|
3206 | assert (numberOfRemainingSubstreamBytes == 0); |
---|
3207 | } |
---|
3208 | else |
---|
3209 | { |
---|
3210 | while (m_pcBitstream->getNumBitsLeft()) |
---|
3211 | { |
---|
3212 | UInt trailingNullByte=m_pcBitstream->readByte(); |
---|
3213 | if (trailingNullByte!=0) |
---|
3214 | { |
---|
3215 | printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); |
---|
3216 | assert(trailingNullByte==0); |
---|
3217 | } |
---|
3218 | } |
---|
3219 | } |
---|
3220 | } |
---|
3221 | |
---|
3222 | #if NH_3D_DIS |
---|
3223 | Void TDecCavlc::parseDIS( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3224 | { |
---|
3225 | assert(0); |
---|
3226 | } |
---|
3227 | #endif |
---|
3228 | |
---|
3229 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3230 | { |
---|
3231 | assert(0); |
---|
3232 | } |
---|
3233 | |
---|
3234 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3235 | { |
---|
3236 | assert(0); |
---|
3237 | } |
---|
3238 | |
---|
3239 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
3240 | { |
---|
3241 | assert(0); |
---|
3242 | } |
---|
3243 | |
---|
3244 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3245 | { |
---|
3246 | assert(0); |
---|
3247 | } |
---|
3248 | |
---|
3249 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3250 | { |
---|
3251 | assert(0); |
---|
3252 | } |
---|
3253 | |
---|
3254 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3255 | { |
---|
3256 | assert(0); |
---|
3257 | } |
---|
3258 | |
---|
3259 | /** Parse I_PCM information. |
---|
3260 | * \param pcCU pointer to CU |
---|
3261 | * \param uiAbsPartIdx CU index |
---|
3262 | * \param uiDepth CU depth |
---|
3263 | * \returns Void |
---|
3264 | * |
---|
3265 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
3266 | */ |
---|
3267 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3268 | { |
---|
3269 | assert(0); |
---|
3270 | } |
---|
3271 | |
---|
3272 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3273 | { |
---|
3274 | assert(0); |
---|
3275 | } |
---|
3276 | |
---|
3277 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3278 | { |
---|
3279 | assert(0); |
---|
3280 | } |
---|
3281 | |
---|
3282 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
3283 | { |
---|
3284 | assert(0); |
---|
3285 | } |
---|
3286 | |
---|
3287 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
3288 | { |
---|
3289 | assert(0); |
---|
3290 | } |
---|
3291 | |
---|
3292 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
3293 | { |
---|
3294 | assert(0); |
---|
3295 | } |
---|
3296 | |
---|
3297 | Void TDecCavlc::parseCrossComponentPrediction( class TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
3298 | { |
---|
3299 | assert(0); |
---|
3300 | } |
---|
3301 | |
---|
3302 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
3303 | { |
---|
3304 | Int iDQp; |
---|
3305 | |
---|
3306 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
3307 | READ_SVLC(iDQp, "delta_qp"); |
---|
3308 | #else |
---|
3309 | xReadSvlc( iDQp ); |
---|
3310 | #endif |
---|
3311 | |
---|
3312 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
3313 | const Int qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
3314 | |
---|
3315 | const UInt maxCUDepth = pcCU->getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
3316 | const UInt maxCuDQPDepth = pcCU->getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
3317 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
3318 | const UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>doubleDepthDifference)<<doubleDepthDifference ; |
---|
3319 | const UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
3320 | |
---|
3321 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
3322 | } |
---|
3323 | |
---|
3324 | Void TDecCavlc::parseChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
3325 | { |
---|
3326 | assert(0); |
---|
3327 | } |
---|
3328 | |
---|
3329 | Void TDecCavlc::parseCoeffNxN( TComTU &/*rTu*/, ComponentID /*compID*/ ) |
---|
3330 | { |
---|
3331 | assert(0); |
---|
3332 | } |
---|
3333 | |
---|
3334 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
3335 | { |
---|
3336 | assert(0); |
---|
3337 | } |
---|
3338 | |
---|
3339 | Void TDecCavlc::parseQtCbf( TComTU &/*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) |
---|
3340 | { |
---|
3341 | assert(0); |
---|
3342 | } |
---|
3343 | |
---|
3344 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
3345 | { |
---|
3346 | assert(0); |
---|
3347 | } |
---|
3348 | |
---|
3349 | Void TDecCavlc::parseTransformSkipFlags (TComTU &/*rTu*/, ComponentID /*component*/) |
---|
3350 | { |
---|
3351 | assert(0); |
---|
3352 | } |
---|
3353 | |
---|
3354 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
3355 | { |
---|
3356 | assert(0); |
---|
3357 | } |
---|
3358 | |
---|
3359 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
3360 | { |
---|
3361 | assert(0); |
---|
3362 | } |
---|
3363 | |
---|
3364 | #if NH_3D_ARP |
---|
3365 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
3366 | { |
---|
3367 | assert(0); |
---|
3368 | } |
---|
3369 | #endif |
---|
3370 | #if NH_3D_IC |
---|
3371 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
3372 | { |
---|
3373 | assert(0); |
---|
3374 | } |
---|
3375 | #endif |
---|
3376 | #if NH_3D_SDC_INTRA || H_3D_INTER_SDC |
---|
3377 | Void TDecCavlc::parseSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
3378 | { |
---|
3379 | assert(0); |
---|
3380 | } |
---|
3381 | |
---|
3382 | #endif |
---|
3383 | #if NH_3D_DBBP |
---|
3384 | Void TDecCavlc::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
3385 | { |
---|
3386 | assert(0); |
---|
3387 | } |
---|
3388 | #endif |
---|
3389 | // ==================================================================================================================== |
---|
3390 | // Protected member functions |
---|
3391 | // ==================================================================================================================== |
---|
3392 | |
---|
3393 | //! parse explicit wp tables |
---|
3394 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice, const TComSPS *sps ) |
---|
3395 | { |
---|
3396 | WPScalingParam *wp; |
---|
3397 | const ChromaFormat chFmt = sps->getChromaFormatIdc(); |
---|
3398 | const Int numValidComp = Int(getNumberValidComponents(chFmt)); |
---|
3399 | const Bool bChroma = (chFmt!=CHROMA_400); |
---|
3400 | const SliceType eSliceType = pcSlice->getSliceType(); |
---|
3401 | const Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
3402 | UInt uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0; |
---|
3403 | UInt uiTotalSignalledWeightFlags = 0; |
---|
3404 | |
---|
3405 | Int iDeltaDenom; |
---|
3406 | // decode delta_luma_log2_weight_denom : |
---|
3407 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); |
---|
3408 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
3409 | if( bChroma ) |
---|
3410 | { |
---|
3411 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); |
---|
3412 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
3413 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
3414 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
3415 | } |
---|
3416 | |
---|
3417 | |
---|
3418 | |
---|
3419 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements |
---|
3420 | { |
---|
3421 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
3422 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
3423 | { |
---|
3424 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3425 | |
---|
3426 | wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
3427 | for(Int j=1; j<numValidComp; j++) |
---|
3428 | { |
---|
3429 | wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
3430 | } |
---|
3431 | |
---|
3432 | UInt uiCode; |
---|
3433 | READ_FLAG( uiCode, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" ); |
---|
3434 | wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 ); |
---|
3435 | uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; |
---|
3436 | } |
---|
3437 | if ( bChroma ) |
---|
3438 | { |
---|
3439 | UInt uiCode; |
---|
3440 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
3441 | { |
---|
3442 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3443 | READ_FLAG( uiCode, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" ); |
---|
3444 | for(Int j=1; j<numValidComp; j++) |
---|
3445 | { |
---|
3446 | wp[j].bPresentFlag = ( uiCode == 1 ); |
---|
3447 | } |
---|
3448 | uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; |
---|
3449 | } |
---|
3450 | } |
---|
3451 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
3452 | { |
---|
3453 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3454 | if ( wp[COMPONENT_Y].bPresentFlag ) |
---|
3455 | { |
---|
3456 | Int iDeltaWeight; |
---|
3457 | READ_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" ); |
---|
3458 | assert( iDeltaWeight >= -128 ); |
---|
3459 | assert( iDeltaWeight <= 127 ); |
---|
3460 | wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); |
---|
3461 | READ_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" ); |
---|
3462 | Int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<sps->getBitDepth(CHANNEL_TYPE_LUMA))/2 : 128; |
---|
3463 | assert( wp[0].iOffset >= -range ); |
---|
3464 | assert( wp[0].iOffset < range ); |
---|
3465 | } |
---|
3466 | else |
---|
3467 | { |
---|
3468 | wp[COMPONENT_Y].iWeight = (1 << wp[COMPONENT_Y].uiLog2WeightDenom); |
---|
3469 | wp[COMPONENT_Y].iOffset = 0; |
---|
3470 | } |
---|
3471 | if ( bChroma ) |
---|
3472 | { |
---|
3473 | if ( wp[COMPONENT_Cb].bPresentFlag ) |
---|
3474 | { |
---|
3475 | Int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<sps->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128; |
---|
3476 | for ( Int j=1 ; j<numValidComp ; j++ ) |
---|
3477 | { |
---|
3478 | Int iDeltaWeight; |
---|
3479 | READ_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" ); |
---|
3480 | assert( iDeltaWeight >= -128 ); |
---|
3481 | assert( iDeltaWeight <= 127 ); |
---|
3482 | wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom)); |
---|
3483 | |
---|
3484 | Int iDeltaChroma; |
---|
3485 | READ_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" ); |
---|
3486 | assert( iDeltaChroma >= -4*range); |
---|
3487 | assert( iDeltaChroma < 4*range); |
---|
3488 | Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
3489 | wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) ); |
---|
3490 | } |
---|
3491 | } |
---|
3492 | else |
---|
3493 | { |
---|
3494 | for ( Int j=1 ; j<numValidComp ; j++ ) |
---|
3495 | { |
---|
3496 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
3497 | wp[j].iOffset = 0; |
---|
3498 | } |
---|
3499 | } |
---|
3500 | } |
---|
3501 | } |
---|
3502 | |
---|
3503 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
3504 | { |
---|
3505 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3506 | |
---|
3507 | wp[0].bPresentFlag = false; |
---|
3508 | wp[1].bPresentFlag = false; |
---|
3509 | wp[2].bPresentFlag = false; |
---|
3510 | } |
---|
3511 | } |
---|
3512 | assert(uiTotalSignalledWeightFlags<=24); |
---|
3513 | } |
---|
3514 | |
---|
3515 | /** decode quantization matrix |
---|
3516 | * \param scalingList quantization matrix information |
---|
3517 | */ |
---|
3518 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
3519 | { |
---|
3520 | UInt code, sizeId, listId; |
---|
3521 | Bool scalingListPredModeFlag; |
---|
3522 | //for each size |
---|
3523 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3524 | { |
---|
3525 | for(listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
3526 | { |
---|
3527 | if ((sizeId==SCALING_LIST_32x32) && (listId%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) |
---|
3528 | { |
---|
3529 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
3530 | const Int size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
3531 | const Int *srcNextSmallerSize = scalingList->getScalingListAddress(sizeId-1, listId); |
---|
3532 | for(Int i=0; i<size; i++) |
---|
3533 | { |
---|
3534 | src[i] = srcNextSmallerSize[i]; |
---|
3535 | } |
---|
3536 | scalingList->setScalingListDC(sizeId,listId,(sizeId > SCALING_LIST_8x8) ? scalingList->getScalingListDC(sizeId-1, listId) : src[0]); |
---|
3537 | } |
---|
3538 | else |
---|
3539 | { |
---|
3540 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
3541 | scalingListPredModeFlag = (code) ? true : false; |
---|
3542 | scalingList->setScalingListPredModeFlag(sizeId, listId, scalingListPredModeFlag); |
---|
3543 | if(!scalingListPredModeFlag) //Copy Mode |
---|
3544 | { |
---|
3545 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
3546 | |
---|
3547 | if (sizeId==SCALING_LIST_32x32) |
---|
3548 | { |
---|
3549 | code*=(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries. |
---|
3550 | } |
---|
3551 | |
---|
3552 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
3553 | if( sizeId > SCALING_LIST_8x8 ) |
---|
3554 | { |
---|
3555 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
3556 | } |
---|
3557 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
3558 | |
---|
3559 | } |
---|
3560 | else //DPCM Mode |
---|
3561 | { |
---|
3562 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
3563 | } |
---|
3564 | } |
---|
3565 | } |
---|
3566 | } |
---|
3567 | |
---|
3568 | return; |
---|
3569 | } |
---|
3570 | /** decode DPCM |
---|
3571 | * \param scalingList quantization matrix information |
---|
3572 | * \param sizeId size index |
---|
3573 | * \param listId list index |
---|
3574 | */ |
---|
3575 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
3576 | { |
---|
3577 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
3578 | Int data; |
---|
3579 | Int scalingListDcCoefMinus8 = 0; |
---|
3580 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
3581 | UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; |
---|
3582 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
3583 | |
---|
3584 | if( sizeId > SCALING_LIST_8x8 ) |
---|
3585 | { |
---|
3586 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
3587 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
3588 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
3589 | } |
---|
3590 | |
---|
3591 | for(i = 0; i < coefNum; i++) |
---|
3592 | { |
---|
3593 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
3594 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
3595 | dst[scan[i]] = nextCoef; |
---|
3596 | } |
---|
3597 | } |
---|
3598 | |
---|
3599 | Bool TDecCavlc::xMoreRbspData() |
---|
3600 | { |
---|
3601 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
3602 | |
---|
3603 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
3604 | if (bitsLeft > 8) |
---|
3605 | { |
---|
3606 | return true; |
---|
3607 | } |
---|
3608 | |
---|
3609 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
3610 | Int cnt = bitsLeft; |
---|
3611 | |
---|
3612 | // remove trailing bits equal to zero |
---|
3613 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
3614 | { |
---|
3615 | lastByte >>= 1; |
---|
3616 | cnt--; |
---|
3617 | } |
---|
3618 | // remove bit equal to one |
---|
3619 | cnt--; |
---|
3620 | |
---|
3621 | // we should not have a negative number of bits |
---|
3622 | assert (cnt>=0); |
---|
3623 | |
---|
3624 | // we have more data, if cnt is not zero |
---|
3625 | return (cnt>0); |
---|
3626 | } |
---|
3627 | |
---|
3628 | Void TDecCavlc::parseExplicitRdpcmMode( TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
3629 | { |
---|
3630 | assert(0); |
---|
3631 | } |
---|
3632 | //! \} |
---|
3633 | |
---|