HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TEncCavlc.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-2017, 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 "../TLibCommon/CommonDef.h"
39 #include "TEncCavlc.h"
40 #include "SEIwrite.h"
41 
44 
45 #if ENC_DEC_TRACE
46 
47 Void xTraceVPSHeader ()
48 {
49  fprintf( g_hTrace, "=========== Video Parameter Set ===========\n" );
50 }
51 
52 Void xTraceSPSHeader ()
53 {
54  fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" );
55 }
56 
57 Void xTracePPSHeader ()
58 {
59  fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n");
60 }
61 
62 Void xTraceSliceHeader ()
63 {
64  fprintf( g_hTrace, "=========== Slice ===========\n");
65 }
66 
67 Void xTraceAccessUnitDelimiter ()
68 {
69  fprintf( g_hTrace, "=========== Access Unit Delimiter ===========\n");
70 }
71 
72 #endif
73 
74 Void AUDWriter::codeAUD(TComBitIf& bs, const Int pictureType)
75 {
76 #if ENC_DEC_TRACE
77  xTraceAccessUnitDelimiter();
78 #endif
79 
80  assert (pictureType < 3);
81  setBitstream(&bs);
82  WRITE_CODE(pictureType, 3, "pic_type");
84 }
85 
86 // ====================================================================================================================
87 // Constructor / destructor / create / destroy
88 // ====================================================================================================================
89 
91 {
92  m_pcBitIf = NULL;
93 }
94 
96 {
97 }
98 
99 
100 // ====================================================================================================================
101 // Public member functions
102 // ====================================================================================================================
103 
105 {
106 }
107 
108 
110 {
111 #if PRINT_RPS_INFO
112  Int lastBits = getNumberOfWrittenBits();
113 #endif
114  if (idx > 0)
115  {
116  WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag
117  }
118  if (rps->getInterRPSPrediction())
119  {
120  Int deltaRPS = rps->getDeltaRPS();
121  if(calledFromSliceHeader)
122  {
123  WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1
124  }
125 
126  WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign
127  WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1
128 
129  for(Int j=0; j < rps->getNumRefIdc(); j++)
130  {
131  Int refIdc = rps->getRefIdc(j);
132  WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1
133  if (refIdc != 1)
134  {
135  WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise.
136  }
137  }
138  }
139  else
140  {
141  WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" );
142  WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" );
143  Int prev = 0;
144  for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++)
145  {
146  WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" );
147  prev = rps->getDeltaPOC(j);
148  WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag");
149  }
150  prev = 0;
152  {
153  WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" );
154  prev = rps->getDeltaPOC(j);
155  WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" );
156  }
157  }
158 
159 #if PRINT_RPS_INFO
160  printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits);
161  rps->printDeltaPOC();
162 #endif
163 }
164 
165 
167 {
168 #if ENC_DEC_TRACE
169  xTracePPSHeader ();
170 #endif
171 
172  WRITE_UVLC( pcPPS->getPPSId(), "pps_pic_parameter_set_id" );
173  WRITE_UVLC( pcPPS->getSPSId(), "pps_seq_parameter_set_id" );
174  WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag() ? 1 : 0, "dependent_slice_segments_enabled_flag" );
175  WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" );
176  WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits");
177  WRITE_FLAG( pcPPS->getSignDataHidingEnabledFlag(), "sign_data_hiding_enabled_flag" );
178  WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" );
179  WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1, "num_ref_idx_l0_default_active_minus1");
180  WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1, "num_ref_idx_l1_default_active_minus1");
181 
182  WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26");
183  WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" );
184  WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0, "transform_skip_enabled_flag" );
185  WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" );
186  if ( pcPPS->getUseDQP() )
187  {
188  WRITE_UVLC( pcPPS->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth" );
189  }
190 
191  WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" );
192  WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" );
193 
194  WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" );
195 
196  WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE)
197  WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE)
198  WRITE_FLAG( pcPPS->getTransquantBypassEnabledFlag() ? 1 : 0, "transquant_bypass_enabled_flag" );
199  WRITE_FLAG( pcPPS->getTilesEnabledFlag() ? 1 : 0, "tiles_enabled_flag" );
200  WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" );
201  if( pcPPS->getTilesEnabledFlag() )
202  {
203  WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(), "num_tile_columns_minus1" );
204  WRITE_UVLC( pcPPS->getNumTileRowsMinus1(), "num_tile_rows_minus1" );
205  WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(), "uniform_spacing_flag" );
206  if( !pcPPS->getTileUniformSpacingFlag() )
207  {
208  for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++)
209  {
210  WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1, "column_width_minus1" );
211  }
212  for(UInt i=0; i<pcPPS->getNumTileRowsMinus1(); i++)
213  {
214  WRITE_UVLC( pcPPS->getTileRowHeight(i)-1, "row_height_minus1" );
215  }
216  }
217  assert ((pcPPS->getNumTileColumnsMinus1() + pcPPS->getNumTileRowsMinus1()) != 0);
218  WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0, "loop_filter_across_tiles_enabled_flag");
219  }
220  WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0, "pps_loop_filter_across_slices_enabled_flag");
221  WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0, "deblocking_filter_control_present_flag");
223  {
224  WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" );
225  WRITE_FLAG( pcPPS->getPPSDeblockingFilterDisabledFlag() ? 1 : 0, "pps_deblocking_filter_disabled_flag" );
227  {
228  WRITE_SVLC( pcPPS->getDeblockingFilterBetaOffsetDiv2(), "pps_beta_offset_div2" );
229  WRITE_SVLC( pcPPS->getDeblockingFilterTcOffsetDiv2(), "pps_tc_offset_div2" );
230  }
231  }
232  WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" );
233  if( pcPPS->getScalingListPresentFlag() )
234  {
235  codeScalingList( pcPPS->getScalingList() );
236  }
237  WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag");
238  WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
239  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
240 
241  Bool pps_extension_present_flag=false;
242  Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false};
243 
244  pps_extension_flags[PPS_EXT__REXT] = pcPPS->getPpsRangeExtension().settingsDifferFromDefaults(pcPPS->getUseTransformSkip());
245 
246  // Other PPS extension flags checked here.
247 
248  for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++)
249  {
250  pps_extension_present_flag|=pps_extension_flags[i];
251  }
252 
253  WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" );
254 
255  if (pps_extension_present_flag)
256  {
257 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
258  static const TChar *syntaxStrings[]={ "pps_range_extension_flag",
259  "pps_multilayer_extension_flag",
260  "pps_extension_6bits[0]",
261  "pps_extension_6bits[1]",
262  "pps_extension_6bits[2]",
263  "pps_extension_6bits[3]",
264  "pps_extension_6bits[4]",
265  "pps_extension_6bits[5]" };
266 #endif
267 
268  for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++)
269  {
270  WRITE_FLAG( pps_extension_flags[i]?1:0, syntaxStrings[i] );
271  }
272 
273  for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
274  {
275  if (pps_extension_flags[i])
276  {
277  switch (PPSExtensionFlagIndex(i))
278  {
279  case PPS_EXT__REXT:
280  {
281  const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension();
282  if (pcPPS->getUseTransformSkip())
283  {
284  WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2, "log2_max_transform_skip_block_size_minus2");
285  }
286 
287  WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" );
288 
289  WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" );
290  if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag())
291  {
292  WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(), "diff_cu_chroma_qp_offset_depth");
293  WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1");
294  /* skip zero index */
295  for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++)
296  {
297  WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]");
298  WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]");
299  }
300  }
301 
302  WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" );
303  WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" );
304  }
305  break;
306  default:
307  assert(pps_extension_flags[i]==false); // Should never get here with an active PPS extension flag.
308  break;
309  } // switch
310  } // if flag present
311  } // loop over PPS flags
312  } // pps_extension_present_flag is non-zero
314 }
315 
316 Void TEncCavlc::codeVUI( const TComVUI *pcVUI, const TComSPS* pcSPS )
317 {
318 #if ENC_DEC_TRACE
319  fprintf( g_hTrace, "----------- vui_parameters -----------\n");
320 #endif
321  WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(), "aspect_ratio_info_present_flag");
322  if (pcVUI->getAspectRatioInfoPresentFlag())
323  {
324  WRITE_CODE(pcVUI->getAspectRatioIdc(), 8, "aspect_ratio_idc" );
325  if (pcVUI->getAspectRatioIdc() == 255)
326  {
327  WRITE_CODE(pcVUI->getSarWidth(), 16, "sar_width");
328  WRITE_CODE(pcVUI->getSarHeight(), 16, "sar_height");
329  }
330  }
331  WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(), "overscan_info_present_flag");
332  if (pcVUI->getOverscanInfoPresentFlag())
333  {
334  WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(), "overscan_appropriate_flag");
335  }
336  WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(), "video_signal_type_present_flag");
337  if (pcVUI->getVideoSignalTypePresentFlag())
338  {
339  WRITE_CODE(pcVUI->getVideoFormat(), 3, "video_format");
340  WRITE_FLAG(pcVUI->getVideoFullRangeFlag(), "video_full_range_flag");
341  WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(), "colour_description_present_flag");
342  if (pcVUI->getColourDescriptionPresentFlag())
343  {
344  WRITE_CODE(pcVUI->getColourPrimaries(), 8, "colour_primaries");
345  WRITE_CODE(pcVUI->getTransferCharacteristics(), 8, "transfer_characteristics");
346  WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coeffs");
347  }
348  }
349 
350  WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(), "chroma_loc_info_present_flag");
351  if (pcVUI->getChromaLocInfoPresentFlag())
352  {
353  WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(), "chroma_sample_loc_type_top_field");
354  WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(), "chroma_sample_loc_type_bottom_field");
355  }
356 
357  WRITE_FLAG(pcVUI->getNeutralChromaIndicationFlag(), "neutral_chroma_indication_flag");
358  WRITE_FLAG(pcVUI->getFieldSeqFlag(), "field_seq_flag");
359  WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(), "frame_field_info_present_flag");
360 
361  Window defaultDisplayWindow = pcVUI->getDefaultDisplayWindow();
362  WRITE_FLAG(defaultDisplayWindow.getWindowEnabledFlag(), "default_display_window_flag");
363  if( defaultDisplayWindow.getWindowEnabledFlag() )
364  {
365  WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset");
366  WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset");
367  WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset");
368  WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset");
369  }
370  const TimingInfo *timingInfo = pcVUI->getTimingInfo();
371  WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vui_timing_info_present_flag");
372  if(timingInfo->getTimingInfoPresentFlag())
373  {
374  WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vui_num_units_in_tick");
375  WRITE_CODE(timingInfo->getTimeScale(), 32, "vui_time_scale");
376  WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vui_poc_proportional_to_timing_flag");
377  if(timingInfo->getPocProportionalToTimingFlag())
378  {
379  WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vui_num_ticks_poc_diff_one_minus1");
380  }
381  WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "vui_hrd_parameters_present_flag");
382  if( pcVUI->getHrdParametersPresentFlag() )
383  {
384  codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
385  }
386  }
387 
388  WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(), "bitstream_restriction_flag");
389  if (pcVUI->getBitstreamRestrictionFlag())
390  {
391  WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(), "tiles_fixed_structure_flag");
392  WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(), "motion_vectors_over_pic_boundaries_flag");
393  WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag");
394  WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(), "min_spatial_segmentation_idc");
395  WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(), "max_bytes_per_pic_denom");
396  WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_min_cu_denom");
397  WRITE_UVLC(pcVUI->getLog2MaxMvLengthHorizontal(), "log2_max_mv_length_horizontal");
398  WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(), "log2_max_mv_length_vertical");
399  }
400 }
401 
402 Void TEncCavlc::codeHrdParameters( const TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 )
403 {
404  if( commonInfPresentFlag )
405  {
406  WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" );
407  WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" );
409  {
410  WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_hrd_params_present_flag" );
411  if( hrd->getSubPicCpbParamsPresentFlag() )
412  {
413  WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" );
414  WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_increment_length_minus1" );
415  WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" );
416  WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" );
417  }
418  WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" );
419  WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" );
420  if( hrd->getSubPicCpbParamsPresentFlag() )
421  {
422  WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" );
423  }
424  WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" );
425  WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(), 5, "au_cpb_removal_delay_length_minus1" );
426  WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1" );
427  }
428  }
429  Int i, j, nalOrVcl;
430  for( i = 0; i <= maxNumSubLayersMinus1; i ++ )
431  {
432  WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag");
433  Bool fixedPixRateWithinCvsFlag = true;
434  if( !hrd->getFixedPicRateFlag( i ) )
435  {
436  fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i );
437  WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag");
438  }
439  if( fixedPixRateWithinCvsFlag )
440  {
441  WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1");
442  }
443  else
444  {
445  WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag");
446  }
447  if (!hrd->getLowDelayHrdFlag( i ))
448  {
449  WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1");
450  }
451 
452  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
453  {
454  if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
455  ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
456  {
457  for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
458  {
459  WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1");
460  WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1");
461  if( hrd->getSubPicCpbParamsPresentFlag() )
462  {
463  WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1");
464  WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1");
465  }
466  WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag");
467  }
468  }
469  }
470  }
471 }
472 
474 {
475 
476  const ChromaFormat format = pcSPS->getChromaFormatIdc();
477  const Bool chromaEnabled = isChromaEnabled(format);
478 
479 #if ENC_DEC_TRACE
480  xTraceSPSHeader ();
481 #endif
482  WRITE_CODE( pcSPS->getVPSId (), 4, "sps_video_parameter_set_id" );
483  WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" );
484  WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" );
485  codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
486  WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" );
487  WRITE_UVLC( Int(pcSPS->getChromaFormatIdc ()), "chroma_format_idc" );
488  if( format == CHROMA_444 )
489  {
490  WRITE_FLAG( 0, "separate_colour_plane_flag");
491  }
492 
493  WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" );
494  WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" );
495  Window conf = pcSPS->getConformanceWindow();
496 
497  WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" );
498  if (conf.getWindowEnabledFlag())
499  {
500  WRITE_UVLC( conf.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
501  WRITE_UVLC( conf.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
502  WRITE_UVLC( conf.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
503  WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
504  }
505 
506  WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_luma_minus8" );
507 
508  WRITE_UVLC( chromaEnabled ? (pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) - 8):0, "bit_depth_chroma_minus8" );
509 
510  WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" );
511 
512  const Bool subLayerOrderingInfoPresentFlag = 1;
513  WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
514  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
515  {
516  WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]" );
517  WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_max_num_reorder_pics[i]" );
518  WRITE_UVLC( pcSPS->getMaxLatencyIncreasePlus1(i), "sps_max_latency_increase_plus1[i]" );
519  if (!subLayerOrderingInfoPresentFlag)
520  {
521  break;
522  }
523  }
524  assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() );
525  WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3, "log2_min_luma_coding_block_size_minus3" );
526  WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(), "log2_diff_max_min_luma_coding_block_size" );
527  WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_luma_transform_block_size_minus2" );
528  WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_luma_transform_block_size" );
529  WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" );
530  WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" );
531  WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" );
532  if(pcSPS->getScalingListFlag())
533  {
534  WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" );
535  if(pcSPS->getScalingListPresentFlag())
536  {
537  codeScalingList( pcSPS->getScalingList() );
538  }
539  }
540  WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0, "amp_enabled_flag" );
541  WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag");
542 
543  WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag");
544  if( pcSPS->getUsePCM() )
545  {
546  WRITE_CODE( pcSPS->getPCMBitDepth(CHANNEL_TYPE_LUMA) - 1, 4, "pcm_sample_bit_depth_luma_minus1" );
547  WRITE_CODE( chromaEnabled ? (pcSPS->getPCMBitDepth(CHANNEL_TYPE_CHROMA) - 1) : 0, 4, "pcm_sample_bit_depth_chroma_minus1" );
548  WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_luma_coding_block_size_minus3" );
549  WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_luma_coding_block_size" );
550  WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag");
551  }
552 
553  assert( pcSPS->getMaxTLayers() > 0 );
554 
555  const TComRPSList* rpsList = pcSPS->getRPSList();
556 
557  WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" );
558  for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++)
559  {
560  const TComReferencePictureSet*rps = rpsList->getReferencePictureSet(i);
561  codeShortTermRefPicSet( rps,false, i);
562  }
563  WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" );
564  if (pcSPS->getLongTermRefsPresent())
565  {
566  WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pics_sps" );
567  for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++)
568  {
569  WRITE_CODE( pcSPS->getLtRefPicPocLsbSps(k), pcSPS->getBitsForPOC(), "lt_ref_pic_poc_lsb_sps");
570  WRITE_FLAG( pcSPS->getUsedByCurrPicLtSPSFlag(k), "used_by_curr_pic_lt_sps_flag[i]");
571  }
572  }
573  WRITE_FLAG( pcSPS->getSPSTemporalMVPEnabledFlag() ? 1 : 0, "sps_temporal_mvp_enabled_flag" );
574 
575  WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "strong_intra_smoothing_enable_flag" );
576 
577  WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(), "vui_parameters_present_flag" );
578  if (pcSPS->getVuiParametersPresentFlag())
579  {
580  codeVUI(pcSPS->getVuiParameters(), pcSPS);
581  }
582 
583  Bool sps_extension_present_flag=false;
584  Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]={false};
585 
586  sps_extension_flags[SPS_EXT__REXT] = pcSPS->getSpsRangeExtension().settingsDifferFromDefaults();
587 
588  // Other SPS extension flags checked here.
589 
590  for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
591  {
592  sps_extension_present_flag|=sps_extension_flags[i];
593  }
594 
595  WRITE_FLAG( (sps_extension_present_flag?1:0), "sps_extension_present_flag" );
596 
597  if (sps_extension_present_flag)
598  {
599 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
600  static const TChar *syntaxStrings[]={ "sps_range_extension_flag",
601  "sps_multilayer_extension_flag",
602  "sps_extension_6bits[0]",
603  "sps_extension_6bits[1]",
604  "sps_extension_6bits[2]",
605  "sps_extension_6bits[3]",
606  "sps_extension_6bits[4]",
607  "sps_extension_6bits[5]" };
608 #endif
609 
610  for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
611  {
612  WRITE_FLAG( sps_extension_flags[i]?1:0, syntaxStrings[i] );
613  }
614 
615  for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
616  {
617  if (sps_extension_flags[i])
618  {
619  switch (SPSExtensionFlagIndex(i))
620  {
621  case SPS_EXT__REXT:
622  {
623  const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension();
624 
625  WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0), "transform_skip_rotation_enabled_flag");
626  WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0), "transform_skip_context_enabled_flag");
627  WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" );
628  WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" );
629  WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0), "extended_precision_processing_flag" );
630  WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag" );
631  WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0), "high_precision_offsets_enabled_flag" );
632  WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0), "persistent_rice_adaptation_enabled_flag" );
633  WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" );
634  break;
635  }
636  default:
637  assert(sps_extension_flags[i]==false); // Should never get here with an active SPS extension flag.
638  break;
639  }
640  }
641  }
642  }
644 }
645 
647 {
648 #if ENC_DEC_TRACE
649  xTraceVPSHeader();
650 #endif
651  WRITE_CODE( pcVPS->getVPSId(), 4, "vps_video_parameter_set_id" );
652  WRITE_FLAG( 1, "vps_base_layer_internal_flag" );
653  WRITE_FLAG( 1, "vps_base_layer_available_flag" );
654  WRITE_CODE( 0, 6, "vps_max_layers_minus1" );
655  WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" );
656  WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" );
657  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
658  WRITE_CODE( 0xffff, 16, "vps_reserved_0xffff_16bits" );
659  codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 );
660  const Bool subLayerOrderingInfoPresentFlag = 1;
661  WRITE_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag");
662  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
663  {
664  WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1, "vps_max_dec_pic_buffering_minus1[i]" );
665  WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_max_num_reorder_pics[i]" );
666  WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase_plus1[i]" );
667  if (!subLayerOrderingInfoPresentFlag)
668  {
669  break;
670  }
671  }
672 
673  assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS );
675  WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6, "vps_max_layer_id" );
676  WRITE_UVLC( pcVPS->getMaxOpSets() - 1, "vps_num_layer_sets_minus1" );
677  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ )
678  {
679  // Operation point set
680  for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
681  {
682  // Only applicable for version 1
683  // pcVPS->setLayerIdIncludedFlag( true, opsIdx, i );
684  WRITE_FLAG( pcVPS->getLayerIdIncludedFlag( opsIdx, i ) ? 1 : 0, "layer_id_included_flag[opsIdx][i]" );
685  }
686  }
687  const TimingInfo *timingInfo = pcVPS->getTimingInfo();
688  WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vps_timing_info_present_flag");
689  if(timingInfo->getTimingInfoPresentFlag())
690  {
691  WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vps_num_units_in_tick");
692  WRITE_CODE(timingInfo->getTimeScale(), 32, "vps_time_scale");
693  WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vps_poc_proportional_to_timing_flag");
694  if(timingInfo->getPocProportionalToTimingFlag())
695  {
696  WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vps_num_ticks_poc_diff_one_minus1");
697  }
698  WRITE_UVLC( pcVPS->getNumHrdParameters(), "vps_num_hrd_parameters" );
699 
700  if( pcVPS->getNumHrdParameters() > 0 )
701  {
702  for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ )
703  {
704  // Only applicable for version 1
705  WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ), "hrd_layer_set_idx" );
706  if( i > 0 )
707  {
708  WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" );
709  }
710  codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
711  }
712  }
713  }
714  WRITE_FLAG( 0, "vps_extension_flag" );
715 
716  //future extensions here..
718 }
719 
721 {
722 #if ENC_DEC_TRACE
723  xTraceSliceHeader ();
724 #endif
725 
726  const ChromaFormat format = pcSlice->getSPS()->getChromaFormatIdc();
727  const UInt numberValidComponents = getNumberValidComponents(format);
728  const Bool chromaEnabled = isChromaEnabled(format);
729 
730  //calculate number of bits required for slice address
731  Int maxSliceSegmentAddress = pcSlice->getPic()->getNumberOfCtusInFrame();
732  Int bitsSliceSegmentAddress = 0;
733  while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress))
734  {
735  bitsSliceSegmentAddress++;
736  }
737  const Int ctuTsAddress = pcSlice->getSliceSegmentCurStartCtuTsAddr();
738 
739  //write slice address
740  const Int sliceSegmentRsAddress = pcSlice->getPic()->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddress);
741 
742  WRITE_FLAG( sliceSegmentRsAddress==0, "first_slice_segment_in_pic_flag" );
743  if ( pcSlice->getRapPicFlag() )
744  {
745  WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" );
746  }
747  WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" );
748  if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) )
749  {
750  WRITE_FLAG( pcSlice->getDependentSliceSegmentFlag() ? 1 : 0, "dependent_slice_segment_flag" );
751  }
752  if(sliceSegmentRsAddress>0)
753  {
754  WRITE_CODE( sliceSegmentRsAddress, bitsSliceSegmentAddress, "slice_segment_address" );
755  }
756  if ( !pcSlice->getDependentSliceSegmentFlag() )
757  {
758  for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
759  {
760  WRITE_FLAG(0, "slice_reserved_flag[]");
761  }
762 
763  WRITE_UVLC( pcSlice->getSliceType(), "slice_type" );
764 
765  if( pcSlice->getPPS()->getOutputFlagPresentFlag() )
766  {
767  WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" );
768  }
769 
770  if( !pcSlice->getIdrPicFlag() )
771  {
772  Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
773  WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb");
774  const TComReferencePictureSet* rps = pcSlice->getRPS();
775 
776  // check for bitstream restriction stating that:
777  // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
778  // Ideally this process should not be repeated for each slice in a picture
779  if (pcSlice->isIRAP())
780  {
781  for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
782  {
783  assert (!rps->getUsed(picIdx));
784  }
785  }
786 
787  if(pcSlice->getRPSidx() < 0)
788  {
789  WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
791  }
792  else
793  {
794  WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag");
795  Int numBits = 0;
796  while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets())
797  {
798  numBits++;
799  }
800  if (numBits > 0)
801  {
802  WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" );
803  }
804  }
805  if(pcSlice->getSPS()->getLongTermRefsPresent())
806  {
807  Int numLtrpInSH = rps->getNumberOfLongtermPictures();
808  Int ltrpInSPS[MAX_NUM_REF_PICS];
809  Int numLtrpInSPS = 0;
810  UInt ltrpIndex;
811  Int counter = 0;
812  // WARNING: The following code only works only if a matching long-term RPS is
813  // found in the SPS for ALL long-term pictures
814  // The problem is that the SPS coded long-term pictures are moved to the
815  // beginning of the list which causes a mismatch when no reference picture
816  // list reordering is used
817  // NB: Long-term coding is currently not supported in general by the HM encoder
818  for(Int k = rps->getNumberOfPictures()-1; k > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; k--)
819  {
820  if (findMatchingLTRP(pcSlice, &ltrpIndex, rps->getPOC(k), rps->getUsed(k)))
821  {
822  ltrpInSPS[numLtrpInSPS] = ltrpIndex;
823  numLtrpInSPS++;
824  }
825  else
826  {
827  counter++;
828  }
829  }
830  numLtrpInSH -= numLtrpInSPS;
831  // check that either all long-term pictures are coded in SPS or in slice header (no mixing)
832  assert (numLtrpInSH==0 || numLtrpInSPS==0);
833 
834  Int bitsForLtrpInSPS = 0;
835  while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
836  {
837  bitsForLtrpInSPS++;
838  }
839  if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0)
840  {
841  WRITE_UVLC( numLtrpInSPS, "num_long_term_sps");
842  }
843  WRITE_UVLC( numLtrpInSH, "num_long_term_pics");
844  // Note that the LSBs of the LT ref. pic. POCs must be sorted before.
845  // Not sorted here because LT ref indices will be used in setRefPicList()
846  Int prevDeltaMSB = 0, prevLSB = 0;
847  Int offset = rps->getNumberOfNegativePictures() + rps->getNumberOfPositivePictures();
848  counter = 0;
849  // Warning: If some pictures are moved to ltrpInSPS, i is referring to a wrong index
850  // (mapping would be required)
851  for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--, counter++)
852  {
853  if (counter < numLtrpInSPS)
854  {
855  if (bitsForLtrpInSPS > 0)
856  {
857  WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]");
858  }
859  }
860  else
861  {
862  WRITE_CODE( rps->getPocLSBLT(i), pcSlice->getSPS()->getBitsForPOC(), "poc_lsb_lt");
863  WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag");
864  }
865  WRITE_FLAG( rps->getDeltaPocMSBPresentFlag(i), "delta_poc_msb_present_flag");
866 
867  if(rps->getDeltaPocMSBPresentFlag(i))
868  {
869  Bool deltaFlag = false;
870  // First LTRP from SPS || First LTRP from SH || curr LSB != prev LSB
871  if( (i == rps->getNumberOfPictures()-1) || (i == rps->getNumberOfPictures()-1-numLtrpInSPS) || (rps->getPocLSBLT(i) != prevLSB) )
872  {
873  deltaFlag = true;
874  }
875  if(deltaFlag)
876  {
877  WRITE_UVLC( rps->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i]" );
878  }
879  else
880  {
881  Int differenceInDeltaMSB = rps->getDeltaPocMSBCycleLT(i) - prevDeltaMSB;
882  assert(differenceInDeltaMSB >= 0);
883  WRITE_UVLC( differenceInDeltaMSB, "delta_poc_msb_cycle_lt[i]" );
884  }
885  prevLSB = rps->getPocLSBLT(i);
886  prevDeltaMSB = rps->getDeltaPocMSBCycleLT(i);
887  }
888  }
889  }
890  if (pcSlice->getSPS()->getSPSTemporalMVPEnabledFlag())
891  {
892  WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" );
893  }
894  }
895  if(pcSlice->getSPS()->getUseSAO())
896  {
897  WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag" );
898  if (chromaEnabled)
899  {
900  WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag" );
901  }
902  }
903 
904  //check if numrefidxes match the defaults. If not, override
905 
906  if (!pcSlice->isIntra())
907  {
908  Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive()));
909  WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag");
910  if (overrideFlag)
911  {
912  WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" );
913  if (pcSlice->isInterB())
914  {
915  WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, "num_ref_idx_l1_active_minus1" );
916  }
917  else
918  {
919  pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
920  }
921  }
922  }
923  else
924  {
925  pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0);
926  pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
927  }
928 
929  if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1)
930  {
931  TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
932  if(!pcSlice->isIntra())
933  {
934  WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" );
936  {
937  Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList();
938  if (numRpsCurrTempList0 > 1)
939  {
940  Int length = 1;
941  numRpsCurrTempList0 --;
942  while ( numRpsCurrTempList0 >>= 1)
943  {
944  length ++;
945  }
946  for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++)
947  {
948  WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0");
949  }
950  }
951  }
952  }
953  if(pcSlice->isInterB())
954  {
955  WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" );
957  {
958  Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList();
959  if ( numRpsCurrTempList1 > 1 )
960  {
961  Int length = 1;
962  numRpsCurrTempList1 --;
963  while ( numRpsCurrTempList1 >>= 1)
964  {
965  length ++;
966  }
967  for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++)
968  {
969  WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1");
970  }
971  }
972  }
973  }
974  }
975 
976  if (pcSlice->isInterB())
977  {
978  WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag");
979  }
980 
981  if(!pcSlice->isIntra())
982  {
983  if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag())
984  {
985  SliceType sliceType = pcSlice->getSliceType();
986  SliceType encCABACTableIdx = pcSlice->getEncCABACTableIdx();
987  Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=I_SLICE) ? true : false;
988  pcSlice->setCabacInitFlag( encCabacInitFlag );
989  WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" );
990  }
991  }
992 
993  if ( pcSlice->getEnableTMVPFlag() )
994  {
995  if ( pcSlice->getSliceType() == B_SLICE )
996  {
997  WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" );
998  }
999 
1000  if ( pcSlice->getSliceType() != I_SLICE &&
1001  ((pcSlice->getColFromL0Flag()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)||
1002  (pcSlice->getColFromL0Flag()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1)))
1003  {
1004  WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" );
1005  }
1006  }
1007  if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) )
1008  {
1009  xCodePredWeightTable( pcSlice );
1010  }
1011  assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS);
1012  if (!pcSlice->isIntra())
1013  {
1014  WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
1015  }
1016  Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 );
1017  WRITE_SVLC( iCode, "slice_qp_delta" );
1018  if (pcSlice->getPPS()->getSliceChromaQpFlag())
1019  {
1020  if (numberValidComponents > COMPONENT_Cb)
1021  {
1022  WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset" );
1023  }
1024  if (numberValidComponents > COMPONENT_Cr)
1025  {
1026  WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset" );
1027  }
1028  assert(numberValidComponents <= COMPONENT_Cr+1);
1029  }
1030 
1032  {
1033  WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag");
1034  }
1035 
1037  {
1039  {
1040  WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag");
1041  }
1042  if (pcSlice->getDeblockingFilterOverrideFlag())
1043  {
1044  WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_deblocking_filter_disabled_flag");
1045  if(!pcSlice->getDeblockingFilterDisable())
1046  {
1047  WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2");
1048  WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(), "slice_tc_offset_div2");
1049  }
1050  }
1051  }
1052 
1053  Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (chromaEnabled && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA)));
1054  Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable());
1055 
1056  if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
1057  {
1058  WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag");
1059  }
1060  }
1061  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
1062  {
1063  WRITE_UVLC(0,"slice_segment_header_extension_length");
1064  }
1065 }
1066 
1067 Void TEncCavlc::codePTL( const TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1)
1068 {
1069  if(profilePresentFlag)
1070  {
1071  codeProfileTier(pcPTL->getGeneralPTL(), false); // general_...
1072  }
1073  WRITE_CODE( Int(pcPTL->getGeneralPTL()->getLevelIdc()), 8, "general_level_idc" );
1074 
1075  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
1076  {
1077  WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" );
1078  WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" );
1079  }
1080 
1081  if (maxNumSubLayersMinus1 > 0)
1082  {
1083  for (Int i = maxNumSubLayersMinus1; i < 8; i++)
1084  {
1085  WRITE_CODE(0, 2, "reserved_zero_2bits");
1086  }
1087  }
1088 
1089  for(Int i = 0; i < maxNumSubLayersMinus1; i++)
1090  {
1091  if( pcPTL->getSubLayerProfilePresentFlag(i) )
1092  {
1093  codeProfileTier(pcPTL->getSubLayerPTL(i), true); // sub_layer_...
1094  }
1095  if( pcPTL->getSubLayerLevelPresentFlag(i) )
1096  {
1097  WRITE_CODE( Int(pcPTL->getSubLayerPTL(i)->getLevelIdc()), 8, "sub_layer_level_idc[i]" );
1098  }
1099  }
1100 }
1101 
1102 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
1103 Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool bIsSubLayer )
1104 #define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt)
1105 #else
1106 Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool /*bIsSubLayer*/ )
1107 #define PTL_TRACE_TEXT(txt) txt
1108 #endif
1109 {
1110  WRITE_CODE( ptl->getProfileSpace(), 2 , PTL_TRACE_TEXT("profile_space" ));
1111  WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, PTL_TRACE_TEXT("tier_flag" ));
1112  WRITE_CODE( Int(ptl->getProfileIdc()), 5 , PTL_TRACE_TEXT("profile_idc" ));
1113  for(Int j = 0; j < 32; j++)
1114  {
1115  WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), PTL_TRACE_TEXT("profile_compatibility_flag[][j]" ));
1116  }
1117 
1118  WRITE_FLAG(ptl->getProgressiveSourceFlag(), PTL_TRACE_TEXT("progressive_source_flag" ));
1119  WRITE_FLAG(ptl->getInterlacedSourceFlag(), PTL_TRACE_TEXT("interlaced_source_flag" ));
1120  WRITE_FLAG(ptl->getNonPackedConstraintFlag(), PTL_TRACE_TEXT("non_packed_constraint_flag" ));
1121  WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), PTL_TRACE_TEXT("frame_only_constraint_flag" ));
1122 
1124  {
1125  const UInt bitDepthConstraint=ptl->getBitDepthConstraint();
1126  WRITE_FLAG(bitDepthConstraint<=12, PTL_TRACE_TEXT("max_12bit_constraint_flag" ));
1127  WRITE_FLAG(bitDepthConstraint<=10, PTL_TRACE_TEXT("max_10bit_constraint_flag" ));
1128  WRITE_FLAG(bitDepthConstraint<= 8, PTL_TRACE_TEXT("max_8bit_constraint_flag" ));
1129  const ChromaFormat chromaFmtConstraint=ptl->getChromaFormatConstraint();
1130  WRITE_FLAG(chromaFmtConstraint==CHROMA_422||chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_422chroma_constraint_flag" ));
1131  WRITE_FLAG(chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_420chroma_constraint_flag" ));
1132  WRITE_FLAG(chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_monochrome_constraint_flag"));
1133  WRITE_FLAG(ptl->getIntraConstraintFlag(), PTL_TRACE_TEXT("intra_constraint_flag" ));
1134  WRITE_FLAG(ptl->getOnePictureOnlyConstraintFlag(), PTL_TRACE_TEXT("one_picture_only_constraint_flag"));
1135  WRITE_FLAG(ptl->getLowerBitRateConstraintFlag(), PTL_TRACE_TEXT("lower_bit_rate_constraint_flag" ));
1136  WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]" ));
1137  WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]" ));
1138  WRITE_CODE(0 , 2, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]" ));
1139  }
1140  else if (ptl->getProfileIdc() == Profile::MAIN10)
1141  {
1142  WRITE_CODE(0x00 , 7, PTL_TRACE_TEXT("reserved_zero_7bits" ));
1143  WRITE_FLAG(ptl->getOnePictureOnlyConstraintFlag(), PTL_TRACE_TEXT("one_picture_only_constraint_flag"));
1144  WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_35bits[0..15]" ));
1145  WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_35bits[16..31]" ));
1146  WRITE_CODE(0x0 , 3, PTL_TRACE_TEXT("reserved_zero_35bits[32..34]" ));
1147  }
1148  else
1149  {
1150  WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]" ));
1151  WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]" ));
1152  WRITE_CODE(0x000 , 11, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]" ));
1153  }
1154  WRITE_FLAG(false, PTL_TRACE_TEXT("inbld_flag" ));
1155 #undef PTL_TRACE_TEXT
1156 }
1157 
1164 {
1165  if (!pSlice->getPPS()->getTilesEnabledFlag() && !pSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
1166  {
1167  return;
1168  }
1169  UInt maxOffset = 0;
1170  for(Int idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++)
1171  {
1172  UInt offset=pSlice->getSubstreamSize(idx);
1173  if ( offset > maxOffset )
1174  {
1175  maxOffset = offset;
1176  }
1177  }
1178 
1179  // Determine number of bits "offsetLenMinus1+1" required for entry point information
1180  UInt offsetLenMinus1 = 0;
1181  while (maxOffset >= (1u << (offsetLenMinus1 + 1)))
1182  {
1183  offsetLenMinus1++;
1184  assert(offsetLenMinus1 + 1 < 32);
1185  }
1186 
1187  WRITE_UVLC(pSlice->getNumberOfSubstreamSizes(), "num_entry_point_offsets");
1188  if (pSlice->getNumberOfSubstreamSizes()>0)
1189  {
1190  WRITE_UVLC(offsetLenMinus1, "offset_len_minus1");
1191 
1192  for (UInt idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++)
1193  {
1194  WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1");
1195  }
1196  }
1197 }
1198 
1200 {
1201 }
1202 
1204 {
1205 }
1206 
1207 Void TEncCavlc::codeMVPIdx ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ )
1208 {
1209  assert(0);
1210 }
1211 
1212 Void TEncCavlc::codePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1213 {
1214  assert(0);
1215 }
1216 
1217 Void TEncCavlc::codePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1218 {
1219  assert(0);
1220 }
1221 
1222 Void TEncCavlc::codeMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1223 {
1224  assert(0);
1225 }
1226 
1227 Void TEncCavlc::codeMergeIndex ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1228 {
1229  assert(0);
1230 }
1231 
1232 Void TEncCavlc::codeInterModeFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiEncMode*/ )
1233 {
1234  assert(0);
1235 }
1236 
1238 {
1239  assert(0);
1240 }
1241 
1242 Void TEncCavlc::codeSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1243 {
1244  assert(0);
1245 }
1246 
1247 Void TEncCavlc::codeSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
1248 {
1249  assert(0);
1250 }
1251 
1253 {
1254  assert(0);
1255 }
1256 
1257 Void TEncCavlc::codeQtCbf( TComTU& /*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ )
1258 {
1259  assert(0);
1260 }
1261 
1262 Void TEncCavlc::codeQtRootCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1263 {
1264  assert(0);
1265 }
1266 
1267 Void TEncCavlc::codeQtCbfZero( TComTU& /*rTu*/, const ChannelType /*chType*/ )
1268 {
1269  assert(0);
1270 }
1272 {
1273  assert(0);
1274 }
1275 
1277 {
1278  assert(0);
1279 }
1280 
1286 Void TEncCavlc::codeIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1287 {
1288  assert(0);
1289 }
1290 
1291 Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, Bool /*isMultiple*/)
1292 {
1293  assert(0);
1294 }
1295 
1296 Void TEncCavlc::codeIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1297 {
1298  assert(0);
1299 }
1300 
1301 Void TEncCavlc::codeInterDir( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
1302 {
1303  assert(0);
1304 }
1305 
1306 Void TEncCavlc::codeRefFrmIdx( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ )
1307 {
1308  assert(0);
1309 }
1310 
1311 Void TEncCavlc::codeMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ )
1312 {
1313  assert(0);
1314 }
1315 
1317 {
1318  assert(0);
1319 }
1320 
1322 {
1323  Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx );
1324 
1325  Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
1326  iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2);
1327 
1328  xWriteSvlc( iDQp );
1329 
1330  return;
1331 }
1332 
1334 {
1335  assert(0);
1336 }
1337 
1338 Void TEncCavlc::codeCoeffNxN ( TComTU& /*rTu*/, TCoeff* /*pcCoef*/, const ComponentID /*compID*/ )
1339 {
1340  assert(0);
1341 }
1342 
1343 Void TEncCavlc::estBit( estBitsSbacStruct* /*pcEstBitsCabac*/, Int /*width*/, Int /*height*/, ChannelType /*chType*/, COEFF_SCAN_TYPE /*scanType*/ )
1344 {
1345  // printf("error : no VLC mode support in this version\n");
1346  return;
1347 }
1348 
1349 // ====================================================================================================================
1350 // Protected member functions
1351 // ====================================================================================================================
1352 
1355 {
1356  WPScalingParam *wp;
1357  const ChromaFormat format = pcSlice->getPic()->getChromaFormat();
1358  const UInt numberValidComponents = getNumberValidComponents(format);
1359  const Bool bChroma = isChromaEnabled(format);
1360  const Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1);
1361  Bool bDenomCoded = false;
1362  UInt uiTotalSignalledWeightFlags = 0;
1363 
1364  if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) )
1365  {
1366  for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements
1367  {
1368  RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
1369 
1370  // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings.
1371 
1372  for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
1373  {
1374  pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
1375  if ( !bDenomCoded )
1376  {
1377  Int iDeltaDenom;
1378  WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" );
1379 
1380  if( bChroma )
1381  {
1382  assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); // check the channel-type settings are consistent across components.
1383  iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom);
1384  WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );
1385  }
1386  bDenomCoded = true;
1387  }
1388  WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" );
1389  uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
1390  }
1391  if (bChroma)
1392  {
1393  for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
1394  {
1395  pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
1396  assert(wp[COMPONENT_Cb].bPresentFlag == wp[COMPONENT_Cr].bPresentFlag); // check the channel-type settings are consistent across components.
1397  WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" );
1398  uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag;
1399  }
1400  }
1401 
1402  for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
1403  {
1404  pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
1405  if ( wp[COMPONENT_Y].bPresentFlag )
1406  {
1407  Int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom));
1408  WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" );
1409  WRITE_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" );
1410  }
1411 
1412  if ( bChroma )
1413  {
1414  if ( wp[COMPONENT_Cb].bPresentFlag )
1415  {
1416  for ( Int j = COMPONENT_Cb ; j < numberValidComponents ; j++ )
1417  {
1418  assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom);
1419  Int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom));
1420  WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" );
1421 
1423  Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
1424  Int iDeltaChroma = (wp[j].iOffset - pred);
1425  WRITE_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" );
1426  }
1427  }
1428  }
1429  }
1430  }
1431  assert(uiTotalSignalledWeightFlags<=24);
1432  }
1433 }
1434 
1439 {
1440  //for each size
1441  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
1442  {
1443  const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries.
1444 
1445  for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep)
1446  {
1447  Bool scalingListPredModeFlag = scalingList.getScalingListPredModeFlag(sizeId, listId);
1448  WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" );
1449  if(!scalingListPredModeFlag)// Copy Mode
1450  {
1451  if (sizeId == SCALING_LIST_32x32)
1452  {
1453  // adjust the code, to cope with the missing chroma entries
1454  WRITE_UVLC( ((Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId)) / (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES), "scaling_list_pred_matrix_id_delta");
1455  }
1456  else
1457  {
1458  WRITE_UVLC( (Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta");
1459  }
1460  }
1461  else// DPCM Mode
1462  {
1463  xCodeScalingList(&scalingList, sizeId, listId);
1464  }
1465  }
1466  }
1467  return;
1468 }
1474 Void TEncCavlc::xCodeScalingList(const TComScalingList* scalingList, UInt sizeId, UInt listId)
1475 {
1476  Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]);
1477  UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3];
1478  Int nextCoef = SCALING_LIST_START_VALUE;
1479  Int data;
1480  const Int *src = scalingList->getScalingListAddress(sizeId, listId);
1481  if( sizeId > SCALING_LIST_8x8 )
1482  {
1483  WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8");
1484  nextCoef = scalingList->getScalingListDC(sizeId,listId);
1485  }
1486  for(Int i=0;i<coefNum;i++)
1487  {
1488  data = src[scan[i]] - nextCoef;
1489  nextCoef = src[scan[i]];
1490  if(data > 127)
1491  {
1492  data = data - 256;
1493  }
1494  if(data < -128)
1495  {
1496  data = data + 256;
1497  }
1498 
1499  WRITE_SVLC( data, "scaling_list_delta_coef");
1500  }
1501 }
1502 
1503 Bool TEncCavlc::findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag )
1504 {
1505  // Bool state = true, state2 = false;
1506  Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
1507  for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++)
1508  {
1509  if ( (lsb == pcSlice->getSPS()->getLtRefPicPocLsbSps(k)) && (usedFlag == pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(k)) )
1510  {
1511  *ltrpsIndex = k;
1512  return true;
1513  }
1514  }
1515  return false;
1516 }
1517 
1519  {
1520  assert(0);
1521  }
1522 
Bool getPCMFilterDisableFlag() const
Definition: TComSlice.h:918
Bool getOnePictureOnlyConstraintFlag() const
Definition: TComSlice.h:242
Void codeProfileTier(const ProfileTierLevel *ptl, const Bool bIsSubLayer)
Definition: TEncCavlc.cpp:1106
Int getNumberOfPositivePictures() const
Definition: TComSlice.h:109
static Bool isChromaEnabled(const ChromaFormat fmt)
Bool getNalHrdParametersPresentFlag() const
Definition: TComSlice.h:324
Int getNumTileRowsMinus1() const
Definition: TComSlice.h:1163
Int getLastIDR() const
Definition: TComSlice.h:1348
Bool getPicOutputFlag() const
Definition: TComSlice.h:1337
static const Int MAX_NUM_REF_PICS
max. number of pictures used for reference
Definition: CommonDef.h:124
Bool getCrossComponentPredictionEnabledFlag() const
Definition: TComSlice.h:1001
Void codeTransformSubdivFlag(UInt uiSymbol, UInt uiCtx)
Definition: TEncCavlc.cpp:1252
Int getPicInitQPMinus26() const
Definition: TComSlice.h:1097
UInt getDuCpbRemovalDelayLengthMinus1() const
Definition: TComSlice.h:336
UInt getNumberOfWrittenBits()
Definition: TEncCavlc.h:87
static const Int SCALING_LIST_NUM
list number for quantization matrix
Definition: CommonDef.h:232
UInt getMaxNuhReservedZeroLayerId() const
Definition: TComSlice.h:501
Int getSPSId() const
Definition: TComSlice.h:1094
SliceType
supported slice type
Definition: TypeDef.h:283
Bool getFixedPicRateFlag(Int layer) const
Definition: TComSlice.h:362
Bool getVclHrdParametersPresentFlag() const
Definition: TComSlice.h:327
UInt getMaxLatencyIncrease(UInt tLayer) const
Definition: TComSlice.h:496
Bool getPersistentRiceAdaptationEnabledFlag() const
Definition: TComSlice.h:732
Bool getSPSTemporalMVPEnabledFlag() const
Definition: TComSlice.h:887
Int getLog2MinCodingBlockSize() const
Definition: TComSlice.h:851
Bool getUsedByCurrPicLtSPSFlag(Int i) const
Definition: TComSlice.h:848
Bool getUseStrongIntraSmoothing() const
Definition: TComSlice.h:932
UInt getCtuTsToRsAddrMap(Int ctuTsAddr) const
Definition: TComPicSym.h:183
PPSExtensionFlagIndex
Definition: TypeDef.h:653
UInt getMaxTLayers() const
Definition: TComSlice.h:480
Int * getScalingListAddress(UInt sizeId, UInt listId)
get matrix coefficient
Definition: TComSlice.h:155
SliceType getSliceType() const
Definition: TComSlice.h:1353
CU data structure class.
Definition: TComDataCU.h:64
ChannelType
Definition: TypeDef.h:301
Void codeMvd(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)
Definition: TEncCavlc.cpp:1311
UInt getCpbSizeValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl) const
Definition: TComSlice.h:380
Bool getVideoFullRangeFlag() const
Definition: TComSlice.h:610
Int getSPSId() const
Definition: TComSlice.h:824
Int getSarHeight() const
Definition: TComSlice.h:595
Int getNumTileColumnsMinus1() const
Definition: TComSlice.h:1159
UInt getHrdOpSetIdx(UInt i) const
Definition: TComSlice.h:472
Void printDeltaPOC() const
Definition: TComSlice.cpp:1753
UInt getNumberOfCtusInFrame() const
Definition: TComPic.h:127
UInt getSubstreamSize(Int idx)
Definition: TComSlice.h:1526
Void codeSplitFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TEncCavlc.cpp:1247
Bool getCprmsPresentFlag(UInt i) const
Definition: TComSlice.h:474
void Void
Definition: TypeDef.h:203
Int getRPSidx() const
Definition: TComSlice.h:1345
Void codeQtRootCbfZero()
Definition: TEncCavlc.cpp:1271
Int getUsed(Int bufferNum) const
Definition: TComSlice.cpp:1665
#define WRITE_CODE(value, length, name)
Int getNumTicksPocDiffOneMinus1() const
Definition: TComSlice.h:420
const TComPPSRExt & getPpsRangeExtension() const
Definition: TComSlice.h:1197
Bool getLayerIdIncludedFlag(UInt opsIdx, UInt id) const
Definition: TComSlice.h:506
Bool getTransformSkipContextEnabledFlag() const
Definition: TComSlice.h:717
Void codeSPS(const TComSPS *pcSPS)
Definition: TEncCavlc.cpp:473
Bool getSliceChromaQpFlag() const
Definition: TComSlice.h:1103
Void codeExplicitRdpcmMode(TComTU &rTu, const ComponentID compID)
Definition: TEncCavlc.cpp:1518
static const Int MRG_MAX_NUM_CANDS
MERGE.
Definition: CommonDef.h:131
const TComSPSRExt & getSpsRangeExtension() const
Definition: TComSlice.h:941
pure virtual class for basic bit handling
Definition: TComBitStream.h:58
Void xCodePredWeightTable(TComSlice *pcSlice)
Code weighted prediction tables.
Definition: TEncCavlc.cpp:1354
Int getVPSId() const
Definition: TComSlice.h:822
UInt getTimeScale() const
Definition: TComSlice.h:414
UInt getBitDepthConstraint() const
Definition: TComSlice.h:233
Bool getNeutralChromaIndicationFlag() const
Definition: TComSlice.h:634
#define NULL
Definition: CommonDef.h:107
static const Int SCALING_LIST_START_VALUE
start value for dpcm mode
Definition: CommonDef.h:234
Int getNumExtraSliceHeaderBits() const
Definition: TComSlice.h:1190
union ChromaQpAdj::@2 u
UInt getBitsForPOC() const
Definition: TComSlice.h:869
Void setBitstream(TComBitIf *p)
const ChromaQpAdj & getChromaQpOffsetListEntry(Int cuChromaQpOffsetIdxPlus1) const
Definition: TComSlice.h:1012
Bool getUseChromaQpAdj() const
Definition: TComSlice.h:1364
Bool getCabacInitPresentFlag() const
Definition: TComSlice.h:1171
UInt getNumHrdParameters() const
Definition: TComSlice.h:498
Bool getScalingListPresentFlag() const
Definition: TComSlice.h:922
unsigned int UInt
Definition: TypeDef.h:212
Bool getHrdParametersPresentFlag() const
Definition: TComSlice.h:647
Void codeAUD(TComBitIf &bs, const Int pictureType)
Definition: TEncCavlc.cpp:74
Void codeSliceFinish()
Definition: TEncCavlc.cpp:1203
Bool getUseSAO() const
Definition: TComSlice.h:908
virtual ~TEncCavlc()
Definition: TEncCavlc.cpp:95
Bool getMvdL1ZeroFlag() const
Definition: TComSlice.h:1383
static Int getWinUnitY(Int chromaFormatIdc)
Definition: TComSlice.h:830
Void resetEntropy(const TComSlice *pSlice)
Definition: TEncCavlc.cpp:104
Void codeIntraDirChroma(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1296
Void codePredMode(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1217
SCALING_LIST class.
Definition: TComSlice.h:150
Int getMaxBytesPerPicDenom() const
Definition: TComSlice.h:665
Void xCodeScalingList(const TComScalingList *scalingList, UInt sizeId, UInt listId)
Definition: TEncCavlc.cpp:1474
UInt getPCMLog2MaxSize() const
Definition: TComSlice.h:865
Bool getRestrictedRefPicListsFlag() const
Definition: TComSlice.h:659
Int getMaxBitsPerMinCuDenom() const
Definition: TComSlice.h:668
const TComRPSList * getRPSList() const
Definition: TComSlice.h:883
Bool getNonPackedConstraintFlag() const
Definition: TComSlice.h:227
Int getDeblockingFilterBetaOffsetDiv2() const
Definition: TComSlice.h:1367
UInt getMaxCUHeight() const
Definition: TComSlice.h:859
Void codeSliceHeader(TComSlice *pcSlice)
Definition: TEncCavlc.cpp:720
Bool getLowDelayHrdFlag(Int layer) const
Definition: TComSlice.h:371
UInt getMaxDecPicBuffering(UInt tlayer) const
Definition: TComSlice.h:926
Int getLog2MaxMvLengthVertical() const
Definition: TComSlice.h:674
UInt getDuCpbSizeValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl) const
Definition: TComSlice.h:382
Int getTransferCharacteristics() const
Definition: TComSlice.h:619
TComRefPicListModification * getRefPicListModification()
Definition: TComSlice.h:1346
Bool getPPSDeblockingFilterDisabledFlag() const
get offset for deblocking filter disabled
Definition: TComSlice.h:1177
Void codeChromaQpAdjustment(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1333
Reference Picture Lists class.
Definition: TComSlice.h:948
Window & getDefaultDisplayWindow()
Definition: TComSlice.h:643
UInt getLog2MaxTransformSkipBlockSize() const
Definition: TComSlice.h:998
Int getDeblockingFilterTcOffsetDiv2() const
Definition: TComSlice.h:1368
Bool settingsDifferFromDefaults() const
Definition: TComSlice.h:700
ChromaFormat getChromaFormatIdc() const
Definition: TComSlice.h:826
Int getScalingListDC(UInt sizeId, UInt listId) const
get DC value
Definition: TComSlice.h:166
Bool getMotionVectorsOverPicBoundariesFlag() const
Definition: TComSlice.h:656
Bool getTransquantBypassEnabledFlag() const
Definition: TComSlice.h:1142
Int getChromaQpOffsetListLen() const
Definition: TComSlice.h:1010
Int getNumRefIdx(RefPicList e) const
Definition: TComSlice.h:1370
Level::Tier getTierFlag() const
Definition: TComSlice.h:209
ProfileTierLevel * getSubLayerPTL(Int i)
Definition: TComSlice.h:267
Int getChromaSampleLocTypeBottomField() const
Definition: TComSlice.h:631
UInt getTileRowHeight(UInt rowIdx) const
Definition: TComSlice.h:1165
Bool getSubLayerProfilePresentFlag(Int i) const
Definition: TComSlice.h:259
Bool getRefPicListModificationFlagL1() const
Definition: TComSlice.h:962
Bool getFrameOnlyConstraintFlag() const
Definition: TComSlice.h:230
static const Int MAX_VPS_NUM_HRD_PARAMETERS
Definition: CommonDef.h:143
Bool getSaoEnabledFlag(ChannelType chType) const
Definition: TComSlice.h:1339
Bool getLongTermRefsPresent() const
Definition: TComSlice.h:885
Bool getInterlacedSourceFlag() const
Definition: TComSlice.h:224
Bool getSignDataHidingEnabledFlag() const
Definition: TComSlice.h:1168
char TChar
Definition: TypeDef.h:206
TComVUI * getVuiParameters()
Definition: TComSlice.h:936
UInt getDiffCuChromaQpOffsetDepth() const
Definition: TComSlice.h:1006
Bool isInterB() const
Definition: TComSlice.h:1424
Bool getTilesEnabledFlag() const
Definition: TComSlice.h:1155
#define WRITE_FLAG(value,name)
Void codeVPS(const TComVPS *pcVPS)
Definition: TEncCavlc.cpp:646
Int getRefIdc(Int bufferNum) const
get the reference idc value at uiBufferNum
Definition: TComSlice.cpp:1707
Int getDeltaRIdxMinus1() const
Definition: TComSlice.h:116
UInt getLtRefPicPocLsbSps(UInt index) const
Definition: TComSlice.h:845
Bool getFieldSeqFlag() const
Definition: TComSlice.h:637
Bool getDependentSliceSegmentFlag() const
Definition: TComSlice.h:1357
Void codeTilesWPPEntryPoint(TComSlice *pSlice)
Definition: TEncCavlc.cpp:1163
Void codeScalingList(const TComScalingList &scalingList)
Definition: TEncCavlc.cpp:1438
ProfileTierLevel * getGeneralPTL()
Definition: TComSlice.h:265
Bool getListsModificationPresentFlag() const
Definition: TComSlice.h:1186
Bool getLoopFilterAcrossSlicesEnabledFlag() const
Definition: TComSlice.h:1193
Int getSarWidth() const
Definition: TComSlice.h:592
UInt getNumRefIdxL1DefaultActive() const
Definition: TComSlice.h:1132
Bool getTilesFixedStructureFlag() const
Definition: TComSlice.h:653
Void codeTerminatingBit(UInt uilsLast)
Definition: TEncCavlc.cpp:1199
UInt getMaxOpSets() const
Definition: TComSlice.h:504
ChromaFormat getChromaFormatConstraint() const
Definition: TComSlice.h:236
UInt getMaxNumMergeCand() const
Definition: TComSlice.h:1465
Bool getTemporalIdNestingFlag() const
Definition: TComSlice.h:913
Bool getSubLayerLevelPresentFlag(Int i) const
Definition: TComSlice.h:262
Int getMinSpatialSegmentationIdc() const
Definition: TComSlice.h:662
Int getQpBDOffset(ChannelType type) const
Definition: TComSlice.h:904
TComScalingList & getScalingList()
Definition: TComSlice.h:1184
Bool getScalingListPredModeFlag(UInt sizeId, UInt listId) const
Definition: TComSlice.h:169
UInt getLog2SaoOffsetScale(ChannelType type) const
Definition: TComSlice.h:1027
bool Bool
Definition: TypeDef.h:204
Bool getUseTransformSkip() const
Definition: TComSlice.h:1144
const TComReferencePictureSet * getRPS()
Definition: TComSlice.h:1341
Bool getLowerBitRateConstraintFlag() const
Definition: TComSlice.h:245
Bool getSubPicCpbParamsPresentFlag() const
Definition: TComSlice.h:330
Void codeIntraDirLumaAng(TComDataCU *pcCU, UInt absPartIdx, Bool isMultiple)
Definition: TEncCavlc.cpp:1291
static const Int MAX_MATRIX_COEF_NUM
max coefficient number for quantization matrix
Definition: CommonDef.h:235
Bool getRefPicListModificationFlagL0() const
Definition: TComSlice.h:960
Bool getProgressiveSourceFlag() const
Definition: TComSlice.h:221
Bool getColourDescriptionPresentFlag() const
Definition: TComSlice.h:613
Void codeCoeffNxN(TComTU &rTu, TCoeff *pcCoef, const ComponentID compID)
Definition: TEncCavlc.cpp:1338
UInt getQuadtreeTUMaxDepthIntra() const
Definition: TComSlice.h:879
PPS class.
Definition: TComSlice.h:1034
Bool getSubPicCpbParamsInPicTimingSEIFlag() const
Definition: TComSlice.h:339
Bool getOverscanInfoPresentFlag() const
Definition: TComSlice.h:598
UInt getCpbSizeScale() const
Definition: TComSlice.h:348
UInt getPicHeightInLumaSamples() const
Definition: TComSlice.h:836
up-right diagonal scan
Definition: TypeDef.h:475
Bool getCbrFlag(Int layer, Int cpbcnt, Int nalOrVcl) const
Definition: TComSlice.h:386
UInt uiLog2WeightDenom
Definition: TComSlice.h:1206
TimingInfo * getTimingInfo()
Definition: TComSlice.h:511
UInt getNumberOfSubstreamSizes()
Definition: TComSlice.h:1524
Int getDeltaPOC(Int bufferNum) const
Definition: TComSlice.cpp:1670
UInt getPCMLog2MinSize() const
Definition: TComSlice.h:867
Int getMatrixCoefficients() const
Definition: TComSlice.h:622
Int getAspectRatioIdc() const
Definition: TComSlice.h:589
Int getDeltaRPS() const
Definition: TComSlice.h:118
Bool getPocProportionalToTimingFlag() const
Definition: TComSlice.h:417
Bool getTransformSkipRotationEnabledFlag() const
Definition: TComSlice.h:714
UInt getMaxLatencyIncreasePlus1(UInt tlayer) const
Definition: TComSlice.h:928
Reference Picture Set set class.
Definition: TComSlice.h:130
UInt * g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_DEPTH][MAX_CU_DEPTH]
Definition: TComRom.cpp:587
Bool getFrameFieldInfoPresentFlag() const
Definition: TComSlice.h:640
reference list 0
Definition: TypeDef.h:372
Int getBitDepth(ChannelType type) const
Definition: TComSlice.h:894
Bool getTemporalNestingFlag() const
Definition: TComSlice.h:486
Int TCoeff
transform coefficient
Definition: TypeDef.h:250
Void codeInterDir(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1301
Bool getLFCrossSliceBoundaryFlag()
Definition: TComSlice.h:1533
Bool getUseDQP() const
Definition: TComSlice.h:1099
UInt getNumLongTermRefPicSPS() const
Definition: TComSlice.h:842
RefPicList
reference list index
Definition: TypeDef.h:370
Bool getColFromL0Flag() const
Definition: TComSlice.h:1377
Bool getEnableTMVPFlag() const
Definition: TComSlice.h:1536
Bool getCabacBypassAlignmentEnabledFlag() const
Definition: TComSlice.h:735
Int getProfileSpace() const
Definition: TComSlice.h:206
const TComPTL * getPTL() const
Definition: TComSlice.h:938
TComPicSym * getPicSym()
Definition: TComPic.h:111
UInt getMaxCuDQPDepth() const
Definition: TComSlice.h:1107
Void getWpScaling(RefPicList e, Int iRefIdx, WPScalingParam *&wp)
get tables for weighted prediction
Definition: TComSlice.cpp:1405
ChromaFormat
chroma formats (according to semantics of chroma_format_idc)
Definition: TypeDef.h:292
Void codeShortTermRefPicSet(const TComReferencePictureSet *pcRPS, Bool calledFromSliceHeader, Int idx)
Definition: TEncCavlc.cpp:109
UInt getInitialCpbRemovalDelayLengthMinus1() const
Definition: TComSlice.h:353
Bool getTimingInfoPresentFlag() const
Definition: TComSlice.h:408
UInt getQuadtreeTULog2MinSize() const
Definition: TComSlice.h:875
UInt getDpbOutputDelayLengthMinus1() const
Definition: TComSlice.h:359
Void codeHrdParameters(const TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1)
Definition: TEncCavlc.cpp:402
UInt getSliceSegmentCurStartCtuTsAddr() const
Definition: TComSlice.h:1492
COEFF_SCAN_TYPE
coefficient scanning type used in ACS
Definition: TypeDef.h:473
Bool getNoOutputPriorPicsFlag() const
Definition: TComSlice.h:1468
const UInt g_scalingListSize[SCALING_LIST_SIZE_NUM]
Definition: TComRom.cpp:692
Void codeInterModeFlag(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode)
Definition: TEncCavlc.cpp:1232
Bool getAspectRatioInfoPresentFlag() const
Definition: TComSlice.h:586
UInt getNumRefIdxL0DefaultActive() const
Definition: TComSlice.h:1130
const TComPPS * getPPS() const
Definition: TComSlice.h:1332
Int getDeblockingFilterBetaOffsetDiv2() const
get beta offset for deblocking filter
Definition: TComSlice.h:1179
UInt getPicWidthInLumaSamples() const
Definition: TComSlice.h:834
Void codePartSize(TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth)
Definition: TEncCavlc.cpp:1212
Bool getIdrPicFlag() const
Definition: TComSlice.h:1393
Int getLog2MaxMvLengthHorizontal() const
Definition: TComSlice.h:671
UInt getTileColumnWidth(UInt columnIdx) const
Definition: TComSlice.h:1161
Profile::Name getProfileIdc() const
Definition: TComSlice.h:212
Level::Name getLevelIdc() const
Definition: TComSlice.h:218
Bool getUseWP() const
Definition: TComSlice.h:1134
ChromaFormat getChromaFormat() const
Definition: TComPic.h:139
Void codePPS(const TComPPS *pcPPS)
Definition: TEncCavlc.cpp:166
Bool getProfileCompatibilityFlag(Int i) const
Definition: TComSlice.h:215
Bool getIntraSmoothingDisabledFlag() const
Definition: TComSlice.h:726
Bool isIntra() const
Definition: TComSlice.h:1423
Bool getScalingListPresentFlag() const
Definition: TComSlice.h:1182
reference list 1
Definition: TypeDef.h:373
Int getPPSId() const
Definition: TComSlice.h:1092
#define PTL_TRACE_TEXT(txt)
Int getPOC() const
Definition: TComSlice.h:1354
Bool getDeblockingFilterControlPresentFlag() const
Definition: TComSlice.h:1173
Bool getEntropyCodingSyncEnabledFlag() const
Definition: TComSlice.h:1151
TimingInfo * getTimingInfo()
Definition: TComSlice.h:680
TComPTL * getPTL()
Definition: TComSlice.h:509
Int getLog2DiffMaxMinCodingBlockSize() const
Definition: TComSlice.h:853
Bool getVideoSignalTypePresentFlag() const
Definition: TComSlice.h:604
UInt getCpbRemovalDelayLengthMinus1() const
Definition: TComSlice.h:356
Bool getUsePCM() const
Definition: TComSlice.h:863
Void codeRefFrmIdx(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)
Definition: TEncCavlc.cpp:1306
Bool getScalingListFlag() const
Definition: TComSlice.h:920
Definition: TComTU.h:48
Void setCabacInitFlag(Bool val)
set CABAC initial flag
Definition: TComSlice.h:1528
TComPic * getPic()
Definition: TComSlice.h:1371
Int getVideoFormat() const
Definition: TComSlice.h:607
Int getNumberOfReferencePictureSets() const
Definition: TComSlice.h:146
UInt getDpbOutputDelayDuLengthMinus1() const
Definition: TComSlice.h:342
Void codeTransformSkipFlags(TComTU &rTu, ComponentID component)
Definition: TEncCavlc.cpp:1276
Int getColourPrimaries() const
Definition: TComSlice.h:616
Bool getFixedPicRateWithinCvsFlag(Int layer) const
Definition: TComSlice.h:365
Void estBit(estBitsSbacStruct *pcEstBitsSbac, Int width, Int height, ChannelType chType, COEFF_SCAN_TYPE scanType)
Definition: TEncCavlc.cpp:1343
Int getNumberOfNegativePictures() const
Definition: TComSlice.h:107
SliceType getEncCABACTableIdx() const
Definition: TComSlice.h:1539
Bool getRdpcmEnabledFlag(const RDPCMSignallingMode signallingMode) const
Definition: TComSlice.h:720
Bool getUseAMP() const
Definition: TComSlice.h:870
Bool getDependentSliceSegmentsEnabledFlag() const
Definition: TComSlice.h:1149
Int getQpOffset(ComponentID compID) const
Definition: TComSlice.h:1124
static Int getWinUnitX(Int chromaFormatIdc)
Definition: TComSlice.h:829
Int getNumRefIdc() const
Definition: TComSlice.h:120
UInt getDuBitRateValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl) const
Definition: TComSlice.h:384
Void codeSkipFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1242
UInt getBitRateValueMinus1(Int layer, Int cpbcnt, Int nalOrVcl) const
Definition: TComSlice.h:377
UInt getMaxDecPicBuffering(UInt tLayer) const
Definition: TComSlice.h:493
Bool getSliceHeaderExtensionPresentFlag() const
Definition: TComSlice.h:1194
UInt getRefPicSetIdxL1(UInt idx) const
Definition: TComSlice.h:966
Void codeDeltaQP(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1321
Void codeCrossComponentPrediction(TComTU &rTu, ComponentID compID)
Definition: TEncCavlc.cpp:1316
UInt getLog2ParallelMergeLevelMinus2() const
Definition: TComSlice.h:1188
Bool getChromaLocInfoPresentFlag() const
Definition: TComSlice.h:625
#define WRITE_SVLC(value,name)
TComScalingList & getScalingList()
Definition: TComSlice.h:924
int Int
Definition: TypeDef.h:211
Window & getConformanceWindow()
Definition: TComSlice.h:838
const char data[10]
Void codeMVPIdx(TComDataCU *pcCU, UInt uiAbsPartIdx, RefPicList eRefList)
Definition: TEncCavlc.cpp:1207
Void codeVUI(const TComVUI *pcVUI, const TComSPS *pcSPS)
Definition: TEncCavlc.cpp:316
Bool getBitstreamRestrictionFlag() const
Definition: TComSlice.h:650
UInt getPCMBitDepth(ChannelType type) const
Definition: TComSlice.h:915
Void codeIPCMInfo(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1286
Void codeCUTransquantBypassFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1237
UInt getQuadtreeTULog2MaxSize() const
Definition: TComSlice.h:873
UInt getMaxTLayers() const
Definition: TComSlice.h:910
Bool settingsDifferFromDefaults(const bool bTransformSkipEnabledFlag) const
Definition: TComSlice.h:989
ComponentID
Definition: TypeDef.h:308
Int getNumRpsCurrTempList() const
Definition: TComSlice.cpp:469
SPSExtensionFlagIndex
Definition: TypeDef.h:645
Int getSliceChromaQpDelta(ComponentID compID) const
Definition: TComSlice.h:1363
Bool getRapPicFlag() const
Definition: TComSlice.cpp:179
Int getSliceQp() const
Definition: TComSlice.h:1355
Bool getTileUniformSpacingFlag() const
Definition: TComSlice.h:1157
UInt getCpbCntMinus1(Int layer) const
Definition: TComSlice.h:374
Bool getLoopFilterAcrossTilesEnabledFlag() const
Definition: TComSlice.h:1148
Void codeMergeFlag(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1222
UInt getNumReorderPics(UInt tLayer) const
Definition: TComSlice.h:490
UInt getPicDurationInTcMinus1(Int layer) const
Definition: TComSlice.h:368
SChar * getQP()
Definition: TComDataCU.h:258
#define WRITE_UVLC(value,name)
SChar getRefQP(UInt uiCurrAbsIdxInCtu) const
Bool getDeblockingFilterOverrideFlag() const
Definition: TComSlice.h:1366
Bool getConstrainedIntraPred() const
Definition: TComSlice.h:1101
CAVLC encoder class (header)
Bool getChromaQpOffsetListEnabledFlag() const
Definition: TComSlice.h:1009
UInt getColRefIdx() const
Definition: TComSlice.h:1378
Bool getInterRPSPrediction() const
Definition: TComSlice.h:114
Void codeQtRootCbf(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1262
Void codeQtCbf(TComTU &rTu, const ComponentID compID, const Bool lowestLevel)
Definition: TEncCavlc.cpp:1257
UInt getQuadtreeTUMaxDepthInter() const
Definition: TComSlice.h:878
Bool getOverscanAppropriateFlag() const
Definition: TComSlice.h:601
Reference Picture Set class.
Definition: TComSlice.h:65
Bool getDeblockingFilterDisable() const
Definition: TComSlice.h:1365
static UInt getNumberValidComponents(const ChromaFormat fmt)
SPS RExt class.
Definition: TComSlice.h:685
slice header class
Definition: TComSlice.h:1225
Bool isIRAP() const
Definition: TComSlice.h:1394
Void setNumRefIdx(RefPicList e, Int i)
Definition: TComSlice.h:1412
TComHRD * getHrdParameters(UInt i)
Definition: TComSlice.h:470
Void codeMergeIndex(TComDataCU *pcCU, UInt uiAbsPartIdx)
Definition: TEncCavlc.cpp:1227
Bool getWPBiPred() const
Definition: TComSlice.h:1135
static const Int MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1
Definition: CommonDef.h:145
Int getVPSId() const
Definition: TComSlice.h:477
Void codePTL(const TComPTL *pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1)
Definition: TEncCavlc.cpp:1067
Int getDeblockingFilterTcOffsetDiv2() const
get tc offset for deblocking filter
Definition: TComSlice.h:1181
Bool getIntraConstraintFlag() const
Definition: TComSlice.h:239
UInt getNumUnitsInTick() const
Definition: TComSlice.h:411
PPS RExt class.
Definition: TComSlice.h:973
UInt getDuCpbSizeScale() const
Definition: TComSlice.h:350
Int getChromaSampleLocTypeTopField() const
Definition: TComSlice.h:628
Bool getDeblockingFilterOverrideEnabledFlag() const
Definition: TComSlice.h:1175
UInt getRefMatrixId(UInt sizeId, UInt listId) const
get reference matrix ID
Definition: TComSlice.h:160
TComHRD * getHrdParameters()
Definition: TComSlice.h:677
Bool getVuiParametersPresentFlag() const
Definition: TComSlice.h:934
Bool getExtendedPrecisionProcessingFlag() const
Definition: TComSlice.h:723
Int getNumReorderPics(UInt tlayer) const
Definition: TComSlice.h:881
UInt getRefPicSetIdxL0(UInt idx) const
Definition: TComSlice.h:964
UInt getMaxCUWidth() const
Definition: TComSlice.h:857
UInt getBitRateScale() const
Definition: TComSlice.h:345
Bool getOutputFlagPresentFlag() const
Definition: TComSlice.h:1140
Bool findMatchingLTRP(TComSlice *pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag)
Definition: TEncCavlc.cpp:1503
TComSlice * getSlice()
Definition: TComDataCU.h:202
Void codeQtCbfZero(TComTU &rTu, const ChannelType chType)
Definition: TEncCavlc.cpp:1267
const TComSPS * getSPS() const
Definition: TComSlice.h:1329
SPS class.
Definition: TComSlice.h:740
Bool getHighPrecisionOffsetsEnabledFlag() const
Definition: TComSlice.h:729
struct ChromaQpAdj::@2::@3 comp
UInt getTickDivisorMinus2() const
Definition: TComSlice.h:333