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