HEVC Test Model (HM)  HM-16.3
TDecCAVLC.cpp
Go to the documentation of this file.
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 
38 #include "TDecCAVLC.h"
39 #include "SEIread.h"
40 #include "TDecSlice.h"
42 #if RExt__DECODER_DEBUG_BIT_STATISTICS
44 #endif
45 
48 
49 #if ENC_DEC_TRACE
50 
52 {
53  fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() );
54 }
55 
57 {
58  fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() );
59 }
60 
62 {
63  fprintf( g_hTrace, "=========== Slice ===========\n");
64 }
65 
66 #endif
67 
68 // ====================================================================================================================
69 // Constructor / destructor / create / destroy
70 // ====================================================================================================================
71 
73 {
74 }
75 
77 {
78 
79 }
80 
81 // ====================================================================================================================
82 // Public member functions
83 // ====================================================================================================================
84 
86 {
87  UInt code;
88  UInt interRPSPred;
89  if (idx > 0)
90  {
91  READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred);
92  }
93  else
94  {
95  interRPSPred = false;
96  rps->setInterRPSPrediction(false);
97  }
98 
99  if (interRPSPred)
100  {
101  UInt bit;
102  if(idx == sps->getRPSList()->getNumberOfReferencePictureSets())
103  {
104  READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1
105  }
106  else
107  {
108  code = 0;
109  }
110  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
111  Int rIdx = idx - 1 - code;
112  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
114  Int k = 0, k0 = 0, k1 = 0;
115  READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign
116  READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1
117  Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS
118  for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++)
119  {
120  READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1
121  Int refIdc = bit;
122  if (refIdc == 0)
123  {
124  READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise.
125  refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0.
126  }
127  if (refIdc == 1 || refIdc == 2)
128  {
129  Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0);
130  rps->setDeltaPOC(k, deltaPOC);
131  rps->setUsed(k, (refIdc == 1));
132 
133  if (deltaPOC < 0)
134  {
135  k0++;
136  }
137  else
138  {
139  k1++;
140  }
141  k++;
142  }
143  rps->setRefIdc(j,refIdc);
144  }
145  rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1);
146  rps->setNumberOfPictures(k);
149  rps->sortDeltaPOC();
150  }
151  else
152  {
153  READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code);
154  READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code);
155  Int prev = 0;
156  Int poc;
157  for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++)
158  {
159  READ_UVLC(code, "delta_poc_s0_minus1");
160  poc = prev-code-1;
161  prev = poc;
162  rps->setDeltaPOC(j,poc);
163  READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code);
164  }
165  prev = 0;
167  {
168  READ_UVLC(code, "delta_poc_s1_minus1");
169  poc = prev+code+1;
170  prev = poc;
171  rps->setDeltaPOC(j,poc);
172  READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code);
173  }
175  }
176 #if PRINT_RPS_INFO
177  rps->printDeltaPOC();
178 #endif
179 }
180 
182 {
183 #if ENC_DEC_TRACE
184  xTracePPSHeader (pcPPS);
185 #endif
186  UInt uiCode;
187 
188  Int iCode;
189 
190  READ_UVLC( uiCode, "pps_pic_parameter_set_id");
191  assert(uiCode <= 63);
192  pcPPS->setPPSId (uiCode);
193 
194  READ_UVLC( uiCode, "pps_seq_parameter_set_id");
195  assert(uiCode <= 15);
196  pcPPS->setSPSId (uiCode);
197 
198  READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 );
199 
200  READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 );
201 
202  READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode);
203 
204  READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode );
205 
206  READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false );
207 
208  READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1");
209  assert(uiCode <= 14);
210  pcPPS->setNumRefIdxL0DefaultActive(uiCode+1);
211 
212  READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");
213  assert(uiCode <= 14);
214  pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
215 
216  READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode);
217  READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false );
218  READ_FLAG( uiCode, "transform_skip_enabled_flag" );
219  pcPPS->setUseTransformSkip ( uiCode ? true : false );
220 
221  READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false );
222  if( pcPPS->getUseDQP() )
223  {
224  READ_UVLC( uiCode, "diff_cu_qp_delta_depth" );
225  pcPPS->setMaxCuDQPDepth( uiCode );
226  }
227  else
228  {
229  pcPPS->setMaxCuDQPDepth( 0 );
230  }
231  READ_SVLC( iCode, "pps_cb_qp_offset");
232  pcPPS->setQpOffset(COMPONENT_Cb, iCode);
233  assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 );
234  assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 );
235 
236  READ_SVLC( iCode, "pps_cr_qp_offset");
237  pcPPS->setQpOffset(COMPONENT_Cr, iCode);
238  assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 );
239  assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 );
240 
241  assert(MAX_NUM_COMPONENT<=3);
242 
243  READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" );
244  pcPPS->setSliceChromaQpFlag( uiCode ? true : false );
245 
246  READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE)
247  pcPPS->setUseWP( uiCode==1 );
248  READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE)
249  pcPPS->setWPBiPred( uiCode==1 );
250 
251  READ_FLAG( uiCode, "transquant_bypass_enable_flag");
252  pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false);
253  READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 );
254  READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 );
255 
256  if( pcPPS->getTilesEnabledFlag() )
257  {
258  READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumTileColumnsMinus1( uiCode );
259  READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumTileRowsMinus1( uiCode );
260  READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 );
261 
262  const UInt tileColumnsMinus1 = pcPPS->getNumTileColumnsMinus1();
263  const UInt tileRowsMinus1 = pcPPS->getNumTileRowsMinus1();
264 
265  if ( !pcPPS->getTileUniformSpacingFlag())
266  {
267  if (tileColumnsMinus1 > 0)
268  {
269  std::vector<Int> columnWidth(tileColumnsMinus1);
270  for(UInt i = 0; i < tileColumnsMinus1; i++)
271  {
272  READ_UVLC( uiCode, "column_width_minus1" );
273  columnWidth[i] = uiCode+1;
274  }
275  pcPPS->setTileColumnWidth(columnWidth);
276  }
277 
278  if (tileRowsMinus1 > 0)
279  {
280  std::vector<Int> rowHeight (tileRowsMinus1);
281  for(UInt i = 0; i < tileRowsMinus1; i++)
282  {
283  READ_UVLC( uiCode, "row_height_minus1" );
284  rowHeight[i] = uiCode + 1;
285  }
286  pcPPS->setTileRowHeight(rowHeight);
287  }
288  }
289 
290  if ((tileColumnsMinus1 + tileRowsMinus1) != 0)
291  {
292  READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false );
293  }
294  }
295  READ_FLAG( uiCode, "pps_loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false );
296  READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false );
298  {
299  READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false );
300  READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false );
302  {
303  READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode );
304  READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode );
305  }
306  }
307  READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false );
308  if(pcPPS->getScalingListPresentFlag ())
309  {
310  parseScalingList( &(pcPPS->getScalingList()) );
311  }
312 
313  READ_FLAG( uiCode, "lists_modification_present_flag");
314  pcPPS->setListsModificationPresentFlag(uiCode);
315 
316  READ_UVLC( uiCode, "log2_parallel_merge_level_minus2");
317  pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode);
318 
319  READ_FLAG( uiCode, "slice_segment_header_extension_present_flag");
320  pcPPS->setSliceHeaderExtensionPresentFlag(uiCode);
321 
322  READ_FLAG( uiCode, "pps_extension_present_flag");
323  if (uiCode)
324  {
325 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
326  static const char *syntaxStrings[]={ "pps_range_extension_flag",
327  "pps_multilayer_extension_flag",
328  "pps_extension_6bits[0]",
329  "pps_extension_6bits[1]",
330  "pps_extension_6bits[2]",
331  "pps_extension_6bits[3]",
332  "pps_extension_6bits[4]",
333  "pps_extension_6bits[5]" };
334 #endif
335 
336  Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS];
337  for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++)
338  {
339  READ_FLAG( uiCode, syntaxStrings[i] );
340  pps_extension_flags[i] = uiCode!=0;
341  }
342 
343  Bool bSkipTrailingExtensionBits=false;
344  for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
345  {
346  if (pps_extension_flags[i])
347  {
348  switch (PPSExtensionFlagIndex(i))
349  {
350  case PPS_EXT__REXT:
351  assert(!bSkipTrailingExtensionBits);
352 
353  if (pcPPS->getUseTransformSkip())
354  {
355  READ_UVLC( uiCode, "log2_max_transform_skip_block_size_minus2");
356  pcPPS->setTransformSkipLog2MaxSize(uiCode+2);
357  }
358 
359  READ_FLAG( uiCode, "cross_component_prediction_enabled_flag");
360  pcPPS->setUseCrossComponentPrediction(uiCode != 0);
361 
362  READ_FLAG( uiCode, "chroma_qp_offset_list_enabled_flag");
363  if (uiCode == 0)
364  {
365  pcPPS->clearChromaQpAdjTable();
366  pcPPS->setMaxCuChromaQpAdjDepth(0);
367  }
368  else
369  {
370  READ_UVLC(uiCode, "diff_cu_chroma_qp_offset_depth"); pcPPS->setMaxCuChromaQpAdjDepth(uiCode);
371  UInt tableSizeMinus1 = 0;
372  READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1");
373  assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE);
374 
375  for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++)
376  {
377  Int cbOffset;
378  Int crOffset;
379  READ_SVLC(cbOffset, "cb_qp_offset_list[i]");
380  assert(cbOffset >= -12 && cbOffset <= 12);
381  READ_SVLC(crOffset, "cr_qp_offset_list[i]");
382  assert(crOffset >= -12 && crOffset <= 12);
383  // table uses +1 for index (see comment inside the function)
384  pcPPS->setChromaQpAdjTableAt(cuChromaQpOffsetIdx+1, cbOffset, crOffset);
385  }
386  assert(pcPPS->getChromaQpAdjTableSize() == tableSizeMinus1 + 1);
387  }
388 
389  READ_UVLC( uiCode, "log2_sao_offset_scale_luma");
390  pcPPS->setSaoOffsetBitShift(CHANNEL_TYPE_LUMA, uiCode);
391  READ_UVLC( uiCode, "log2_sao_offset_scale_chroma");
393  break;
394  default:
395  bSkipTrailingExtensionBits=true;
396  break;
397  }
398  }
399  }
400  if (bSkipTrailingExtensionBits)
401  {
402  while ( xMoreRbspData() )
403  {
404  READ_FLAG( uiCode, "pps_extension_data_flag");
405  }
406  }
407  }
408 }
409 
411 {
412 #if ENC_DEC_TRACE
413  fprintf( g_hTrace, "----------- vui_parameters -----------\n");
414 #endif
415  UInt uiCode;
416 
417  READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode);
418  if (pcVUI->getAspectRatioInfoPresentFlag())
419  {
420  READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode);
421  if (pcVUI->getAspectRatioIdc() == 255)
422  {
423  READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode);
424  READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode);
425  }
426  }
427 
428  READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode);
429  if (pcVUI->getOverscanInfoPresentFlag())
430  {
431  READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode);
432  }
433 
434  READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode);
435  if (pcVUI->getVideoSignalTypePresentFlag())
436  {
437  READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode);
438  READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode);
439  READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode);
440  if (pcVUI->getColourDescriptionPresentFlag())
441  {
442  READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode);
443  READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode);
444  READ_CODE(8, uiCode, "matrix_coeffs"); pcVUI->setMatrixCoefficients(uiCode);
445  }
446  }
447 
448  READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode);
449  if (pcVUI->getChromaLocInfoPresentFlag())
450  {
451  READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode);
452  READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode);
453  }
454 
455  READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode);
456 
457  READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode);
458 
459  READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode);
460 
461  READ_FLAG( uiCode, "default_display_window_flag");
462  if (uiCode != 0)
463  {
464  Window &defDisp = pcVUI->getDefaultDisplayWindow();
465  READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) );
466  READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) );
467  READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
468  READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
469  }
470 
471  TimingInfo *timingInfo = pcVUI->getTimingInfo();
472  READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false);
473  if(timingInfo->getTimingInfoPresentFlag())
474  {
475  READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode);
476  READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode);
477  READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false);
478  if(timingInfo->getPocProportionalToTimingFlag())
479  {
480  READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode);
481  }
482 
483  READ_FLAG( uiCode, "vui_hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode);
484  if( pcVUI->getHrdParametersPresentFlag() )
485  {
486  parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
487  }
488  }
489 
490  READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode);
491  if (pcVUI->getBitstreamRestrictionFlag())
492  {
493  READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode);
494  READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode);
495  READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode);
496  READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode);
497  assert(uiCode < 4096);
498  READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode);
499  READ_UVLC( uiCode, "max_bits_per_min_cu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode);
500  READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode);
501  READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode);
502  }
503 }
504 
505 Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1)
506 {
507  UInt uiCode;
508  if( commonInfPresentFlag )
509  {
510  READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false );
511  READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false );
513  {
514  READ_FLAG( uiCode, "sub_pic_hrd_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false );
515  if( hrd->getSubPicCpbParamsPresentFlag() )
516  {
517  READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode );
518  READ_CODE( 5, uiCode, "du_cpb_removal_delay_increment_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode );
519  READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false );
520  READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode );
521  }
522  READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode );
523  READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode );
524  if( hrd->getSubPicCpbParamsPresentFlag() )
525  {
526  READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode );
527  }
528  READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode );
529  READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode );
530  READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode );
531  }
532  }
533  Int i, j, nalOrVcl;
534  for( i = 0; i <= maxNumSubLayersMinus1; i ++ )
535  {
536  READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false );
537  if( !hrd->getFixedPicRateFlag( i ) )
538  {
539  READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false );
540  }
541  else
542  {
543  hrd->setFixedPicRateWithinCvsFlag( i, true );
544  }
545 
546  hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present
547  hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present
548 
549  if( hrd->getFixedPicRateWithinCvsFlag( i ) )
550  {
551  READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode );
552  }
553  else
554  {
555  READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false );
556  }
557  if (!hrd->getLowDelayHrdFlag( i ))
558  {
559  READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode );
560  }
561 
562  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
563  {
564  if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
565  ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
566  {
567  for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
568  {
569  READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode );
570  READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
571  if( hrd->getSubPicCpbParamsPresentFlag() )
572  {
573  READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
574  READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode );
575  }
576  READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false );
577  }
578  }
579  }
580  }
581 }
582 
584 {
585 #if ENC_DEC_TRACE
586  xTraceSPSHeader (pcSPS);
587 #endif
588 
589  UInt uiCode;
590  READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode );
591  READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 );
592  assert(uiCode <= 6);
593 
594  READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
595  if ( pcSPS->getMaxTLayers() == 1 )
596  {
597  // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0
598  assert( uiCode == 1 );
599  }
600 
601  parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
602  READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode );
603  assert(uiCode <= 15);
604 
605  READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) );
606  assert(uiCode <= 3);
607 
608  if( pcSPS->getChromaFormatIdc() == CHROMA_444 )
609  {
610  READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0);
611  }
612 
613  READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode );
614  READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode );
615  READ_FLAG( uiCode, "conformance_window_flag");
616  if (uiCode != 0)
617  {
618  Window &conf = pcSPS->getConformanceWindow();
619  READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
620  READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
621  READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
622  READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
623  }
624 
625  READ_UVLC( uiCode, "bit_depth_luma_minus8" );
626 #if O0043_BEST_EFFORT_DECODING
627  const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth();
628  g_bitDepthInStream[CHANNEL_TYPE_LUMA] = 8 + uiCode;
629  if (forceDecodeBitDepth != 0)
630  {
631  uiCode = forceDecodeBitDepth - 8;
632  }
633 #endif
634  assert(uiCode <= 8);
635 
636  pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode);
637 #if O0043_BEST_EFFORT_DECODING
638  pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_LUMA]-8)) );
639 #else
640  pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) );
641 #endif
642 
643  READ_UVLC( uiCode, "bit_depth_chroma_minus8" );
644 #if O0043_BEST_EFFORT_DECODING
645  g_bitDepthInStream[CHANNEL_TYPE_CHROMA] = 8 + uiCode;
646  if (forceDecodeBitDepth != 0)
647  {
648  uiCode = forceDecodeBitDepth - 8;
649  }
650 #endif
651  assert(uiCode <= 8);
652  pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode);
653 #if O0043_BEST_EFFORT_DECODING
654  pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_CHROMA]-8)) );
655 #else
656  pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) );
657 #endif
658 
659  READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode );
660  assert(uiCode <= 12);
661 
662  UInt subLayerOrderingInfoPresentFlag;
663  READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
664 
665  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
666  {
667  READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");
668  pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
669  READ_UVLC ( uiCode, "sps_max_num_reorder_pics[i]" );
670  pcSPS->setNumReorderPics(uiCode, i);
671  READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
672  pcSPS->setMaxLatencyIncrease( uiCode, i );
673 
674  if (!subLayerOrderingInfoPresentFlag)
675  {
676  for (i++; i <= pcSPS->getMaxTLayers()-1; i++)
677  {
678  pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i);
679  pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i);
680  pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i);
681  }
682  break;
683  }
684  }
685 
686  READ_UVLC( uiCode, "log2_min_luma_coding_block_size_minus3" );
687  Int log2MinCUSize = uiCode + 3;
688  pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
689  READ_UVLC( uiCode, "log2_diff_max_min_luma_coding_block_size" );
690  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
691 
692  if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5)
693  {
694  assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5);
695  }
696 
697  Int maxCUDepthDelta = uiCode;
698  pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) );
699  pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) );
700  READ_UVLC( uiCode, "log2_min_luma_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 );
701 
702  READ_UVLC( uiCode, "log2_diff_max_min_luma_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() );
703  pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) );
704 
705  READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 );
706  READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 );
707 
708  Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() );
709  pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) );
710 
711  READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode );
712  if(pcSPS->getScalingListFlag())
713  {
714  READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode );
715  if(pcSPS->getScalingListPresentFlag ())
716  {
717  parseScalingList( &(pcSPS->getScalingList()) );
718  }
719  }
720  READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode );
721  READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false );
722 
723  READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false );
724  if( pcSPS->getUsePCM() )
725  {
726  READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode );
727  READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode );
728  READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3);
729  READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() );
730  READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false );
731  }
732 
733  READ_UVLC( uiCode, "num_short_term_ref_pic_sets" );
734  assert(uiCode <= 64);
735  pcSPS->createRPSList(uiCode);
736 
737  TComRPSList* rpsList = pcSPS->getRPSList();
739 
740  for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++)
741  {
742  rps = rpsList->getReferencePictureSet(i);
743  parseShortTermRefPicSet(pcSPS,rps,i);
744  }
745  READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode);
746  if (pcSPS->getLongTermRefsPresent())
747  {
748  READ_UVLC( uiCode, "num_long_term_ref_pics_sps" );
749  pcSPS->setNumLongTermRefPicSPS(uiCode);
750  for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++)
751  {
752  READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" );
753  pcSPS->setLtRefPicPocLsbSps(k, uiCode);
754  READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]");
755  pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0);
756  }
757  }
758  READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode);
759 
760  READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode);
761 
762  READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode);
763 
764  if (pcSPS->getVuiParametersPresentFlag())
765  {
766  parseVUI(pcSPS->getVuiParameters(), pcSPS);
767  }
768 
769  READ_FLAG( uiCode, "sps_extension_present_flag");
770  if (uiCode)
771  {
772 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
773  static const char *syntaxStrings[]={ "sps_range_extension_flag",
774  "sps_multilayer_extension_flag",
775  "sps_extension_6bits[0]",
776  "sps_extension_6bits[1]",
777  "sps_extension_6bits[2]",
778  "sps_extension_6bits[3]",
779  "sps_extension_6bits[4]",
780  "sps_extension_6bits[5]" };
781 #endif
782  Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS];
783 
784  for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
785  {
786  READ_FLAG( uiCode, syntaxStrings[i] );
787  sps_extension_flags[i] = uiCode!=0;
788  }
789 
790  Bool bSkipTrailingExtensionBits=false;
791  for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
792  {
793  if (sps_extension_flags[i])
794  {
795  switch (SPSExtensionFlagIndex(i))
796  {
797  case SPS_EXT__REXT:
798  assert(!bSkipTrailingExtensionBits);
799 
800  READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); pcSPS->setUseResidualRotation (uiCode != 0);
801  READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); pcSPS->setUseSingleSignificanceMapContext (uiCode != 0);
802  READ_FLAG( uiCode, "implicit_rdpcm_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0));
803  READ_FLAG( uiCode, "explicit_rdpcm_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0));
804  READ_FLAG( uiCode, "extended_precision_processing_flag"); pcSPS->setUseExtendedPrecision (uiCode != 0);
805  READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); pcSPS->setDisableIntraReferenceSmoothing (uiCode != 0);
806  READ_FLAG( uiCode, "high_precision_offsets_enabled_flag"); pcSPS->setUseHighPrecisionPredictionWeighting (uiCode != 0);
807  READ_FLAG( uiCode, "persistent_rice_adaptation_enabled_flag"); pcSPS->setUseGolombRiceParameterAdaptation (uiCode != 0);
808  READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); pcSPS->setAlignCABACBeforeBypass (uiCode != 0);
809  break;
810  default:
811  bSkipTrailingExtensionBits=true;
812  break;
813  }
814  }
815  }
816  if (bSkipTrailingExtensionBits)
817  {
818  while ( xMoreRbspData() )
819  {
820  READ_FLAG( uiCode, "sps_extension_data_flag");
821  }
822  }
823  }
824 }
825 
827 {
828  UInt uiCode;
829 
830  READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode );
831  READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); assert(uiCode == 1);
832  READ_FLAG( uiCode, "vps_base_layer_available_flag" ); assert(uiCode == 1);
833  READ_CODE( 6, uiCode, "vps_max_layers_minus1" );
834  READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER);
835  READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false );
836  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
837  READ_CODE( 16, uiCode, "vps_reserved_0xffff_16bits" ); assert(uiCode == 0xffff);
838  parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1);
839  UInt subLayerOrderingInfoPresentFlag;
840  READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag");
841  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
842  {
843  READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
844  READ_UVLC( uiCode, "vps_max_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i );
845  READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i );
846 
847  if (!subLayerOrderingInfoPresentFlag)
848  {
849  for (i++; i <= pcVPS->getMaxTLayers()-1; i++)
850  {
851  pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i);
852  pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i);
853  pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i);
854  }
855  break;
856  }
857  }
858 
859  assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 );
861  READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode );
862  READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 );
863  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ )
864  {
865  // Operation point set
866  for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
867  {
868  READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i );
869  }
870  }
871 
872  TimingInfo *timingInfo = pcVPS->getTimingInfo();
873  READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false);
874  if(timingInfo->getTimingInfoPresentFlag())
875  {
876  READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode);
877  READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode);
878  READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false);
879  if(timingInfo->getPocProportionalToTimingFlag())
880  {
881  READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode);
882  }
883 
884  READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode );
885 
886  if( pcVPS->getNumHrdParameters() > 0 )
887  {
888  pcVPS->createHrdParamBuffer();
889  }
890  for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ )
891  {
892  READ_UVLC( uiCode, "hrd_layer_set_idx[i]" ); pcVPS->setHrdOpSetIdx( uiCode, i );
893  if( i > 0 )
894  {
895  READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i );
896  }
897  else
898  {
899  pcVPS->setCprmsPresentFlag( true, i );
900  }
901 
902  parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
903  }
904  }
905 
906  READ_FLAG( uiCode, "vps_extension_flag" );
907  if (uiCode)
908  {
909  while ( xMoreRbspData() )
910  {
911  READ_FLAG( uiCode, "vps_extension_data_flag");
912  }
913  }
914 
915  return;
916 }
917 
919 {
920  UInt uiCode;
921  Int iCode;
922 
923 #if ENC_DEC_TRACE
924  xTraceSliceHeader(pcSlice);
925 #endif
926  TComPPS* pps = NULL;
927  TComSPS* sps = NULL;
928 
929  UInt firstSliceSegmentInPic;
930  READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" );
931  if( pcSlice->getRapPicFlag())
932  {
933  READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already
934  pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false);
935  }
936  READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode);
937  pps = parameterSetManager->getPPS(uiCode);
939  assert(pps!=0);
940  sps = parameterSetManager->getSPS(pps->getSPSId());
942  assert(sps!=0);
943 
944  const ChromaFormat chFmt = sps->getChromaFormatIdc();
945  const UInt numValidComp=getNumberValidComponents(chFmt);
946  const Bool bChroma=(chFmt!=CHROMA_400);
947 
948  if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic ))
949  {
950  READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false);
951  }
952  else
953  {
954  pcSlice->setDependentSliceSegmentFlag(false);
955  }
956  Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight());
957  UInt sliceSegmentAddress = 0;
958  Int bitsSliceSegmentAddress = 0;
959  while(numCTUs>(1<<bitsSliceSegmentAddress))
960  {
961  bitsSliceSegmentAddress++;
962  }
963 
964  if(!firstSliceSegmentInPic)
965  {
966  READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" );
967  }
968  //set uiCode to equal slice start address (or dependent slice start address)
969  pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet.
970  pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture.
971 
972  if (!pcSlice->getDependentSliceSegmentFlag())
973  {
974  pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet.
975  pcSlice->setSliceCurEndCtuTsAddr(numCTUs);
976  }
977 
978  if(!pcSlice->getDependentSliceSegmentFlag())
979  {
980  for (Int i = 0; i < pps->getNumExtraSliceHeaderBits(); i++)
981  {
982  READ_FLAG(uiCode, "slice_reserved_flag[]"); // ignored
983  }
984 
985  READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode);
986  if( pps->getOutputFlagPresentFlag() )
987  {
988  READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false );
989  }
990  else
991  {
992  pcSlice->setPicOutputFlag( true );
993  }
994 
995  // if (separate_colour_plane_flag == 1)
996  // read colour_plane_id
997  // (separate_colour_plane_flag == 1) is not supported in this version of the standard.
998 
999  if( pcSlice->getIdrPicFlag() )
1000  {
1001  pcSlice->setPOC(0);
1002  TComReferencePictureSet* rps = pcSlice->getLocalRPS();
1006  rps->setNumberOfPictures(0);
1007  pcSlice->setRPS(rps);
1008  }
1009  else
1010  {
1011  READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb");
1012  Int iPOClsb = uiCode;
1013  Int iPrevPOC = pcSlice->getPrevTid0POC();
1014  Int iMaxPOClsb = 1<< sps->getBitsForPOC();
1015  Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1);
1016  Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb;
1017  Int iPOCmsb;
1018  if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) )
1019  {
1020  iPOCmsb = iPrevPOCmsb + iMaxPOClsb;
1021  }
1022  else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) )
1023  {
1024  iPOCmsb = iPrevPOCmsb - iMaxPOClsb;
1025  }
1026  else
1027  {
1028  iPOCmsb = iPrevPOCmsb;
1029  }
1033  {
1034  // For BLA picture types, POCmsb is set to 0.
1035  iPOCmsb = 0;
1036  }
1037  pcSlice->setPOC (iPOCmsb+iPOClsb);
1038 
1040  rps = pcSlice->getLocalRPS();
1041  pcSlice->setRPS(rps);
1042  READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
1043  if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
1044  {
1046  }
1047  else // use reference to short-term reference picture set in PPS
1048  {
1049  Int numBits = 0;
1050  while ((1 << numBits) < sps->getRPSList()->getNumberOfReferencePictureSets())
1051  {
1052  numBits++;
1053  }
1054  if (numBits > 0)
1055  {
1056  READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx");
1057  }
1058  else
1059  {
1060  uiCode = 0;
1061 
1062  }
1063  *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
1064  }
1065  if(sps->getLongTermRefsPresent())
1066  {
1068  UInt numOfLtrp = 0;
1069  UInt numLtrpInSPS = 0;
1070  if (sps->getNumLongTermRefPicSPS() > 0)
1071  {
1072  READ_UVLC( uiCode, "num_long_term_sps");
1073  numLtrpInSPS = uiCode;
1074  numOfLtrp += numLtrpInSPS;
1075  rps->setNumberOfLongtermPictures(numOfLtrp);
1076  }
1077  Int bitsForLtrpInSPS = 0;
1078  while (sps->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
1079  {
1080  bitsForLtrpInSPS++;
1081  }
1082  READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode);
1083  numOfLtrp += uiCode;
1084  rps->setNumberOfLongtermPictures(numOfLtrp);
1085  Int maxPicOrderCntLSB = 1 << sps->getBitsForPOC();
1086  Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;
1087  for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
1088  {
1089  Int pocLsbLt;
1090  if (k < numLtrpInSPS)
1091  {
1092  uiCode = 0;
1093  if (bitsForLtrpInSPS > 0)
1094  {
1095  READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]");
1096  }
1097  Bool usedByCurrFromSPS=sps->getUsedByCurrPicLtSPSFlag(uiCode);
1098 
1099  pocLsbLt = sps->getLtRefPicPocLsbSps(uiCode);
1100  rps->setUsed(j,usedByCurrFromSPS);
1101  }
1102  else
1103  {
1104  READ_CODE(sps->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode;
1105  READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode);
1106  }
1107  READ_FLAG(uiCode,"delta_poc_msb_present_flag");
1108  Bool mSBPresentFlag = uiCode ? true : false;
1109  if(mSBPresentFlag)
1110  {
1111  READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
1112  Bool deltaFlag = false;
1113  // First LTRP || First LTRP from SH
1114  if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
1115  {
1116  deltaFlag = true;
1117  }
1118  if(deltaFlag)
1119  {
1120  deltaPocMSBCycleLT = uiCode;
1121  }
1122  else
1123  {
1124  deltaPocMSBCycleLT = uiCode + prevDeltaMSB;
1125  }
1126 
1127  Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB
1128  - iPOClsb + pocLsbLt;
1129  rps->setPOC (j, pocLTCurr);
1130  rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr);
1131  rps->setCheckLTMSBPresent(j,true);
1132  }
1133  else
1134  {
1135  rps->setPOC (j, pocLsbLt);
1136  rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt);
1137  rps->setCheckLTMSBPresent(j,false);
1138 
1139  // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
1140  if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
1141  {
1142  deltaPocMSBCycleLT = 0;
1143  }
1144  }
1145  prevDeltaMSB = deltaPocMSBCycleLT;
1146  }
1147  offset += rps->getNumberOfLongtermPictures();
1148  rps->setNumberOfPictures(offset);
1149  }
1153  {
1154  // In the case of BLA picture types, rps data is read from slice header but ignored
1155  rps = pcSlice->getLocalRPS();
1159  rps->setNumberOfPictures(0);
1160  pcSlice->setRPS(rps);
1161  }
1162  if (sps->getTMVPFlagsPresent())
1163  {
1164  READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" );
1165  pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );
1166  }
1167  else
1168  {
1169  pcSlice->setEnableTMVPFlag(false);
1170  }
1171  }
1172  if(sps->getUseSAO())
1173  {
1174  READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (Bool)uiCode);
1175 
1176  if (bChroma)
1177  {
1178  READ_FLAG(uiCode, "slice_sao_chroma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (Bool)uiCode);
1179  }
1180  }
1181 
1182  if (pcSlice->getIdrPicFlag())
1183  {
1184  pcSlice->setEnableTMVPFlag(false);
1185  }
1186  if (!pcSlice->isIntra())
1187  {
1188 
1189  READ_FLAG( uiCode, "num_ref_idx_active_override_flag");
1190  if (uiCode)
1191  {
1192  READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 );
1193  if (pcSlice->isInterB())
1194  {
1195  READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 );
1196  }
1197  else
1198  {
1199  pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
1200  }
1201  }
1202  else
1203  {
1205  if (pcSlice->isInterB())
1206  {
1208  }
1209  else
1210  {
1211  pcSlice->setNumRefIdx(REF_PIC_LIST_1,0);
1212  }
1213  }
1214  }
1215  // }
1216  TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
1217  if(!pcSlice->isIntra())
1218  {
1219  if( !pps->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 )
1220  {
1221  refPicListModification->setRefPicListModificationFlagL0( 0 );
1222  }
1223  else
1224  {
1225  READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 );
1226  }
1227 
1228  if(refPicListModification->getRefPicListModificationFlagL0())
1229  {
1230  uiCode = 0;
1231  Int i = 0;
1232  Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList();
1233  if ( numRpsCurrTempList0 > 1 )
1234  {
1235  Int length = 1;
1236  numRpsCurrTempList0 --;
1237  while ( numRpsCurrTempList0 >>= 1)
1238  {
1239  length ++;
1240  }
1241  for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++)
1242  {
1243  READ_CODE( length, uiCode, "list_entry_l0" );
1244  refPicListModification->setRefPicSetIdxL0(i, uiCode );
1245  }
1246  }
1247  else
1248  {
1249  for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++)
1250  {
1251  refPicListModification->setRefPicSetIdxL0(i, 0 );
1252  }
1253  }
1254  }
1255  }
1256  else
1257  {
1258  refPicListModification->setRefPicListModificationFlagL0(0);
1259  }
1260  if(pcSlice->isInterB())
1261  {
1262  if( !pps->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 )
1263  {
1264  refPicListModification->setRefPicListModificationFlagL1( 0 );
1265  }
1266  else
1267  {
1268  READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 );
1269  }
1270  if(refPicListModification->getRefPicListModificationFlagL1())
1271  {
1272  uiCode = 0;
1273  Int i = 0;
1274  Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList();
1275  if ( numRpsCurrTempList1 > 1 )
1276  {
1277  Int length = 1;
1278  numRpsCurrTempList1 --;
1279  while ( numRpsCurrTempList1 >>= 1)
1280  {
1281  length ++;
1282  }
1283  for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++)
1284  {
1285  READ_CODE( length, uiCode, "list_entry_l1" );
1286  refPicListModification->setRefPicSetIdxL1(i, uiCode );
1287  }
1288  }
1289  else
1290  {
1291  for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++)
1292  {
1293  refPicListModification->setRefPicSetIdxL1(i, 0 );
1294  }
1295  }
1296  }
1297  }
1298  else
1299  {
1300  refPicListModification->setRefPicListModificationFlagL1(0);
1301  }
1302  if (pcSlice->isInterB())
1303  {
1304  READ_FLAG( uiCode, "mvd_l1_zero_flag" ); pcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) );
1305  }
1306 
1307  pcSlice->setCabacInitFlag( false ); // default
1308  if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra())
1309  {
1310  READ_FLAG(uiCode, "cabac_init_flag");
1311  pcSlice->setCabacInitFlag( uiCode ? true : false );
1312  }
1313 
1314  if ( pcSlice->getEnableTMVPFlag() )
1315  {
1316  if ( pcSlice->getSliceType() == B_SLICE )
1317  {
1318  READ_FLAG( uiCode, "collocated_from_l0_flag" );
1319  pcSlice->setColFromL0Flag(uiCode);
1320  }
1321  else
1322  {
1323  pcSlice->setColFromL0Flag( 1 );
1324  }
1325 
1326  if ( pcSlice->getSliceType() != I_SLICE &&
1327  ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)||
1328  (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1)))
1329  {
1330  READ_UVLC( uiCode, "collocated_ref_idx" );
1331  pcSlice->setColRefIdx(uiCode);
1332  }
1333  else
1334  {
1335  pcSlice->setColRefIdx(0);
1336  }
1337  }
1338  if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) )
1339  {
1340  xParsePredWeightTable(pcSlice, sps);
1341  pcSlice->initWpScaling(sps);
1342  }
1343  if (!pcSlice->isIntra())
1344  {
1345  READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
1346  pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
1347  }
1348 
1349  READ_SVLC( iCode, "slice_qp_delta" );
1350  pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode);
1351 
1352  assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) );
1353  assert( pcSlice->getSliceQp() <= 51 );
1354 
1355  if (pps->getSliceChromaQpFlag())
1356  {
1357  if (numValidComp>COMPONENT_Cb)
1358  {
1359  READ_SVLC( iCode, "slice_cb_qp_offset" );
1360  pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode );
1361  assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >= -12 );
1362  assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) <= 12 );
1363  assert( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >= -12 );
1364  assert( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) <= 12 );
1365  }
1366 
1367  if (numValidComp>COMPONENT_Cr)
1368  {
1369  READ_SVLC( iCode, "slice_cr_qp_offset" );
1370  pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode );
1371  assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >= -12 );
1372  assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) <= 12 );
1373  assert( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >= -12 );
1374  assert( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) <= 12 );
1375  }
1376  }
1377 
1378  if (pps->getChromaQpAdjTableSize() > 0)
1379  {
1380  READ_FLAG(uiCode, "cu_chroma_qp_offset_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0);
1381  }
1382  else
1383  {
1384  pcSlice->setUseChromaQpAdj(false);
1385  }
1386 
1388  {
1390  {
1391  READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false);
1392  }
1393  else
1394  {
1395  pcSlice->setDeblockingFilterOverrideFlag(0);
1396  }
1397  if(pcSlice->getDeblockingFilterOverrideFlag())
1398  {
1399  READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0);
1400  if(!pcSlice->getDeblockingFilterDisable())
1401  {
1402  READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
1403  assert(pcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 &&
1404  pcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6);
1405  READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
1406  assert(pcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 &&
1407  pcSlice->getDeblockingFilterTcOffsetDiv2() <= 6);
1408  }
1409  }
1410  else
1411  {
1415  }
1416  }
1417  else
1418  {
1419  pcSlice->setDeblockingFilterDisable ( false );
1420  pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
1421  pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 );
1422  }
1423 
1424  Bool isSAOEnabled = sps->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (bChroma && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA)));
1425  Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable());
1426 
1427  if(pps->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
1428  {
1429  READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag");
1430  }
1431  else
1432  {
1433  uiCode = pps->getLoopFilterAcrossSlicesEnabledFlag()?1:0;
1434  }
1435  pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false);
1436 
1437  }
1438 
1439  std::vector<UInt> entryPointOffset;
1441  {
1442  UInt numEntryPointOffsets;
1443  UInt offsetLenMinus1;
1444  READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets");
1445  if (numEntryPointOffsets>0)
1446  {
1447  READ_UVLC(offsetLenMinus1, "offset_len_minus1");
1448  entryPointOffset.resize(numEntryPointOffsets);
1449  for (UInt idx=0; idx<numEntryPointOffsets; idx++)
1450  {
1451  READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1");
1452  entryPointOffset[ idx ] = uiCode + 1;
1453  }
1454  }
1455  }
1456 
1458  {
1459  READ_UVLC(uiCode,"slice_segment_header_extension_length");
1460  for(Int i=0; i<uiCode; i++)
1461  {
1462  UInt ignore;
1463  READ_CODE(8,ignore,"slice_segment_header_extension_data_byte");
1464  }
1465  }
1466 #if RExt__DECODER_DEBUG_BIT_STATISTICS
1468 #else
1470 #endif
1471 
1472  pcSlice->clearSubstreamSizes();
1473 
1475  {
1476  Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
1477 
1478  // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header
1479  for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
1480  {
1481  if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation )
1482  {
1483  endOfSliceHeaderLocation++;
1484  }
1485  }
1486 
1487  Int curEntryPointOffset = 0;
1488  Int prevEntryPointOffset = 0;
1489  for (UInt idx=0; idx<entryPointOffset.size(); idx++)
1490  {
1491  curEntryPointOffset += entryPointOffset[ idx ];
1492 
1493  Int emulationPreventionByteCount = 0;
1494  for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
1495  {
1496  if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
1497  m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) )
1498  {
1499  emulationPreventionByteCount++;
1500  }
1501  }
1502 
1503  entryPointOffset[ idx ] -= emulationPreventionByteCount;
1504  prevEntryPointOffset = curEntryPointOffset;
1505  pcSlice->addSubstreamSize(entryPointOffset [ idx ] );
1506  }
1507  }
1508 
1509  return;
1510 }
1511 
1512 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 )
1513 {
1514  UInt uiCode;
1515  if(profilePresentFlag)
1516  {
1517  parseProfileTier(rpcPTL->getGeneralPTL(), false);
1518  }
1519  READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(Level::Name(uiCode));
1520 
1521  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
1522  {
1523  READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode);
1524  READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode);
1525  }
1526 
1527  if (maxNumSubLayersMinus1 > 0)
1528  {
1529  for (Int i = maxNumSubLayersMinus1; i < 8; i++)
1530  {
1531  READ_CODE(2, uiCode, "reserved_zero_2bits");
1532  assert(uiCode == 0);
1533  }
1534  }
1535 
1536  for(Int i = 0; i < maxNumSubLayersMinus1; i++)
1537  {
1538  if( rpcPTL->getSubLayerProfilePresentFlag(i) )
1539  {
1540  parseProfileTier(rpcPTL->getSubLayerPTL(i), true);
1541  }
1542  if(rpcPTL->getSubLayerLevelPresentFlag(i))
1543  {
1544  READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(Level::Name(uiCode));
1545  }
1546  }
1547 }
1548 
1549 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
1551 #define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt)
1552 #else
1553 Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl, const Bool /*bIsSubLayer*/)
1554 #define PTL_TRACE_TEXT(txt) txt
1555 #endif
1556 {
1557  UInt uiCode;
1558  READ_CODE(2 , uiCode, PTL_TRACE_TEXT("profile_space" )); ptl->setProfileSpace(uiCode);
1559  READ_FLAG( uiCode, PTL_TRACE_TEXT("tier_flag" )); ptl->setTierFlag (uiCode ? Level::HIGH : Level::MAIN);
1560  READ_CODE(5 , uiCode, PTL_TRACE_TEXT("profile_idc" )); ptl->setProfileIdc (Profile::Name(uiCode));
1561  for(Int j = 0; j < 32; j++)
1562  {
1563  READ_FLAG( uiCode, PTL_TRACE_TEXT("profile_compatibility_flag[][j]" )); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0);
1564  }
1565  READ_FLAG(uiCode, PTL_TRACE_TEXT("progressive_source_flag" )); ptl->setProgressiveSourceFlag(uiCode ? true : false);
1566 
1567  READ_FLAG(uiCode, PTL_TRACE_TEXT("interlaced_source_flag" )); ptl->setInterlacedSourceFlag(uiCode ? true : false);
1568 
1569  READ_FLAG(uiCode, PTL_TRACE_TEXT("non_packed_constraint_flag" )); ptl->setNonPackedConstraintFlag(uiCode ? true : false);
1570 
1571  READ_FLAG(uiCode, PTL_TRACE_TEXT("frame_only_constraint_flag" )); ptl->setFrameOnlyConstraintFlag(uiCode ? true : false);
1572 
1575  {
1576  UInt maxBitDepth=16;
1577  READ_FLAG( uiCode, PTL_TRACE_TEXT("max_12bit_constraint_flag" )); if (uiCode) maxBitDepth=12;
1578  READ_FLAG( uiCode, PTL_TRACE_TEXT("max_10bit_constraint_flag" )); if (uiCode) maxBitDepth=10;
1579  READ_FLAG( uiCode, PTL_TRACE_TEXT("max_8bit_constraint_flag" )); if (uiCode) maxBitDepth=8;
1580  ptl->setBitDepthConstraint(maxBitDepth);
1581  ChromaFormat chromaFmtConstraint=CHROMA_444;
1582  READ_FLAG( uiCode, PTL_TRACE_TEXT("max_422chroma_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_422;
1583  READ_FLAG( uiCode, PTL_TRACE_TEXT("max_420chroma_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_420;
1584  READ_FLAG( uiCode, PTL_TRACE_TEXT("max_monochrome_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_400;
1585  ptl->setChromaFormatConstraint(chromaFmtConstraint);
1586  READ_FLAG( uiCode, PTL_TRACE_TEXT("intra_constraint_flag" )); ptl->setIntraConstraintFlag(uiCode != 0);
1587  READ_FLAG( uiCode, PTL_TRACE_TEXT("one_picture_only_constraint_flag"));
1588  READ_FLAG( uiCode, PTL_TRACE_TEXT("lower_bit_rate_constraint_flag" )); ptl->setLowerBitRateConstraintFlag(uiCode != 0);
1589  READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]" ));
1590  READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]" ));
1591  READ_CODE(2, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]" ));
1592  }
1593  else
1594  {
1595  ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8);
1597  ptl->setIntraConstraintFlag(false);
1598  ptl->setLowerBitRateConstraintFlag(true);
1599  READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]" ));
1600  READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]" ));
1601  READ_CODE(11, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]" ));
1602  }
1603 
1610  {
1611  READ_FLAG( uiCode, PTL_TRACE_TEXT("inbld_flag" )); assert(uiCode == 0);
1612  }
1613  else
1614  {
1615  READ_FLAG( uiCode, PTL_TRACE_TEXT("reserved_zero_bit" ));
1616  }
1617 #undef PTL_TRACE_TEXT
1618 }
1619 
1621 {
1622  ruiBit = false;
1623  Int iBitsLeft = m_pcBitstream->getNumBitsLeft();
1624  if(iBitsLeft <= 8)
1625  {
1626  UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft);
1627  if (uiPeekValue == (1<<(iBitsLeft-1)))
1628  {
1629  ruiBit = true;
1630  }
1631  }
1632 }
1633 
1634 Void TDecCavlc::parseRemainingBytes( Bool noTrailingBytesExpected )
1635 {
1636  if (noTrailingBytesExpected)
1637  {
1638  const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft();
1639  assert (numberOfRemainingSubstreamBytes == 0);
1640  }
1641  else
1642  {
1643  while (m_pcBitstream->getNumBitsLeft())
1644  {
1645  UInt trailingNullByte=m_pcBitstream->readByte();
1646  if (trailingNullByte!=0)
1647  {
1648  printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte);
1649  assert(trailingNullByte==0);
1650  }
1651  }
1652  }
1653 }
1654 
1655 Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1656 {
1657  assert(0);
1658 }
1659 
1660 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1661 {
1662  assert(0);
1663 }
1664 
1666 {
1667  assert(0);
1668 }
1669 
1670 Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1671 {
1672  assert(0);
1673 }
1674 
1675 Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1676 {
1677  assert(0);
1678 }
1679 
1680 Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1681 {
1682  assert(0);
1683 }
1684 
1693 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1694 {
1695  assert(0);
1696 }
1697 
1698 Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1699 {
1700  assert(0);
1701 }
1702 
1703 Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1704 {
1705  assert(0);
1706 }
1707 
1708 Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ )
1709 {
1710  assert(0);
1711 }
1712 
1713 Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ )
1714 {
1715  assert(0);
1716 }
1717 
1718 Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ )
1719 {
1720  assert(0);
1721 }
1722 
1724 {
1725  assert(0);
1726 }
1727 
1728 Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
1729 {
1730  Int qp;
1731  Int iDQp;
1732 
1733 #if RExt__DECODER_DEBUG_BIT_STATISTICS
1734  READ_SVLC(iDQp, "delta_qp");
1735 #else
1736  xReadSvlc( iDQp );
1737 #endif
1738 
1739  Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
1740  qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY;
1741 
1742  UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ;
1743  UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ;
1744 
1745  pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth );
1746 }
1747 
1748 Void TDecCavlc::parseChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1749 {
1750  assert(0);
1751 }
1752 
1754 {
1755  assert(0);
1756 }
1757 
1758 Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ )
1759 {
1760  assert(0);
1761 }
1762 
1763 Void TDecCavlc::parseQtCbf( TComTU &/*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ )
1764 {
1765  assert(0);
1766 }
1767 
1768 Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ )
1769 {
1770  assert(0);
1771 }
1772 
1774 {
1775  assert(0);
1776 }
1777 
1778 Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ )
1779 {
1780  assert(0);
1781 }
1782 
1783 Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ )
1784 {
1785  assert(0);
1786 }
1787 
1788 // ====================================================================================================================
1789 // Protected member functions
1790 // ====================================================================================================================
1791 
1794 {
1795  WPScalingParam *wp;
1796  const ChromaFormat chFmt = sps->getChromaFormatIdc();
1797  const Int numValidComp = Int(getNumberValidComponents(chFmt));
1798  const Bool bChroma = (chFmt!=CHROMA_400);
1799  const SliceType eSliceType = pcSlice->getSliceType();
1800  const Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1);
1801  UInt uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0;
1802  UInt uiTotalSignalledWeightFlags = 0;
1803 
1804  Int iDeltaDenom;
1805  // decode delta_luma_log2_weight_denom :
1806  READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );
1807  assert( uiLog2WeightDenomLuma <= 7 );
1808  if( bChroma )
1809  {
1810  READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );
1811  assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0);
1812  assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7);
1813  uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma);
1814  }
1815 
1816  for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements
1817  {
1818  RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
1819  for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
1820  {
1821  pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
1822 
1823  wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma;
1824  for(Int j=1; j<numValidComp; j++)
1825  {
1826  wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma;
1827  }
1828 
1829  UInt uiCode;
1830  READ_FLAG( uiCode, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" );
1831  wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 );
1832  uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
1833  }
1834  if ( bChroma )
1835  {
1836  UInt uiCode;
1837  for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
1838  {
1839  pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
1840  READ_FLAG( uiCode, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" );
1841  for(Int j=1; j<numValidComp; j++)
1842  {
1843  wp[j].bPresentFlag = ( uiCode == 1 );
1844  }
1845  uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag;
1846  }
1847  }
1848  for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
1849  {
1850  pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
1851  if ( wp[COMPONENT_Y].bPresentFlag )
1852  {
1853  Int iDeltaWeight;
1854  READ_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" );
1855  assert( iDeltaWeight >= -128 );
1856  assert( iDeltaWeight <= 127 );
1857  wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom));
1858  READ_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" );
1860  assert( wp[0].iOffset >= -range );
1861  assert( wp[0].iOffset < range );
1862  }
1863  else
1864  {
1866  wp[COMPONENT_Y].iOffset = 0;
1867  }
1868  if ( bChroma )
1869  {
1870  if ( wp[COMPONENT_Cb].bPresentFlag )
1871  {
1873  for ( Int j=1 ; j<numValidComp ; j++ )
1874  {
1875  Int iDeltaWeight;
1876  READ_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" );
1877  assert( iDeltaWeight >= -128 );
1878  assert( iDeltaWeight <= 127 );
1879  wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom));
1880 
1881  Int iDeltaChroma;
1882  READ_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" );
1883  assert( iDeltaChroma >= -4*range);
1884  assert( iDeltaChroma < 4*range);
1885  Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
1886  wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) );
1887  }
1888  }
1889  else
1890  {
1891  for ( Int j=1 ; j<numValidComp ; j++ )
1892  {
1893  wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom);
1894  wp[j].iOffset = 0;
1895  }
1896  }
1897  }
1898  }
1899 
1900  for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
1901  {
1902  pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
1903 
1904  wp[0].bPresentFlag = false;
1905  wp[1].bPresentFlag = false;
1906  wp[2].bPresentFlag = false;
1907  }
1908  }
1909  assert(uiTotalSignalledWeightFlags<=24);
1910 }
1911 
1916 {
1917  UInt code, sizeId, listId;
1918  Bool scalingListPredModeFlag;
1919  //for each size
1920  for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
1921  {
1922  for(listId = 0; listId < SCALING_LIST_NUM; listId++)
1923  {
1924  if ((sizeId==SCALING_LIST_32x32) && (listId%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0))
1925  {
1926  Int *src = scalingList->getScalingListAddress(sizeId, listId);
1927  const Int size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]);
1928  const Int *srcNextSmallerSize = scalingList->getScalingListAddress(sizeId-1, listId);
1929  for(Int i=0; i<size; i++)
1930  {
1931  src[i] = srcNextSmallerSize[i];
1932  }
1933  scalingList->setScalingListDC(sizeId,listId,(sizeId > SCALING_LIST_8x8) ? scalingList->getScalingListDC(sizeId-1, listId) : src[0]);
1934  }
1935  else
1936  {
1937  READ_FLAG( code, "scaling_list_pred_mode_flag");
1938  scalingListPredModeFlag = (code) ? true : false;
1939  scalingList->setScalingListPredModeFlag(sizeId, listId, scalingListPredModeFlag);
1940  if(!scalingListPredModeFlag) //Copy Mode
1941  {
1942  READ_UVLC( code, "scaling_list_pred_matrix_id_delta");
1943 
1944  if (sizeId==SCALING_LIST_32x32)
1945  {
1946  code*=(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries.
1947  }
1948 
1949  scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code)));
1950  if( sizeId > SCALING_LIST_8x8 )
1951  {
1952  scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId))));
1953  }
1954  scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId));
1955 
1956  }
1957  else //DPCM Mode
1958  {
1959  xDecodeScalingList(scalingList, sizeId, listId);
1960  }
1961  }
1962  }
1963  }
1964 
1965  return;
1966 }
1973 {
1974  Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]);
1975  Int data;
1976  Int scalingListDcCoefMinus8 = 0;
1977  Int nextCoef = SCALING_LIST_START_VALUE;
1978  UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3];
1979  Int *dst = scalingList->getScalingListAddress(sizeId, listId);
1980 
1981  if( sizeId > SCALING_LIST_8x8 )
1982  {
1983  READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8");
1984  scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8);
1985  nextCoef = scalingList->getScalingListDC(sizeId,listId);
1986  }
1987 
1988  for(i = 0; i < coefNum; i++)
1989  {
1990  READ_SVLC( data, "scaling_list_delta_coef");
1991  nextCoef = (nextCoef + data + 256 ) % 256;
1992  dst[scan[i]] = nextCoef;
1993  }
1994 }
1995 
1997 {
1998  Int bitsLeft = m_pcBitstream->getNumBitsLeft();
1999 
2000  // if there are more than 8 bits, it cannot be rbsp_trailing_bits
2001  if (bitsLeft > 8)
2002  {
2003  return true;
2004  }
2005 
2006  UChar lastByte = m_pcBitstream->peekBits(bitsLeft);
2007  Int cnt = bitsLeft;
2008 
2009  // remove trailing bits equal to zero
2010  while ((cnt>0) && ((lastByte & 1) == 0))
2011  {
2012  lastByte >>= 1;
2013  cnt--;
2014  }
2015  // remove bit equal to one
2016  cnt--;
2017 
2018  // we should not have a negative number of bits
2019  assert (cnt>=0);
2020 
2021  // we have more data, if cnt is not zero
2022  return (cnt>0);
2023 }
2024 
2026 {
2027  assert(0);
2028 }
2029 
2031 
Void setNumTileColumnsMinus1(Int i)
Definition: TComSlice.h:1134
Int getNumberOfPositivePictures() const
Definition: TComSlice.h:109
Void setColourDescriptionPresentFlag(Bool i)
Definition: TComSlice.h:651
Bool getNalHrdParametersPresentFlag() const
Definition: TComSlice.h:321
Int getNumTileRowsMinus1() const
Definition: TComSlice.h:1139
Void setSliceSegmentCurEndCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1479
Void setPPSId(Int i)
Definition: TComSlice.h:1042
UInt g_uiMaxCUDepth
Definition: TComRom.cpp:253
Void setNoOutputPriorPicsFlag(Bool val)
Definition: TComSlice.h:1453
Int getPicInitQPMinus26() const
Definition: TComSlice.h:1046
Void parseQtCbf(class TComTU &rTu, const ComponentID compID, const Bool lowestLevel)
Definition: TDecCAVLC.cpp:1763
Void setUsed(Int bufferNum, Bool used)
Definition: TComSlice.cpp:1800
Void setQuadtreeTULog2MaxSize(UInt u)
Definition: TComSlice.h:860
Void clearSubstreamSizes()
Definition: TComSlice.h:1509
UInt getMaxNuhReservedZeroLayerId() const
Definition: TComSlice.h:500
Int getSPSId() const
Definition: TComSlice.h:1043
SliceType
supported slice type
Definition: TypeDef.h:343
Bool getFixedPicRateFlag(Int layer) const
Definition: TComSlice.h:359
Bool getVclHrdParametersPresentFlag() const
Definition: TComSlice.h:324
UInt getMaxLatencyIncrease(UInt tLayer) const
Definition: TComSlice.h:495
Void setPPSId(Int PPSId)
Definition: TComSlice.h:1317
Void setVideoSignalTypePresentFlag(Bool i)
Definition: TComSlice.h:642
UInt * g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][6][6]
Definition: TComRom.cpp:573
Void setDeblockingFilterTcOffsetDiv2(Int i)
Definition: TComSlice.h:1389
Void setSPSId(Int i)
Definition: TComSlice.h:813
Void setSarHeight(Int i)
Definition: TComSlice.h:633
Bool getUsedByCurrPicLtSPSFlag(Int i) const
Definition: TComSlice.h:836
Void parseSliceHeader(TComSlice *pcSlice, ParameterSetManager *parameterSetManager)
Definition: TDecCAVLC.cpp:918
Void xTraceSPSHeader(const TComSPS *pSPS)
Definition: TDecCAVLC.cpp:51
PPSExtensionFlagIndex
Definition: TypeDef.h:672
UInt getMaxTLayers() const
Definition: TComSlice.h:479
Void setMaxCUHeight(UInt u)
Definition: TComSlice.h:846
Void setUseWP(Bool b)
Definition: TComSlice.h:1104
#define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1
Definition: TypeDef.h:101
Int * getScalingListAddress(UInt sizeId, UInt listId)
get matrix coefficient
Definition: TComSlice.h:155
Void setColRefIdx(UInt refIdx)
Definition: TComSlice.h:1400
Void xTracePPSHeader(const TComPPS *pPPS)
Definition: TDecCAVLC.cpp:56
SliceType getSliceType() const
Definition: TComSlice.h:1337
Void setUseDQP(Bool b)
Definition: TComSlice.h:1049
CU data structure class.
Definition: TComDataCU.h:64
Void setDependentSliceSegmentFlag(Bool val)
Definition: TComSlice.h:1341
Void parseInterDir(TComDataCU *pcCU, UInt &ruiInterDir, UInt uiAbsPartIdx)
Definition: TDecCAVLC.cpp:1708
Void setColFromL0Flag(Bool colFromL0)
Definition: TComSlice.h:1399
Void setFixedPicRateFlag(Int layer, Bool flag)
Definition: TComSlice.h:358
Int getSPSId() const
Definition: TComSlice.h:812
Void setRefPicSetIdxL0(UInt idx, UInt refPicSetIdx)
Definition: TComSlice.h:971
Int getNumTileColumnsMinus1() const
Definition: TComSlice.h:1135
Void parsePPS(TComPPS *pcPPS)
Definition: TDecCAVLC.cpp:181
Void parseChromaQpAdjustment(TComDataCU *cu, UInt absPartIdx, UInt depth)
Definition: TDecCAVLC.cpp:1748
Void printDeltaPOC() const
Definition: TComSlice.cpp:1903
Void processRefMatrix(UInt sizeId, UInt listId, UInt refListId)
Definition: TComSlice.cpp:1983
Void setMatrixCoefficients(Int i)
Definition: TComSlice.h:660
#define READ_CODE(length, code, name)
Void setTierFlag(Level::Tier x)
Definition: TComSlice.h:209
Void parseTerminatingBit(UInt &ruiBit)
Definition: TDecCAVLC.cpp:1620
Bool getCprmsPresentFlag(UInt i) const
Definition: TComSlice.h:473
void Void
Definition: TypeDef.h:285
Void setVideoFullRangeFlag(Bool i)
Definition: TComSlice.h:648
Void setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx)
Definition: TComSlice.h:973
Void setDuCpbSizeScale(UInt value)
Definition: TComSlice.h:346
Void setScalingListPredModeFlag(UInt sizeId, UInt listId, Bool bIsDPCM)
Definition: TComSlice.h:168
Void setNumberOfNegativePictures(Int number)
Definition: TComSlice.h:106
Int getNumRpsCurrTempList() const
Definition: TComSlice.cpp:481
Bool getSliceChromaQpFlag() const
Definition: TComSlice.h:1052
Void setMinSpatialSegmentationIdc(Int i)
Definition: TComSlice.h:700
Void setDependentSliceSegmentsEnabledFlag(Bool val)
Definition: TComSlice.h:1126
Void setMaxCUWidth(UInt u)
Definition: TComSlice.h:844
Void setDeblockingFilterBetaOffsetDiv2(Int i)
Definition: TComSlice.h:1388
Void setTransquantBypassEnableFlag(Bool b)
Definition: TComSlice.h:1115
Void setScalingListPresentFlag(Bool b)
Definition: TComSlice.h:1159
Void parseCUTransquantBypassFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1660
#define NULL
Definition: CommonDef.h:100
Void xParsePredWeightTable(TComSlice *pcSlice, const TComSPS *sps)
parse explicit wp tables
Definition: TDecCAVLC.cpp:1793
Void setSubLayerProfilePresentFlag(Int i, Bool x)
Definition: TComSlice.h:256
Void setChromaSampleLocTypeTopField(Int i)
Definition: TComSlice.h:666
Void setEnableTMVPFlag(Bool b)
Definition: TComSlice.h:1521
Void setChromaQpAdjTableAt(Int cuChromaQpOffsetIdxPlus1, Int cbOffset, Int crOffset)
Definition: TComSlice.h:1089
virtual ~TDecCavlc()
Definition: TDecCAVLC.cpp:76
Int getNumExtraSliceHeaderBits() const
Definition: TComSlice.h:1166
UInt getBitsForPOC() const
Definition: TComSlice.h:857
Void setCabacInitPresentFlag(Bool flag)
Definition: TComSlice.h:1146
Void addSubstreamSize(UInt size)
Definition: TComSlice.h:1511
#define READ_SVLC(code, name)
Void setPCMFilterDisableFlag(Bool bValue)
Definition: TComSlice.h:917
Void setFrameOnlyConstraintFlag(Bool b)
Definition: TComSlice.h:230
Bool getCabacInitPresentFlag() const
Definition: TComSlice.h:1147
UInt getNumHrdParameters() const
Definition: TComSlice.h:497
Bool getScalingListPresentFlag() const
Definition: TComSlice.h:924
Void setDuCpbSizeValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:378
unsigned int UInt
Definition: TypeDef.h:297
Bool getHrdParametersPresentFlag() const
Definition: TComSlice.h:684
Void setSaoEnabledFlag(ChannelType chType, Bool s)
Definition: TComSlice.h:1321
Void setDeltaPOC(Int bufferNum, Int deltaPOC)
Definition: TComSlice.cpp:1805
Bool getUseSAO() const
Definition: TComSlice.h:893
Void setCprmsPresentFlag(Bool val, UInt i)
Definition: TComSlice.h:474
Void setMaxBytesPerPicDenom(Int i)
Definition: TComSlice.h:703
#define MAX_TLAYER
max number of temporal layer
Definition: CommonDef.h:192
Bool getPicDisableDeblockingFilterFlag() const
get offset for deblocking filter disabled
Definition: TComSlice.h:1153
static Int getWinUnitY(Int chromaFormatIdc)
Definition: TComSlice.h:818
Void parseTransformSubdivFlag(UInt &ruiSubdivFlag, UInt uiLog2TransformBlockSize)
Definition: TDecCAVLC.cpp:1758
Void setLowerBitRateConstraintFlag(Bool b)
Definition: TComSlice.h:242
Void setMaxBitsPerMinCuDenom(Int i)
Definition: TComSlice.h:706
Void setMaxCuDQPDepth(UInt u)
Definition: TComSlice.h:1055
Void setQuadtreeTUMaxDepthInter(UInt u)
Definition: TComSlice.h:864
Void setUseCrossComponentPrediction(Bool value)
Definition: TComSlice.h:1108
Void setLtRefPicPocLsbSps(UInt index, UInt val)
Definition: TComSlice.h:834
Void setQpOffset(ComponentID compID, Int i)
Definition: TComSlice.h:1058
SCALING_LIST class.
Definition: TComSlice.h:150
Void setNumHrdParameters(UInt v)
Definition: TComSlice.h:498
Void setTransformSkipLog2MaxSize(UInt u)
Definition: TComSlice.h:1121
const TComRPSList * getRPSList() const
Definition: TComSlice.h:871
Void setUseHighPrecisionPredictionWeighting(Bool value)
Definition: TComSlice.h:890
Int getDeblockingFilterBetaOffsetDiv2() const
Definition: TComSlice.h:1350
Void setPicHeightInLumaSamples(UInt u)
Definition: TComSlice.h:823
UInt getMaxCUHeight() const
Definition: TComSlice.h:847
Void setCpbRemovalDelayLengthMinus1(UInt value)
Definition: TComSlice.h:352
Bool getLowDelayHrdFlag(Int layer) const
Definition: TComSlice.h:368
UInt getMaxDecPicBuffering(UInt tlayer) const
Definition: TComSlice.h:929
Void setNumReorderPics(Int i, UInt tlayer)
Definition: TComSlice.h:868
TComRefPicListModification * getRefPicListModification()
Definition: TComSlice.h:1330
Void parsePredMode(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1680
Void parseVUI(TComVUI *pcVUI, TComSPS *pcSPS)
Definition: TDecCAVLC.cpp:410
Void setSliceCurStartCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1466
Void setChromaFormatConstraint(ChromaFormat fmt)
Definition: TComSlice.h:236
Reference Picture Lists class.
Definition: TComSlice.h:951
Void parseDeltaQP(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1728
Window & getDefaultDisplayWindow()
Definition: TComSlice.h:680
Int getDeblockingFilterTcOffsetDiv2() const
Definition: TComSlice.h:1351
Void setUseAMP(Bool b)
Definition: TComSlice.h:859
Void initWpScaling(const TComSPS *sps)
init WP table
Definition: TComSlice.cpp:1492
ChromaFormat getChromaFormatIdc() const
Definition: TComSlice.h:814
Int getScalingListDC(UInt sizeId, UInt listId) const
get DC value
Definition: TComSlice.h:166
Void setNumReorderPics(UInt v, UInt tLayer)
Definition: TComSlice.h:488
Void setChromaSampleLocTypeBottomField(Int i)
Definition: TComSlice.h:669
Int getNumRefIdx(RefPicList e) const
Definition: TComSlice.h:1353
Void setEntropyCodingSyncEnabledFlag(Bool val)
Definition: TComSlice.h:1128
Void setIntraConstraintFlag(Bool b)
Definition: TComSlice.h:239
ProfileTierLevel * getSubLayerPTL(Int i)
Definition: TComSlice.h:263
Void setTimeScale(UInt value)
Definition: TComSlice.h:412
Void setNalHrdParametersPresentFlag(Bool flag)
Definition: TComSlice.h:320
Bool getSubLayerProfilePresentFlag(Int i) const
Definition: TComSlice.h:255
Bool getRefPicListModificationFlagL1() const
Definition: TComSlice.h:968
Bool getRapPicFlag() const
Definition: TComSlice.cpp:182
Bool getSaoEnabledFlag(ChannelType chType) const
Definition: TComSlice.h:1322
Void parseQtRootCbf(UInt uiAbsPartIdx, UInt &uiQtRootCbf)
Definition: TDecCAVLC.cpp:1768
Void setRefPicListModificationFlagL1(Bool flag)
Definition: TComSlice.h:969
Bool getLongTermRefsPresent() const
Definition: TComSlice.h:873
Void setSPSId(Int i)
Definition: TComSlice.h:1044
#define MAX_VPS_OP_SETS_PLUS1
Definition: TypeDef.h:100
Void setBitsForPOC(UInt u)
Definition: TComSlice.h:856
Void setChromaFormatIdc(ChromaFormat i)
Definition: TComSlice.h:815
Void setCpbSizeScale(UInt value)
Definition: TComSlice.h:344
Void setTileUniformSpacingFlag(Bool b)
Definition: TComSlice.h:1132
TComInputBitstream * m_pcBitstream
TComVUI * getVuiParameters()
Definition: TComSlice.h:939
Void setFieldSeqFlag(Bool i)
Definition: TComSlice.h:675
Void setUsedByCurrPicLtSPSFlag(Int i, Bool x)
Definition: TComSlice.h:837
Void setDuCpbRemovalDelayLengthMinus1(UInt value)
Definition: TComSlice.h:332
Void setLog2MaxMvLengthVertical(Int i)
Definition: TComSlice.h:712
Bool isInterB() const
Definition: TComSlice.h:1405
Bool getTilesEnabledFlag() const
Definition: TComSlice.h:1131
Void setLFCrossSliceBoundaryFlag(Bool val)
Definition: TComSlice.h:1518
Void parseRefFrmIdx(TComDataCU *pcCU, Int &riRefFrmIdx, RefPicList eRefList)
Definition: TDecCAVLC.cpp:1713
Void setRestrictedRefPicListsFlag(Bool b)
Definition: TComSlice.h:697
Void setInterRPSPrediction(Bool flag)
Definition: TComSlice.h:113
Void setAspectRatioIdc(Int i)
Definition: TComSlice.h:627
Void setWindowBottomOffset(Int val)
Definition: TComSlice.h:539
Void setPicDisableDeblockingFilterFlag(Bool val)
set offset for deblocking filter disabled
Definition: TComSlice.h:1152
Void setRefPicListModificationFlagL0(Bool flag)
Definition: TComSlice.h:967
Void setVPSId(Int i)
Definition: TComSlice.h:811
Void parseMergeFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx)
Definition: TDecCAVLC.cpp:1778
Void setMaxLatencyIncrease(UInt ui, UInt tlayer)
Definition: TComSlice.h:932
UInt getLtRefPicPocLsbSps(UInt index) const
Definition: TComSlice.h:833
Bool getDependentSliceSegmentFlag() const
Definition: TComSlice.h:1340
Void setPOC(Int bufferNum, Int deltaPOC)
Definition: TComSlice.cpp:1835
Void setLog2DiffMaxMinCodingBlockSize(Int val)
Definition: TComSlice.h:842
Void setSliceChromaQpFlag(Bool b)
Definition: TComSlice.h:1053
#define SCALING_LIST_NUM
list number for quantization matrix
Definition: TComRom.h:215
Void setRefIdc(Int bufferNum, Int refIdc)
set the reference idc value at uiBufferNum entry to the value of iRefIdc
Definition: TComSlice.cpp:1851
Void setPocProportionalToTimingFlag(Bool x)
Definition: TComSlice.h:415
ProfileTierLevel * getGeneralPTL()
Definition: TComSlice.h:261
Bool getListsModificationPresentFlag() const
Definition: TComSlice.h:1162
Void xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId)
Definition: TDecCAVLC.cpp:1972
Bool getLoopFilterAcrossSlicesEnabledFlag() const
Definition: TComSlice.h:1169
Void setDeblockingFilterBetaOffsetDiv2(Int val)
set beta offset for deblocking filter
Definition: TComSlice.h:1154
Void parseScalingList(TComScalingList *scalingList)
Definition: TDecCAVLC.cpp:1915
Void setNonPackedConstraintFlag(Bool b)
Definition: TComSlice.h:227
CAVLC decoder class (header)
Void setMaxDecPicBuffering(UInt v, UInt tLayer)
Definition: TComSlice.h:491
Bool getEnableTMVPFlag()
Definition: TComSlice.h:1522
Void setSliceType(SliceType e)
Definition: TComSlice.h:1378
UInt getNumRefIdxL1DefaultActive() const
Definition: TComSlice.h:1100
Void setTileColumnWidth(const std::vector< Int > &columnWidth)
Definition: TComSlice.h:1136
Void setLevelIdc(Level::Name x)
Definition: TComSlice.h:218
Void setUseExtendedPrecision(Bool value)
Definition: TComSlice.h:888
Void setLayerIdIncludedFlag(Bool v, UInt opsIdx, UInt id)
Definition: TComSlice.h:506
Void setQuadtreeTULog2MinSize(UInt u)
Definition: TComSlice.h:862
UInt getMaxOpSets() const
Definition: TComSlice.h:503
Void setNumberOfPositivePictures(Int number)
Definition: TComSlice.h:108
FILE * g_hTrace
Definition: TComRom.cpp:561
UInt numEmulationPreventionBytesRead()
Void setTilesFixedStructureFlag(Bool i)
Definition: TComSlice.h:691
Void setDpbOutputDelayDuLengthMinus1(UInt value)
Definition: TComSlice.h:338
Void setMaxLatencyIncrease(UInt v, UInt tLayer)
Definition: TComSlice.h:494
Bool getSubLayerLevelPresentFlag(Int i) const
Definition: TComSlice.h:258
Void setWindowRightOffset(Int val)
Definition: TComSlice.h:535
Int getQpBDOffset(ChannelType type) const
Definition: TComSlice.h:885
TComScalingList & getScalingList()
Definition: TComSlice.h:1160
Void setScalingListDC(UInt sizeId, UInt listId, UInt u)
set DC value
Definition: TComSlice.h:165
Void setOverscanInfoPresentFlag(Bool i)
Definition: TComSlice.h:636
bool Bool
Definition: TypeDef.h:286
#define SCALING_LIST_START_VALUE
start value for dpcm mode
Definition: TComRom.h:217
Bool getUseTransformSkip() const
Definition: TComSlice.h:1118
Void setLog2ParallelMergeLevelMinus2(UInt mrgLevel)
Definition: TComSlice.h:1165
Bool getSubPicCpbParamsPresentFlag() const
Definition: TComSlice.h:327
Void setBitRateValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:373
TComReferencePictureSet * getReferencePictureSet(Int referencePictureSetNum)
Definition: TComSlice.h:143
Void setVclHrdParametersPresentFlag(Bool flag)
Definition: TComSlice.h:323
Void parseRemainingBytes(Bool noTrailingBytesExpected)
Definition: TDecCAVLC.cpp:1634
Void parseVPS(TComVPS *pcVPS)
Definition: TDecCAVLC.cpp:826
Void setPicDurationInTcMinus1(Int layer, UInt value)
Definition: TComSlice.h:364
Void setCbrFlag(Int layer, Int cpbcnt, Int nalOrVcl, Bool value)
Definition: TComSlice.h:382
Bool getRefPicListModificationFlagL0() const
Definition: TComSlice.h:966
Void setProfileSpace(Int x)
Definition: TComSlice.h:206
Bool getColourDescriptionPresentFlag() const
Definition: TComSlice.h:650
PPS class.
Definition: TComSlice.h:977
Char getRefQP(UInt uiCurrAbsIdxInCtu)
Void setUseResidualDPCM(const RDPCMSignallingMode signallingMode, const Bool value)
Definition: TComSlice.h:908
Void setVPSId(Int i)
Definition: TComSlice.h:477
Bool getOverscanInfoPresentFlag() const
Definition: TComSlice.h:635
Void setColourPrimaries(Int i)
Definition: TComSlice.h:654
Void setRPS(TComReferencePictureSet *pcRPS)
Definition: TComSlice.h:1323
UInt getPicHeightInLumaSamples() const
Definition: TComSlice.h:824
Void setMaxTLayers(UInt uiMaxTLayers)
Definition: TComSlice.h:911
Void setWindowTopOffset(Int val)
Definition: TComSlice.h:537
up-right diagonal scan
Definition: TypeDef.h:523
Void setUseSAO(Bool bVal)
Definition: TComSlice.h:892
UInt uiLog2WeightDenom
Definition: TComSlice.h:1179
TimingInfo * getTimingInfo()
Definition: TComSlice.h:510
Void setProfileCompatibilityFlag(Int i, Bool x)
Definition: TComSlice.h:215
Int getDeltaPOC(Int bufferNum) const
Definition: TComSlice.cpp:1820
UInt getPCMLog2MinSize() const
Definition: TComSlice.h:855
Void setMaxTLayers(UInt t)
Definition: TComSlice.h:480
Void setScalingListPresentFlag(Bool b)
Definition: TComSlice.h:925
Int getAspectRatioIdc() const
Definition: TComSlice.h:626
Void setLog2MaxMvLengthHorizontal(Int i)
Definition: TComSlice.h:709
Bool getPocProportionalToTimingFlag() const
Definition: TComSlice.h:416
T Clip3(const T minVal, const T maxVal, const T a)
general min/max clip
Definition: CommonDef.h:137
Reference Picture Set set class.
Definition: TComSlice.h:130
Void setTileRowHeight(const std::vector< Int > &rowHeight)
Definition: TComSlice.h:1140
Void parsePTL(TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1)
Definition: TDecCAVLC.cpp:1512
Void setHrdParametersPresentFlag(Bool i)
Definition: TComSlice.h:685
reference list 0
Definition: TypeDef.h:417
Void setDeblockingFilterOverrideFlag(Bool b)
Definition: TComSlice.h:1387
Void setNumTicksPocDiffOneMinus1(Int x)
Definition: TComSlice.h:418
Bool getTemporalNestingFlag() const
Definition: TComSlice.h:485
Void setSaoOffsetBitShift(ChannelType type, UInt uiBitShift)
Definition: TComSlice.h:1111
Void parseCrossComponentPrediction(class TComTU &rTu, ComponentID compID)
Definition: TDecCAVLC.cpp:1723
Bool getUseDQP() const
Definition: TComSlice.h:1048
Void setTilesEnabledFlag(Bool val)
Definition: TComSlice.h:1130
UInt getNumLongTermRefPicSPS() const
Definition: TComSlice.h:830
RefPicList
reference list index
Definition: TypeDef.h:415
Bool getColFromL0Flag() const
Definition: TComSlice.h:1358
Void setSliceCurEndCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1468
Void setUseStrongIntraSmoothing(Bool bVal)
Definition: TComSlice.h:934
const TComPTL * getPTL() const
Definition: TComSlice.h:943
UInt getMaxCuDQPDepth() const
Definition: TComSlice.h:1056
Void setUseSingleSignificanceMapContext(const Bool value)
Definition: TComSlice.h:899
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:352
Void setCheckLTMSBPresent(Int bufferNum, Bool b)
Definition: TComSlice.cpp:1845
Void setScalingListFlag(Bool b)
Definition: TComSlice.h:923
Bool getTimingInfoPresentFlag() const
Definition: TComSlice.h:407
Void setUseResidualRotation(const Bool value)
Definition: TComSlice.h:896
unsigned char UChar
Definition: TypeDef.h:293
UInt getQuadtreeTULog2MinSize() const
Definition: TComSlice.h:863
Bool getUseHighPrecisionPredictionWeighting() const
Definition: TComSlice.h:889
Void setPCMBitDepth(ChannelType type, UInt u)
Definition: TComSlice.h:916
Bool getAspectRatioInfoPresentFlag() const
Definition: TComSlice.h:623
Void setNumberOfPictures(Int numberOfPictures)
Definition: TComSlice.cpp:1810
Void setMaxNuhReservedZeroLayerId(UInt v)
Definition: TComSlice.h:501
UInt getNumRefIdxL0DefaultActive() const
Definition: TComSlice.h:1098
const TComPPS * getPPS() const
Definition: TComSlice.h:1309
Int getDeblockingFilterBetaOffsetDiv2() const
get beta offset for deblocking filter
Definition: TComSlice.h:1155
UInt getPicWidthInLumaSamples() const
Definition: TComSlice.h:822
Void setQpBDOffset(ChannelType type, Int i)
Definition: TComSlice.h:886
Void setMaxTrSize(UInt u)
Definition: TComSlice.h:878
Void setSliceChromaQpDelta(ComponentID compID, Int i)
Definition: TComSlice.h:1384
Void setMaxNumMergeCand(UInt val)
Definition: TComSlice.h:1450
Bool getIdrPicFlag() const
Definition: TComSlice.h:1374
Void setCpbCntMinus1(Int layer, UInt value)
Definition: TComSlice.h:370
Int getChromaQpAdjTableSize() const
Definition: TComSlice.h:1081
Profile::Name getProfileIdc() const
Definition: TComSlice.h:211
#define PTL_TRACE_TEXT(txt)
Level::Name getLevelIdc() const
Definition: TComSlice.h:217
std::vector< UInt > getEmulationPreventionByteLocation()
Bool getUseWP() const
Definition: TComSlice.h:1102
Bool getProfileCompatibilityFlag(Int i) const
Definition: TComSlice.h:214
#define MAX_NUM_REF
max. number of entries in picture reference list
Definition: CommonDef.h:113
Bool isIntra() const
Definition: TComSlice.h:1404
#define READ_FLAG(code, name)
Bool getScalingListPresentFlag() const
Definition: TComSlice.h:1158
Void setProfileIdc(Profile::Name x)
Definition: TComSlice.h:212
Name
Definition: TypeDef.h:635
reference list 1
Definition: TypeDef.h:418
Void setDisableIntraReferenceSmoothing(Bool bValue)
Definition: TComSlice.h:919
Int getPPSId() const
Definition: TComSlice.h:1041
Void setFrameFieldInfoPresentFlag(Bool i)
Definition: TComSlice.h:678
Void setPCMLog2MinSize(UInt u)
Definition: TComSlice.h:854
Void setMaxCuChromaQpAdjDepth(UInt u)
Definition: TComSlice.h:1078
#define MAX_MATRIX_COEF_NUM
max coefficient number for quantization matrix
Definition: TComRom.h:218
Void clearChromaQpAdjTable()
Definition: TComSlice.h:1080
#define READ_UVLC(code, name)
Int getPOC() const
Definition: TComSlice.h:1338
Void parseIntraDirChroma(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1703
Bool getDeblockingFilterControlPresentFlag() const
Definition: TComSlice.h:1149
Void setAspectRatioInfoPresentFlag(Bool i)
Definition: TComSlice.h:624
Bool getEntropyCodingSyncEnabledFlag() const
Definition: TComSlice.h:1127
Void parsePartSize(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1675
TimingInfo * getTimingInfo()
Definition: TComSlice.h:717
TComPTL * getPTL()
Definition: TComSlice.h:508
Void setListsModificationPresentFlag(Bool b)
Definition: TComSlice.h:1163
Void setHrdOpSetIdx(UInt val, UInt i)
Definition: TComSlice.h:472
Void setWindowLeftOffset(Int val)
Definition: TComSlice.h:533
Int getLog2DiffMaxMinCodingBlockSize() const
Definition: TComSlice.h:841
Void setMaxDecPicBuffering(UInt ui, UInt tlayer)
Definition: TComSlice.h:930
Bool getVideoSignalTypePresentFlag() const
Definition: TComSlice.h:641
Void setProgressiveSourceFlag(Bool b)
Definition: TComSlice.h:221
Bool getUsePCM() const
Definition: TComSlice.h:851
Int g_bitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:548
Bool getScalingListFlag() const
Definition: TComSlice.h:922
Void setUsePCM(Bool b)
Definition: TComSlice.h:850
Void setLongTermRefsPresent(Bool b)
Definition: TComSlice.h:874
Void setWPBiPred(Bool b)
Definition: TComSlice.h:1105
Void setDpbOutputDelayLengthMinus1(UInt value)
Definition: TComSlice.h:355
Void setPOC(Int i)
Definition: TComSlice.h:1370
Definition: TComTU.h:48
Void setCabacInitFlag(Bool val)
set CABAC initial flag
Definition: TComSlice.h:1514
Bool getTMVPFlagsPresent() const
Definition: TComSlice.h:875
Void parseSkipFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1655
Void setNumTileRowsMinus1(Int i)
Definition: TComSlice.h:1138
Int getNumberOfReferencePictureSets() const
Definition: TComSlice.h:146
Void parseMvd(TComDataCU *pcCU, UInt uiAbsPartAddr, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList)
Definition: TDecCAVLC.cpp:1718
Void setInterlacedSourceFlag(Bool b)
Definition: TComSlice.h:224
Void setNumRefIdxL1DefaultActive(UInt ui)
Definition: TComSlice.h:1099
UInt getMaxLatencyIncrease(UInt tlayer) const
Definition: TComSlice.h:931
Void setSubPicCpbParamsInPicTimingSEIFlag(Bool flag)
Definition: TComSlice.h:335
Void parseSPS(TComSPS *pcSPS)
Definition: TDecCAVLC.cpp:583
Void setNumUnitsInTick(UInt value)
Definition: TComSlice.h:409
Void setQuadtreeTUMaxDepthIntra(UInt u)
Definition: TComSlice.h:865
Bool getFixedPicRateWithinCvsFlag(Int layer) const
Definition: TComSlice.h:362
Void setBitstreamRestrictionFlag(Bool i)
Definition: TComSlice.h:688
Void parseTransformSkipFlags(class TComTU &rTu, ComponentID component)
Definition: TDecCAVLC.cpp:1773
TComPPS * getPPS(Int ppsId)
get pointer to existing picture parameter set
Definition: TComSlice.h:1647
Void createHrdParamBuffer()
Definition: TComSlice.h:462
Void setChromaLocInfoPresentFlag(Bool i)
Definition: TComSlice.h:663
Void setMotionVectorsOverPicBoundariesFlag(Bool i)
Definition: TComSlice.h:694
Void setCpbSizeValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:376
Void setTransferCharacteristics(Int i)
Definition: TComSlice.h:657
Void setQPSubParts(Int qp, UInt uiAbsPartIdx, UInt uiDepth)
Void readByte(UInt &ruiBits)
Int getNumberOfNegativePictures() const
Definition: TComSlice.h:107
Void setLoopFilterAcrossSlicesEnabledFlag(Bool bValue)
Definition: TComSlice.h:1168
Void setBitRateScale(UInt value)
Definition: TComSlice.h:341
Bool getDependentSliceSegmentsEnabledFlag() const
Definition: TComSlice.h:1125
Int getQpOffset(ComponentID compID) const
Definition: TComSlice.h:1073
Void setTMVPFlagsPresent(Bool b)
Definition: TComSlice.h:876
slice decoder class (header)
Void parseExplicitRdpcmMode(TComTU &rTu, ComponentID compID)
Definition: TDecCAVLC.cpp:2025
static Int getWinUnitX(Int chromaFormatIdc)
Definition: TComSlice.h:817
Void setRefMatrixId(UInt sizeId, UInt listId, UInt u)
set reference matrix ID
Definition: TComSlice.h:159
Void setNumRefIdxL0DefaultActive(UInt ui)
Definition: TComSlice.h:1097
Void parseIntraDirLumaAng(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1698
Void createRPSList(Int numRPS)
Definition: TComSlice.cpp:1619
Void setDeblockingFilterControlPresentFlag(Bool val)
Definition: TComSlice.h:1148
Void setFixedPicRateWithinCvsFlag(Int layer, Bool flag)
Definition: TComSlice.h:361
Void setDuBitRateValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl, UInt value)
Definition: TComSlice.h:380
Void setTimingInfoPresentFlag(Bool flag)
Definition: TComSlice.h:406
Void parseCoeffNxN(class TComTU &rTu, ComponentID compID)
Definition: TDecCAVLC.cpp:1753
Void setLowDelayHrdFlag(Int layer, Bool flag)
Definition: TComSlice.h:367
Void parseHrdParameters(TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh)
Definition: TDecCAVLC.cpp:505
Void setVideoFormat(Int i)
Definition: TComSlice.h:645
UInt g_scalingListSize[SCALING_LIST_SIZE_NUM]
Definition: TComRom.cpp:678
UInt getMaxDecPicBuffering(UInt tLayer) const
Definition: TComSlice.h:492
Bool getSliceHeaderExtensionPresentFlag() const
Definition: TComSlice.h:1170
#define MAX_QP_OFFSET_LIST_SIZE
Maximum size of QP offset list is 6 entries.
Definition: TypeDef.h:224
Bool getChromaLocInfoPresentFlag() const
Definition: TComSlice.h:662
Void setLog2MinCodingBlockSize(Int val)
Definition: TComSlice.h:840
Void setOutputFlagPresentFlag(Bool b)
Definition: TComSlice.h:1113
TComScalingList & getScalingList()
Definition: TComSlice.h:927
Int getNumberOfPictures() const
Definition: TComSlice.cpp:1825
Void setNumExtraSliceHeaderBits(Int i)
Definition: TComSlice.h:1167
Void setLoopFilterAcrossTilesEnabledFlag(Bool b)
Definition: TComSlice.h:1123
Void getWpScaling(RefPicList e, Int iRefIdx, WPScalingParam *&wp)
get tables for weighted prediction
Definition: TComSlice.cpp:1465
int Int
Definition: TypeDef.h:296
Window & getConformanceWindow()
Definition: TComSlice.h:826
Void setVuiParametersPresentFlag(Bool b)
Definition: TComSlice.h:938
const char data[10]
Bool getBitstreamRestrictionFlag() const
Definition: TComSlice.h:687
Void setSliceSegmentCurStartCtuTsAddr(UInt ctuTsAddr)
Definition: TComSlice.h:1477
static UInt getMaxCUDepthOffset(const ChromaFormat chFmt, const UInt quadtreeTULog2MinSize)
Void xTraceSliceHeader(const TComSlice *pSlice)
Definition: TDecCAVLC.cpp:61
Void setPicWidthInLumaSamples(UInt u)
Definition: TComSlice.h:821
UInt getMaxTLayers() const
Definition: TComSlice.h:910
Bool xMoreRbspData()
Definition: TDecCAVLC.cpp:1996
TComSPS * getSPS(Int spsId)
get pointer to existing sequence parameter set
Definition: TComSlice.h:1639
ComponentID
Definition: TypeDef.h:368
SPSExtensionFlagIndex
Definition: TypeDef.h:664
Void setAlignCABACBeforeBypass(const Bool value)
Definition: TComSlice.h:905
Int getSliceChromaQpDelta(ComponentID compID) const
Definition: TComSlice.h:1346
Void setMaxCUDepth(UInt u)
Definition: TComSlice.h:848
Int getSliceQp() const
Definition: TComSlice.h:1339
Void setSubPicCpbParamsPresentFlag(Bool flag)
Definition: TComSlice.h:326
Bool getTileUniformSpacingFlag() const
Definition: TComSlice.h:1133
Void setNumLongTermRefPicSPS(UInt val)
Definition: TComSlice.h:831
Void setTickDivisorMinus2(UInt value)
Definition: TComSlice.h:329
Void parseSplitFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1670
UInt getCpbCntMinus1(Int layer) const
Definition: TComSlice.h:371
Void setPCMLog2MaxSize(UInt u)
Definition: TComSlice.h:852
Int getNumberOfLongtermPictures() const
Definition: TComSlice.h:111
#define MRG_MAX_NUM_CANDS
Definition: CommonDef.h:186
UInt getNumReorderPics(UInt tLayer) const
Definition: TComSlice.h:489
Void parseShortTermRefPicSet(TComSPS *pcSPS, TComReferencePictureSet *pcRPS, Int idx)
Definition: TDecCAVLC.cpp:85
Bool getDeblockingFilterOverrideFlag() const
Definition: TComSlice.h:1349
Void parseMVPIdx(Int &riMVPIdx)
Definition: TDecCAVLC.cpp:1665
Void parseProfileTier(ProfileTierLevel *ptl, const Bool bIsSubLayer)
Definition: TDecCAVLC.cpp:1550
Void setUseChromaQpAdj(Bool b)
Definition: TComSlice.h:1385
Void parseMergeIndex(TComDataCU *pcCU, UInt &ruiMergeIndex)
Definition: TDecCAVLC.cpp:1783
UInt peekBits(UInt uiBits)
Void setBitDepthConstraint(UInt bitDepth)
Definition: TComSlice.h:233
Void setOverscanAppropriateFlag(Bool i)
Definition: TComSlice.h:639
Void setDeblockingFilterDisable(Bool b)
Definition: TComSlice.h:1386
Void setDeblockingFilterOverrideEnabledFlag(Bool val)
Definition: TComSlice.h:1150
Void setDeblockingFilterTcOffsetDiv2(Int val)
set tc offset for deblocking filter
Definition: TComSlice.h:1156
Void setConstrainedIntraPred(Bool b)
Definition: TComSlice.h:1051
Void setUseGolombRiceParameterAdaptation(const Bool value)
Definition: TComSlice.h:902
Reference Picture Set class.
Definition: TComSlice.h:65
Bool getDeblockingFilterDisable() const
Definition: TComSlice.h:1348
static UInt getNumberValidComponents(const ChromaFormat fmt)
NalUnitType getNalUnitType() const
Definition: TComSlice.h:1372
slice header class
Definition: TComSlice.h:1198
Int getPrevTid0POC() const
Definition: TComSlice.h:1329
Void setNumRefIdx(RefPicList e, Int i)
Definition: TComSlice.h:1393
TComHRD * getHrdParameters(UInt i)
Definition: TComSlice.h:469
Bool getWPBiPred() const
Definition: TComSlice.h:1103
Void setSignHideFlag(Bool signHideFlag)
Definition: TComSlice.h:1143
Void setPicOutputFlag(Bool b)
Definition: TComSlice.h:1319
Void setBitDepth(ChannelType type, Int u)
Definition: TComSlice.h:883
Int getDeblockingFilterTcOffsetDiv2() const
get tc offset for deblocking filter
Definition: TComSlice.h:1157
Void setMvdL1ZeroFlag(Bool b)
Definition: TComSlice.h:1402
Void setTemporalNestingFlag(Bool t)
Definition: TComSlice.h:486
Void setNeutralChromaIndicationFlag(Bool i)
Definition: TComSlice.h:672
Void setSliceQp(Int i)
Definition: TComSlice.h:1379
static Void IncrementStatisticEP(const TComCodingStatisticsClassType &stat, const Int numBits, const Int value)
Void setSubLayerLevelPresentFlag(Int i, Bool x)
Definition: TComSlice.h:259
reading funtionality for SEI messages
Bool getDeblockingFilterOverrideEnabledFlag() const
Definition: TComSlice.h:1151
Void setTemporalIdNestingFlag(Bool bValue)
Definition: TComSlice.h:914
UInt getRefMatrixId(UInt sizeId, UInt listId) const
get reference matrix ID
Definition: TComSlice.h:160
Void setMaxOpSets(UInt v)
Definition: TComSlice.h:504
TComReferencePictureSet * getLocalRPS()
Definition: TComSlice.h:1325
TComHRD * getHrdParameters()
Definition: TComSlice.h:714
Bool getVuiParametersPresentFlag() const
Definition: TComSlice.h:937
Void setNumberOfLongtermPictures(Int number)
Definition: TComSlice.h:110
Void setInitialCpbRemovalDelayLengthMinus1(UInt value)
Definition: TComSlice.h:349
Void setUseTransformSkip(Bool b)
Definition: TComSlice.h:1119
Void setPicInitQPMinus26(Int i)
Definition: TComSlice.h:1047
Void parseIPCMInfo(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TDecCAVLC.cpp:1693
Void setSarWidth(Int i)
Definition: TComSlice.h:630
Int getNumReorderPics(UInt tlayer) const
Definition: TComSlice.h:869
Void setNumRefIdc(Int x)
Definition: TComSlice.h:119
UInt getMaxCUWidth() const
Definition: TComSlice.h:845
Bool getOutputFlagPresentFlag() const
Definition: TComSlice.h:1114
Void setSliceHeaderExtensionPresentFlag(Bool val)
Definition: TComSlice.h:1171
TComSlice * getSlice()
Definition: TComDataCU.h:205
const TComSPS * getSPS() const
Definition: TComSlice.h:1306
SPS class.
Definition: TComSlice.h:722