source: 3DVCSoftware/trunk/source/Lib/TLibEncoder/TEncCavlc.cpp @ 1349

Last change on this file since 1349 was 1321, checked in by tech, 10 years ago

Merged 15.0-dev0@1320.

  • Property svn:eol-style set to native
File size: 110.5 KB
RevLine 
[5]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
[1313]4 * granted under this license.
[5]5 *
[1313]6 * Copyright (c) 2010-2015, ITU/ISO/IEC
[5]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.
[56]17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
[5]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 */
[2]33
34/** \file     TEncCavlc.cpp
35    \brief    CAVLC encoder class
36*/
37
[56]38#include "../TLibCommon/CommonDef.h"
[2]39#include "TEncCavlc.h"
40#include "SEIwrite.h"
[1313]41
[1321]42#if NH_MV
[1179]43#include "TEncTop.h"
44#endif
[1313]45
[56]46//! \ingroup TLibEncoder
47//! \{
[2]48
[56]49#if ENC_DEC_TRACE
50
[1313]51#if !H_MV_ENC_DEC_TRAC
52Void  xTraceVPSHeader ()
[2]53{
[1313]54  fprintf( g_hTrace, "=========== Video Parameter Set     ===========\n" );
[1321]55}
[1313]56
57Void  xTraceSPSHeader ()
58{
59  fprintf( g_hTrace, "=========== Sequence Parameter Set  ===========\n" );
[56]60}
[2]61
[1313]62Void  xTracePPSHeader ()
[56]63{
[1313]64  fprintf( g_hTrace, "=========== Picture Parameter Set  ===========\n");
[2]65}
66
[1313]67Void  xTraceSliceHeader ( )
[56]68{
69  fprintf( g_hTrace, "=========== Slice ===========\n");
70}
[2]71#endif
[1313]72#endif
[56]73// ====================================================================================================================
74// Constructor / destructor / create / destroy
75// ====================================================================================================================
[2]76
[56]77TEncCavlc::TEncCavlc()
[2]78{
[56]79  m_pcBitIf           = NULL;
[2]80}
81
[56]82TEncCavlc::~TEncCavlc()
[2]83{
84}
85
[56]86
87// ====================================================================================================================
88// Public member functions
89// ====================================================================================================================
90
[1313]91Void TEncCavlc::resetEntropy(const TComSlice* /*pSlice*/)
[2]92{
93}
94
95
[1313]96Void TEncCavlc::codeShortTermRefPicSet( const TComReferencePictureSet* rps, Bool calledFromSliceHeader, Int idx)
[42]97{
[56]98#if PRINT_RPS_INFO
[608]99  Int lastBits = getNumberOfWrittenBits();
[2]100#endif
[608]101  if (idx > 0)
102  {
[56]103  WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag
[608]104  }
105  if (rps->getInterRPSPrediction())
[56]106  {
107    Int deltaRPS = rps->getDeltaRPS();
[608]108    if(calledFromSliceHeader)
109    {
110      WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1
111    }
112
[56]113    WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign
114    WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1
[2]115
[56]116    for(Int j=0; j < rps->getNumRefIdc(); j++)
117    {
118      Int refIdc = rps->getRefIdc(j);
[1313]119      WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1
120      if (refIdc != 1)
[56]121      {
122        WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise.
123      }
124    }
[2]125  }
[56]126  else
[2]127  {
[56]128    WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" );
129    WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" );
130    Int prev = 0;
131    for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++)
[2]132    {
[56]133      WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" );
134      prev = rps->getDeltaPOC(j);
[1313]135      WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag");
[2]136    }
[56]137    prev = 0;
138    for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++)
[2]139    {
[56]140      WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" );
141      prev = rps->getDeltaPOC(j);
[1313]142      WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" );
[2]143    }
144  }
[56]145
146#if PRINT_RPS_INFO
147  printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits);
148  rps->printDeltaPOC();
149#endif
[2]150}
151
[56]152
[1313]153Void TEncCavlc::codePPS( const TComPPS* pcPPS )
[2]154{
[1313]155#if ENC_DEC_TRACE
156#if H_MV_ENC_DEC_TRAC
157  tracePSHeader( "PPS", pcPPS->getLayerId() ); 
158#else
159  xTracePPSHeader ();
[42]160#endif
[1313]161#endif
[608]162  WRITE_UVLC( pcPPS->getPPSId(),                             "pps_pic_parameter_set_id" );
163  WRITE_UVLC( pcPPS->getSPSId(),                             "pps_seq_parameter_set_id" );
164  WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag()    ? 1 : 0, "dependent_slice_segments_enabled_flag" );
165  WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0,     "output_flag_present_flag" );
166  WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3,        "num_extra_slice_header_bits");
[56]167  WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" );
168  WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0,   "cabac_init_present_flag" );
[773]169#if PPS_FIX_DEPTH
170  if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
171  {
172    WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive(),     "num_ref_idx_l0_default_active_minus1");
173    WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive(),     "num_ref_idx_l1_default_active_minus1");
174  }
175  else
176  {
177#endif
[608]178  WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1,     "num_ref_idx_l0_default_active_minus1");
179  WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1,     "num_ref_idx_l1_default_active_minus1");
[773]180#if PPS_FIX_DEPTH
181  }
182#endif
[608]183  WRITE_SVLC( pcPPS->getPicInitQPMinus26(),                  "init_qp_minus26");
184  WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0,      "constrained_intra_pred_flag" );
[1313]185  WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0,  "transform_skip_enabled_flag" );
[608]186  WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" );
187  if ( pcPPS->getUseDQP() )
[2]188  {
[608]189    WRITE_UVLC( pcPPS->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth" );
[2]190  }
[1313]191
192  WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" );
193  WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" );
194
[608]195  WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0,          "pps_slice_chroma_qp_offsets_present_flag" );
[2]196
[56]197  WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0,  "weighted_pred_flag" );   // Use of Weighting Prediction (P_SLICE)
[608]198  WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" );  // Use of Weighting Bi-Prediction (B_SLICE)
199  WRITE_FLAG( pcPPS->getTransquantBypassEnableFlag() ? 1 : 0, "transquant_bypass_enable_flag" );
200  WRITE_FLAG( pcPPS->getTilesEnabledFlag()             ? 1 : 0, "tiles_enabled_flag" );
201  WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" );
202  if( pcPPS->getTilesEnabledFlag() )
[56]203  {
[1084]204    WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(),                                    "num_tile_columns_minus1" );
[1313]205    WRITE_UVLC( pcPPS->getNumTileRowsMinus1(),                                       "num_tile_rows_minus1" );
[1084]206    WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(),                                  "uniform_spacing_flag" );
207    if( !pcPPS->getTileUniformSpacingFlag() )
[2]208    {
[1084]209      for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++)
[2]210      {
[1084]211        WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1,                                  "column_width_minus1" );
[2]212      }
[1313]213      for(UInt i=0; i<pcPPS->getNumTileRowsMinus1(); i++)
[2]214      {
[1084]215        WRITE_UVLC( pcPPS->getTileRowHeight(i)-1,                                    "row_height_minus1" );
[2]216      }
217    }
[1313]218    if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getNumTileRowsMinus1() !=0)
[608]219    {
220      WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0,          "loop_filter_across_tiles_enabled_flag");
221    }
[2]222  }
[1313]223  WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0,        "pps_loop_filter_across_slices_enabled_flag");
[608]224  WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0,       "deblocking_filter_control_present_flag");
225  if(pcPPS->getDeblockingFilterControlPresentFlag())
[2]226  {
[1313]227    WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0,  "deblocking_filter_override_enabled_flag" );
[608]228    WRITE_FLAG( pcPPS->getPicDisableDeblockingFilterFlag() ? 1 : 0,       "pps_disable_deblocking_filter_flag" );
229    if(!pcPPS->getPicDisableDeblockingFilterFlag())
230    {
231      WRITE_SVLC( pcPPS->getDeblockingFilterBetaOffsetDiv2(),             "pps_beta_offset_div2" );
232      WRITE_SVLC( pcPPS->getDeblockingFilterTcOffsetDiv2(),               "pps_tc_offset_div2" );
233    }
[2]234  }
[1313]235  WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0,                          "pps_scaling_list_data_present_flag" );
[608]236  if( pcPPS->getScalingListPresentFlag() )
237  {
[1313]238    codeScalingList( pcPPS->getScalingList() );
[608]239  }
[773]240#if PPS_FIX_DEPTH
241  if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
242  {
243    WRITE_FLAG( 1, "lists_modification_present_flag" );
244  }
245  else
246#endif
[608]247  WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag");
[56]248  WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
[872]249  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
[1313]250#if !NH_MV
251  Bool pps_extension_present_flag=false;
252  Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false};
[872]253
[1313]254  pps_extension_flags[PPS_EXT__REXT] = pcPPS->getPpsRangeExtension().settingsDifferFromDefaults(pcPPS->getUseTransformSkip());
255
256  // Other PPS extension flags checked here.
257
258  for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++)
259  {
260    pps_extension_present_flag|=pps_extension_flags[i];
261  }
262
263  WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" );
264
265  if (pps_extension_present_flag)
266  {
267#if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
268    static const char *syntaxStrings[]={ "pps_range_extension_flag",
269                                         "pps_multilayer_extension_flag",
270                                         "pps_extension_6bits[0]",
271                                         "pps_extension_6bits[1]",
272                                         "pps_extension_6bits[2]",
273                                         "pps_extension_6bits[3]",
274                                         "pps_extension_6bits[4]",
275                                         "pps_extension_6bits[5]" };
276#endif
277
278    for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++)
[950]279    {
[1313]280      WRITE_FLAG( pps_extension_flags[i]?1:0, syntaxStrings[i] );
[950]281    }
282
[1313]283    for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
284    {
285      if (pps_extension_flags[i])
286      {
287        switch (PPSExtensionFlagIndex(i))
288        {
289          case PPS_EXT__REXT:
290            {
291              const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension();
292            if (pcPPS->getUseTransformSkip())
293            {
294                WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2,            "log2_max_transform_skip_block_size_minus2");
295            }
296
297              WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" );
298
299              WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()),           "chroma_qp_offset_list_enabled_flag" );
300              if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag())
301            {
302                WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(),                   "diff_cu_chroma_qp_offset_depth");
303                WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1,                   "chroma_qp_offset_list_len_minus1");
304              /* skip zero index */
305                for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++)
306              {
307                  WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset,     "cb_qp_offset_list[i]");
308                  WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset,     "cr_qp_offset_list[i]");
309              }
310            }
311
312              WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA),           "log2_sao_offset_scale_luma"   );
313              WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA),         "log2_sao_offset_scale_chroma" );
314            }
315            break;
316          default:
317            assert(pps_extension_flags[i]==false); // Should never get here with an active PPS extension flag.
318            break;
319        } // switch
320      } // if flag present
321    } // loop over PPS flags
322  } // pps_extension_present_flag is non-zero
[872]323#else
[1313]324    WRITE_FLAG( 1, "pps_extension_present_flag" );
[872]325
[964]326    WRITE_FLAG( pcPPS->getPpsRangeExtensionsFlag( ) ? 1 : 0 , "pps_range_extensions_flag" );
327    WRITE_FLAG( pcPPS->getPpsMultilayerExtensionFlag( ) ? 1 : 0 , "pps_multilayer_extension_flag" );
328    WRITE_FLAG( pcPPS->getPps3dExtensionFlag( ) ? 1 : 0 , "pps_3d_extension_flag" );
329    WRITE_CODE( pcPPS->getPpsExtension5bits( ), 5, "pps_extension_5bits" );
330    if ( pcPPS->getPpsRangeExtensionsFlag() )
331    { 
[1313]332              const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension();
333              if (pcPPS->getUseTransformSkip())
334              {
335                WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2,            "log2_max_transform_skip_block_size_minus2");
336              }
337
338              WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" );
339
340              WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()),           "chroma_qp_offset_list_enabled_flag" );
341              if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag())
342              {
343                WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(),                   "diff_cu_chroma_qp_offset_depth");
344                WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1,                   "chroma_qp_offset_list_len_minus1");
345                /* skip zero index */
346                for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++)
347                {
348                  WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset,     "cb_qp_offset_list[i]");
349                  WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset,     "cr_qp_offset_list[i]");
350                }
351              }
352
353              WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA),           "log2_sao_offset_scale_luma"   );
354              WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA),         "log2_sao_offset_scale_chroma" );
[964]355    }
356
357    if ( pcPPS->getPpsMultilayerExtensionFlag() )
358    { 
[1313]359      codePpsMultilayerExtension( pcPPS );
[964]360    }
361
[1313]362#if NH_3D
[964]363    if( pcPPS->getPps3dExtensionFlag( )  ) // This probably needs to be aligned with Rext and SHVC
364    {
[1313]365      codePps3dExtension( pcPPS ); 
[964]366    }
367#endif
[872]368#endif
[1313]369  xWriteRbspTrailingBits();
[2]370}
371
[1313]372#if NH_3D
373Void  TEncCavlc::codePps3dExtension        ( const TComPPS* pcPPS )
[758]374{
[1313]375#if NH_3D_DLT
376  WRITE_FLAG( pcPPS->getDLT()->getDltPresentFlag() ? 1 : 0, "dlts_present_flag" );
[758]377
[1313]378  if ( pcPPS->getDLT()->getDltPresentFlag() )
[758]379  {
[1313]380    WRITE_CODE(pcPPS->getDLT()->getNumDepthViews() - 1, 6, "pps_depth_layers_minus1");
381    WRITE_CODE((pcPPS->getDLT()->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_layers_minus8");
382   
383    for( Int i = 0; i <= pcPPS->getDLT()->getNumDepthViews()-1; i++ )
[758]384    {
[1313]385      Int layerId = pcPPS->getDLT()->getDepthIdxToLayerId(i);
386     
387      WRITE_FLAG( pcPPS->getDLT()->getUseDLTFlag( layerId ) ? 1 : 0, "dlt_flag[i]" );
388     
389      if ( pcPPS->getDLT()->getUseDLTFlag( layerId ) )
[758]390      {
[1313]391        std::vector<Int> aiIdx2DepthValue_coded(256, 0);
392        UInt uiNumDepthValues_coded = pcPPS->getDLT()->getNumDepthValues(layerId);
393       
394        // ----------------------------- Actual coding -----------------------------
395        WRITE_FLAG( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) ? 1 : 0, "dlt_pred_flag[i]");
396        if ( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) == false )
[758]397        {
[1313]398          WRITE_FLAG( pcPPS->getDLT()->getUseBitmapRep( layerId ) ? 1 : 0, "dlt_val_flags_present_flag[i]" );
399         
400          for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ )
[758]401          {
[1313]402            aiIdx2DepthValue_coded[ui] = pcPPS->getDLT()->idx2DepthValue(layerId, ui);
403          }
404        }
405        else
406        {
407          AOF( layerId > 1 );
408          // assumes ref layer id to be 1
409          std::vector<Int> viRefDLT = pcPPS->getDLT()->idx2DepthValue( 1 );
410          UInt uiRefNum = pcPPS->getDLT()->getNumDepthValues( 1 );
411          pcPPS->getDLT()->getDeltaDLT(layerId, viRefDLT, uiRefNum, aiIdx2DepthValue_coded, uiNumDepthValues_coded);
412        }
413       
414        // bit map coding
415        if ( pcPPS->getDLT()->getUseBitmapRep( layerId ) )
416        {
417          UInt uiDltArrayIndex = 0;
418          for (UInt d=0; d < 256; d++)
419          {
420            if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] )
[758]421            {
[1313]422              WRITE_FLAG(1, "dlt_value_flag[i][j]");
423              uiDltArrayIndex++;
[758]424            }
[1313]425            else
[758]426            {
[1313]427              WRITE_FLAG(0, "dlt_value_flag[i][j]");
[758]428            }
[1313]429          }
430        }
431        // Diff Coding
432        else
433        {
434          UInt uiMaxDiff               = 0;
435          UInt uiMinDiff               = MAX_INT;
436          UInt uiLengthMinDiff         = 0;
437          UInt uiLengthDltDiffMinusMin = 0;
438         
439          std::vector<UInt> puiDltDiffValues(uiNumDepthValues_coded, 0);
440         
441          for (UInt d = 1; d < uiNumDepthValues_coded; d++)
442          {
443            puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1];
444           
445            if ( uiMaxDiff < puiDltDiffValues[d] )
[758]446            {
[1313]447              uiMaxDiff = puiDltDiffValues[d];
[758]448            }
[1313]449           
450            if ( uiMinDiff > puiDltDiffValues[d] )
[758]451            {
[1313]452              uiMinDiff = puiDltDiffValues[d];
[758]453            }
[1313]454          }
455         
456          if ( uiNumDepthValues_coded > 2 )
457          {
458            uiLengthMinDiff    = (UInt) gCeilLog2(uiMaxDiff + 1);
459          }
460          if (uiMaxDiff > uiMinDiff)
461          {
462            uiLengthDltDiffMinusMin = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1);
463          }
464         
465          WRITE_CODE(uiNumDepthValues_coded, 8, "num_val_delta_dlt");    // num_entry
466          {
467            // The condition if( uiNumDepthValues_coded > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component.
[758]468            if ( uiNumDepthValues_coded > 1 )
469            {
[1313]470              WRITE_CODE(uiMaxDiff, 8, "max_diff");        // max_diff
[758]471            }
[1313]472           
[758]473            if ( uiNumDepthValues_coded > 2 )
474            {
[1313]475              WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1");     // min_diff_minus1
[758]476            }
[1313]477           
478            WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "delta_dlt_val0");          // entry0
479           
[758]480            if (uiMaxDiff > uiMinDiff)
481            {
[1313]482              for (UInt d=1; d < uiNumDepthValues_coded; d++)
[758]483              {
[1313]484                WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "delta_val_diff_minus_min[k]");    // entry_value_diff_minus_min[ k ]
[758]485              }
486            }
487          }
[1313]488         
[758]489        }
490      }
491    }
492  }
[1313]493#endif
[758]494}
495#endif
496
[1313]497Void TEncCavlc::codeVUI( const TComVUI *pcVUI, const TComSPS* pcSPS )
[210]498{
[608]499#if ENC_DEC_TRACE
500  fprintf( g_hTrace, "----------- vui_parameters -----------\n");
501#endif
502  WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(),            "aspect_ratio_info_present_flag");
503  if (pcVUI->getAspectRatioInfoPresentFlag())
[210]504  {
[608]505    WRITE_CODE(pcVUI->getAspectRatioIdc(), 8,                   "aspect_ratio_idc" );
506    if (pcVUI->getAspectRatioIdc() == 255)
507    {
508      WRITE_CODE(pcVUI->getSarWidth(), 16,                      "sar_width");
509      WRITE_CODE(pcVUI->getSarHeight(), 16,                     "sar_height");
510    }
[210]511  }
[608]512  WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(),               "overscan_info_present_flag");
513  if (pcVUI->getOverscanInfoPresentFlag())
[210]514  {
[608]515    WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(),             "overscan_appropriate_flag");
[210]516  }
[608]517  WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(),            "video_signal_type_present_flag");
[1313]518#if NH_MV
[738]519  assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); 
520#endif
[608]521  if (pcVUI->getVideoSignalTypePresentFlag())
522  {
523    WRITE_CODE(pcVUI->getVideoFormat(), 3,                      "video_format");
524    WRITE_FLAG(pcVUI->getVideoFullRangeFlag(),                  "video_full_range_flag");
525    WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(),        "colour_description_present_flag");
526    if (pcVUI->getColourDescriptionPresentFlag())
527    {
528      WRITE_CODE(pcVUI->getColourPrimaries(), 8,                "colour_primaries");
529      WRITE_CODE(pcVUI->getTransferCharacteristics(), 8,        "transfer_characteristics");
[1313]530      WRITE_CODE(pcVUI->getMatrixCoefficients(), 8,             "matrix_coeffs");
[608]531    }
532  }
[210]533
[608]534  WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(),              "chroma_loc_info_present_flag");
535  if (pcVUI->getChromaLocInfoPresentFlag())
[210]536  {
[608]537    WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(),         "chroma_sample_loc_type_top_field");
538    WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(),      "chroma_sample_loc_type_bottom_field");
539  }
540
541  WRITE_FLAG(pcVUI->getNeutralChromaIndicationFlag(),           "neutral_chroma_indication_flag");
542  WRITE_FLAG(pcVUI->getFieldSeqFlag(),                          "field_seq_flag");
543  WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(),             "frame_field_info_present_flag");
544
545  Window defaultDisplayWindow = pcVUI->getDefaultDisplayWindow();
546  WRITE_FLAG(defaultDisplayWindow.getWindowEnabledFlag(),       "default_display_window_flag");
547  if( defaultDisplayWindow.getWindowEnabledFlag() )
548  {
[1084]549    WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset");
550    WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset");
551    WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset()   / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset");
552    WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset");
[608]553  }
[1313]554  const TimingInfo *timingInfo = pcVUI->getTimingInfo();
[608]555  WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),          "vui_timing_info_present_flag");
556  if(timingInfo->getTimingInfoPresentFlag())
557  {
558    WRITE_CODE(timingInfo->getNumUnitsInTick(), 32,           "vui_num_units_in_tick");
559    WRITE_CODE(timingInfo->getTimeScale(),      32,           "vui_time_scale");
560    WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(),  "vui_poc_proportional_to_timing_flag");
561    if(timingInfo->getPocProportionalToTimingFlag())
[210]562    {
[608]563      WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),   "vui_num_ticks_poc_diff_one_minus1");
564    }
[1313]565    WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(),              "vui_hrd_parameters_present_flag");
566    if( pcVUI->getHrdParametersPresentFlag() )
567    {
568      codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
569    }
[608]570  }
571
572  WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(),              "bitstream_restriction_flag");
573  if (pcVUI->getBitstreamRestrictionFlag())
574  {
575    WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(),             "tiles_fixed_structure_flag");
576    WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(),  "motion_vectors_over_pic_boundaries_flag");
577    WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(),           "restricted_ref_pic_lists_flag");
578    WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(),           "min_spatial_segmentation_idc");
579    WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(),                 "max_bytes_per_pic_denom");
[1313]580    WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(),                "max_bits_per_min_cu_denom");
[608]581    WRITE_UVLC(pcVUI->getLog2MaxMvLengthHorizontal(),           "log2_max_mv_length_horizontal");
582    WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(),             "log2_max_mv_length_vertical");
583  }
584}
585
[1313]586Void TEncCavlc::codeHrdParameters( const TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 )
[608]587{
588  if( commonInfPresentFlag )
589  {
590    WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 ,  "nal_hrd_parameters_present_flag" );
591    WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 ,  "vcl_hrd_parameters_present_flag" );
592    if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() )
593    {
[1313]594      WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0,  "sub_pic_hrd_params_present_flag" );
[608]595      if( hrd->getSubPicCpbParamsPresentFlag() )
[210]596      {
[608]597        WRITE_CODE( hrd->getTickDivisorMinus2(), 8,              "tick_divisor_minus2" );
[1313]598        WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5,  "du_cpb_removal_delay_increment_length_minus1" );
[608]599        WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" );
600        WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5,   "dpb_output_delay_du_length_minus1"  );
[210]601      }
[608]602      WRITE_CODE( hrd->getBitRateScale(), 4,                     "bit_rate_scale" );
603      WRITE_CODE( hrd->getCpbSizeScale(), 4,                     "cpb_size_scale" );
604      if( hrd->getSubPicCpbParamsPresentFlag() )
605      {
[1313]606        WRITE_CODE( hrd->getDuCpbSizeScale(), 4,                "du_cpb_size_scale" );
[608]607      }
608      WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" );
609      WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(),        5, "au_cpb_removal_delay_length_minus1" );
610      WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(),         5, "dpb_output_delay_length_minus1" );
[210]611    }
612  }
[608]613  Int i, j, nalOrVcl;
614  for( i = 0; i <= maxNumSubLayersMinus1; i ++ )
[210]615  {
[608]616    WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0,          "fixed_pic_rate_general_flag");
[1313]617    Bool fixedPixRateWithinCvsFlag = true;
[608]618    if( !hrd->getFixedPicRateFlag( i ) )
[210]619    {
[1313]620      fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i );
[608]621      WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag");
[210]622    }
[1313]623    if( fixedPixRateWithinCvsFlag )
[210]624    {
[608]625      WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ),           "elemental_duration_in_tc_minus1");
[210]626    }
[608]627    else
[210]628    {
[608]629      WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0,           "low_delay_hrd_flag");
[210]630    }
[608]631    if (!hrd->getLowDelayHrdFlag( i ))
632    {
633      WRITE_UVLC( hrd->getCpbCntMinus1( i ),                      "cpb_cnt_minus1");
634    }
[1313]635
[608]636    for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
[77]637    {
[608]638      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
639          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
[77]640      {
[608]641        for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
[77]642        {
[608]643          WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1");
644          WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1");
645          if( hrd->getSubPicCpbParamsPresentFlag() )
646          {
[1313]647            WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1");
[608]648            WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1");
649          }
650          WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag");
[77]651        }
652      }
653    }
654  }
655}
[608]656
[1313]657Void TEncCavlc::codeSPS( const TComSPS* pcSPS )
[56]658{
[1313]659
660  const ChromaFormat format                = pcSPS->getChromaFormatIdc();
661  const Bool         chromaEnabled         = isChromaEnabled(format);
662
663#if ENC_DEC_TRACE
664#if H_MV_ENC_DEC_TRAC
665  tracePSHeader( "SPS", pcSPS->getLayerId() ); 
666#else
667  xTraceSPSHeader ();
[2]668#endif
[1313]669#endif
[608]670  WRITE_CODE( pcSPS->getVPSId (),          4,       "sps_video_parameter_set_id" );
[1313]671#if NH_MV
[608]672  if ( pcSPS->getLayerId() == 0 )
673  {
[77]674#endif
[608]675  WRITE_CODE( pcSPS->getMaxTLayers() - 1,  3,       "sps_max_sub_layers_minus1" );
[1313]676#if NH_MV
[1066]677  }
678  else
679  {
680    WRITE_CODE( pcSPS->getSpsExtOrMaxSubLayersMinus1( ), 3, "sps_ext_or_max_sub_layers_minus1" );
681  }
682  if ( !pcSPS->getMultiLayerExtSpsFlag() )
683  {
684#endif
[1313]685  WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" );
[608]686  codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
[1313]687#if NH_MV
[608]688}
689#endif
690  WRITE_UVLC( pcSPS->getSPSId (),                   "sps_seq_parameter_set_id" );
[1313]691#if NH_MV
[1066]692    if ( pcSPS->getMultiLayerExtSpsFlag() )
[622]693  {
694    WRITE_FLAG( pcSPS->getUpdateRepFormatFlag( ) ? 1 : 0 , "update_rep_format_flag" );
[738]695    if ( pcSPS->getUpdateRepFormatFlag() )
696    { 
697      WRITE_CODE( pcSPS->getSpsRepFormatIdx( ), 8, "sps_rep_format_idx" );
698    }
[622]699  }
[738]700  else
701  {
[622]702#endif
[1313]703  WRITE_UVLC( Int(pcSPS->getChromaFormatIdc ()),    "chroma_format_idc" );
704  if( format == CHROMA_444 )
[2]705  {
[608]706    WRITE_FLAG( 0,                                  "separate_colour_plane_flag");
[2]707  }
708
[608]709  WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (),   "pic_width_in_luma_samples" );
710  WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(),   "pic_height_in_luma_samples" );
711  Window conf = pcSPS->getConformanceWindow();
[2]712
[608]713  WRITE_FLAG( conf.getWindowEnabledFlag(),          "conformance_window_flag" );
714  if (conf.getWindowEnabledFlag())
[2]715  {
[608]716    WRITE_UVLC( conf.getWindowLeftOffset()   / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
717    WRITE_UVLC( conf.getWindowRightOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
718    WRITE_UVLC( conf.getWindowTopOffset()    / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
719    WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
[2]720  }
[1313]721#if NH_MV
[1066]722}
723#endif
[1313]724#if NH_MV
[1066]725  if ( !pcSPS->getMultiLayerExtSpsFlag() )
[622]726  { 
727#endif
[1313]728
729  WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8,                      "bit_depth_luma_minus8" );
730
731  WRITE_UVLC( chromaEnabled ? (pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) - 8):0,  "bit_depth_chroma_minus8" );
732#if NH_MV
[622]733  }
734#endif
[56]735  WRITE_UVLC( pcSPS->getBitsForPOC()-4,                 "log2_max_pic_order_cnt_lsb_minus4" );
[1313]736#if NH_MV
[1066]737  if ( !pcSPS->getMultiLayerExtSpsFlag()) 
[872]738  { 
739#endif
[1313]740
[608]741  const Bool subLayerOrderingInfoPresentFlag = 1;
742  WRITE_FLAG(subLayerOrderingInfoPresentFlag,       "sps_sub_layer_ordering_info_present_flag");
[56]743  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
[2]744  {
[608]745    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1,       "sps_max_dec_pic_buffering_minus1[i]" );
[1313]746    WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_max_num_reorder_pics[i]" );
[1321]747#if NH_MV
748    WRITE_UVLC( pcSPS->getSpsMaxLatencyIncreasePlus1(i),   "sps_max_latency_increase_plus1[i]" );
749#else
[608]750    WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i),           "sps_max_latency_increase_plus1[i]" );
[1321]751#endif
[608]752    if (!subLayerOrderingInfoPresentFlag)
753    {
754      break;
755    }
[2]756  }
[1313]757#if NH_MV
[872]758  }
759#endif
760
[56]761  assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() );
[1313]762  WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3,                                "log2_min_luma_coding_block_size_minus3" );
763  WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(),                             "log2_diff_max_min_luma_coding_block_size" );
764  WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2,                                 "log2_min_luma_transform_block_size_minus2" );
765  WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_luma_transform_block_size" );
[56]766  WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1,                               "max_transform_hierarchy_depth_inter" );
767  WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1,                               "max_transform_hierarchy_depth_intra" );
[1313]768  WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0,                                   "scaling_list_enabled_flag" );
[608]769  if(pcSPS->getScalingListFlag())
[2]770  {
[1313]771#if NH_MV
[1066]772    if ( pcSPS->getMultiLayerExtSpsFlag() )
[622]773    {   
774      WRITE_FLAG( pcSPS->getSpsInferScalingListFlag( ) ? 1 : 0 , "sps_infer_scaling_list_flag" );
775    }
776
777    if ( pcSPS->getSpsInferScalingListFlag() )
778    {
779      WRITE_CODE( pcSPS->getSpsScalingListRefLayerId( ), 6, "sps_scaling_list_ref_layer_id" );
780    }
781    else
782    {   
783#endif
[1313]784
785    WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0,                          "sps_scaling_list_data_present_flag" );
[608]786    if(pcSPS->getScalingListPresentFlag())
787    {
[1313]788      codeScalingList( pcSPS->getScalingList() );
[608]789    }
[1313]790#if NH_MV
[622]791    }
792#endif
[2]793  }
[608]794  WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0,                                            "amp_enabled_flag" );
795  WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0,                                            "sample_adaptive_offset_enabled_flag");
[2]796
[608]797  WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0,                                            "pcm_enabled_flag");
[56]798  if( pcSPS->getUsePCM() )
[2]799  {
[1313]800    WRITE_CODE( pcSPS->getPCMBitDepth(CHANNEL_TYPE_LUMA) - 1, 4,                            "pcm_sample_bit_depth_luma_minus1" );
801    WRITE_CODE( chromaEnabled ? (pcSPS->getPCMBitDepth(CHANNEL_TYPE_CHROMA) - 1) : 0, 4,    "pcm_sample_bit_depth_chroma_minus1" );
[608]802    WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3,                                      "log2_min_pcm_luma_coding_block_size_minus3" );
803    WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(),             "log2_diff_max_min_pcm_luma_coding_block_size" );
804    WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0,                              "pcm_loop_filter_disable_flag");
[2]805  }
806
[1313]807  assert( pcSPS->getMaxTLayers() > 0 );
[2]808
[1313]809  const TComRPSList* rpsList = pcSPS->getRPSList();
[2]810
[56]811  WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" );
812  for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++)
[2]813  {
[1313]814    const TComReferencePictureSet*rps = rpsList->getReferencePictureSet(i);
815    codeShortTermRefPicSet( rps,false, i);
[608]816  }
[1321]817#if NH_MV
818  WRITE_FLAG( pcSPS->getLongTermRefPicsPresentFlag() ? 1 : 0,         "long_term_ref_pics_present_flag" );
819  if (pcSPS->getLongTermRefPicsPresentFlag())
820#else
[56]821  WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0,         "long_term_ref_pics_present_flag" );
[1313]822  if (pcSPS->getLongTermRefsPresent())
[1321]823#endif
[2]824  {
[1313]825    WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pics_sps" );
[608]826    for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++)
827    {
828      WRITE_CODE( pcSPS->getLtRefPicPocLsbSps(k), pcSPS->getBitsForPOC(), "lt_ref_pic_poc_lsb_sps");
[1313]829      WRITE_FLAG( pcSPS->getUsedByCurrPicLtSPSFlag(k), "used_by_curr_pic_lt_sps_flag[i]");
[608]830    }
[2]831  }
[608]832  WRITE_FLAG( pcSPS->getTMVPFlagsPresent()  ? 1 : 0,           "sps_temporal_mvp_enable_flag" );
[2]833
[608]834  WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(),             "sps_strong_intra_smoothing_enable_flag" );
835
836  WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(),             "vui_parameters_present_flag" );
837  if (pcSPS->getVuiParametersPresentFlag())
[2]838  {
[608]839      codeVUI(pcSPS->getVuiParameters(), pcSPS);
[2]840  }
[608]841
[1313]842#if !NH_MV
843  Bool sps_extension_present_flag=false;
844  Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]={false};
845
846  sps_extension_flags[SPS_EXT__REXT] = pcSPS->getSpsRangeExtension().settingsDifferFromDefaults();
847
848  // Other SPS extension flags checked here.
849
850  for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
851  {
852    sps_extension_present_flag|=sps_extension_flags[i];
853  }
854
855  WRITE_FLAG( (sps_extension_present_flag?1:0), "sps_extension_present_flag" );
856
857  if (sps_extension_present_flag)
858  {
859#if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
860    static const char *syntaxStrings[]={ "sps_range_extension_flag",
861      "sps_multilayer_extension_flag",
862      "sps_extension_6bits[0]",
863      "sps_extension_6bits[1]",
864      "sps_extension_6bits[2]",
865      "sps_extension_6bits[3]",
866      "sps_extension_6bits[4]",
867      "sps_extension_6bits[5]" };
868#endif
869
870    for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
871    {
872      WRITE_FLAG( sps_extension_flags[i]?1:0, syntaxStrings[i] );
873    }
874
875    for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
876    {
877      if (sps_extension_flags[i])
878      {
879        switch (SPSExtensionFlagIndex(i))
880        {
881        case SPS_EXT__REXT:
882          {
883            const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension();
884
885            WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0),      "transform_skip_rotation_enabled_flag");
886            WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0),       "transform_skip_context_enabled_flag");
887            WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" );
888            WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" );
889            WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0),       "extended_precision_processing_flag" );
890            WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0),            "intra_smoothing_disabled_flag" );
891            WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0),       "high_precision_offsets_enabled_flag" );
892            WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0),   "persistent_rice_adaptation_enabled_flag" );
893            WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0),       "cabac_bypass_alignment_enabled_flag" );
894          break;
895          }
896        default:
897          assert(sps_extension_flags[i]==false); // Should never get here with an active SPS extension flag.
898          break;
899        }
900      }
901    }
902  }
[622]903#else
[964]904  WRITE_FLAG( pcSPS->getSpsExtensionPresentFlag(), "sps_extension_present_flag" );
[738]905
[964]906  if ( pcSPS->getSpsExtensionPresentFlag() )
[738]907  {
[1313]908    WRITE_FLAG( pcSPS->getSpsRangeExtensionsFlag( )     ? 1 : 0 , "sps_range_extensions_flag" );
[964]909    WRITE_FLAG( pcSPS->getSpsMultilayerExtensionFlag( ) ? 1 : 0 , "sps_multilayer_extension_flag" );
[1313]910    WRITE_FLAG( pcSPS->getSps3dExtensionFlag( )         ? 1 : 0 , "sps_3d_extension_flag" );
911    WRITE_CODE( pcSPS->getSpsExtension5bits( )              , 5 , "sps_extension_5bits" );
[976]912  }
[964]913
914  if ( pcSPS->getSpsRangeExtensionsFlag() )
915  {
[1313]916    const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension();
917
918    WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0),      "transform_skip_rotation_enabled_flag");
919    WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0),       "transform_skip_context_enabled_flag");
920    WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" );
921    WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" );
922    WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0),       "extended_precision_processing_flag" );
923    WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0),            "intra_smoothing_disabled_flag" );
924    WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0),       "high_precision_offsets_enabled_flag" );
925    WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0),   "persistent_rice_adaptation_enabled_flag" );
926    WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0),       "cabac_bypass_alignment_enabled_flag" );
[964]927  }
928
929  if ( pcSPS->getSpsMultilayerExtensionFlag() )
930  {
931    codeSPSExtension( pcSPS ); 
932  }
933
[1313]934#if NH_3D
[964]935  if ( pcSPS->getSps3dExtensionFlag() )
936  {
[1124]937    codeSPS3dExtension( pcSPS ); 
[964]938  }
939
940#endif
[738]941#endif
[1313]942  xWriteRbspTrailingBits();
[622]943}
[608]944
[1313]945#if NH_MV
946Void TEncCavlc::codeSPSExtension( const TComSPS* pcSPS )
[622]947{
948  WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" );
949}
[1066]950
951
[1313]952Void TEncCavlc::codePpsMultilayerExtension(const TComPPS* pcPPS)
[1066]953{
954  WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag( ) ? 1 : 0 , "poc_reset_info_present_flag" );
955  WRITE_FLAG( pcPPS->getPpsInferScalingListFlag( ) ? 1 : 0 , "pps_infer_scaling_list_flag" );
[1179]956  if (pcPPS->getPpsInferScalingListFlag())
957  {
958    WRITE_CODE( pcPPS->getPpsScalingListRefLayerId( ), 6, "pps_scaling_list_ref_layer_id" );
959  }
[1066]960  WRITE_UVLC( 0, "num_ref_loc_offsets" );
[1124]961  WRITE_FLAG( 0 , "colour_mapping_enabled_flag" );
962
[1066]963}
[622]964
[1066]965#endif
966
[1313]967#if NH_3D
968Void TEncCavlc::codeSPS3dExtension( const TComSPS* pcSPS )
[1124]969{
[1313]970  const TComSps3dExtension* sps3dExt = pcSPS->getSps3dExtension();
[1124]971  for( Int d = 0; d  <=  1; d++ )
972  {
973    WRITE_FLAG( sps3dExt->getIvMvPredFlag( d ) ? 1 : 0 , "iv_mv_pred_flag" );
974    WRITE_FLAG( sps3dExt->getIvMvScalingFlag( d ) ? 1 : 0 , "iv_mv_scaling_flag" );
975    if( d  ==  0 )
976    {
977      WRITE_UVLC( sps3dExt->getLog2SubPbSizeMinus3( d ), "log2_sub_pb_size_minus3" );
978      WRITE_FLAG( sps3dExt->getIvResPredFlag( d ) ? 1 : 0 , "iv_res_pred_flag" );
979      WRITE_FLAG( sps3dExt->getDepthRefinementFlag( d ) ? 1 : 0 , "depth_refinement_flag" );
980      WRITE_FLAG( sps3dExt->getViewSynthesisPredFlag( d ) ? 1 : 0 , "view_synthesis_pred_flag" );
981      WRITE_FLAG( sps3dExt->getDepthBasedBlkPartFlag( d ) ? 1 : 0 , "depth_based_blk_part_flag" );
982    }
983    else 
984    {
985      WRITE_FLAG( sps3dExt->getMpiFlag( d ) ? 1 : 0 , "mpi_flag" );
986      WRITE_UVLC( sps3dExt->getLog2MpiSubPbSizeMinus3( d ), "log2_mpi_sub_pb_size_minus3" );
987      WRITE_FLAG( sps3dExt->getIntraContourFlag( d ) ? 1 : 0 , "intra_contour_flag" );
988      WRITE_FLAG( sps3dExt->getIntraSdcWedgeFlag( d ) ? 1 : 0 , "intra_sdc_wedge_flag" );
989      WRITE_FLAG( sps3dExt->getQtPredFlag( d ) ? 1 : 0 , "qt_pred_flag" );
990      WRITE_FLAG( sps3dExt->getInterSdcFlag( d ) ? 1 : 0 , "inter_sdc_flag" );
[1179]991      WRITE_FLAG( sps3dExt->getDepthIntraSkipFlag( d ) ? 1 : 0 , "intra_skip_flag" );
[1124]992    }
993  }
994}
[622]995#endif
[1066]996
997
[1313]998Void TEncCavlc::codeVPS( const TComVPS* pcVPS )
[608]999{
[1313]1000#if ENC_DEC_TRACE
1001#if H_MV_ENC_DEC_TRAC
1002  tracePSHeader( "VPS", getEncTop()->getLayerId() ); 
1003#else
1004  xTraceVPSHeader();
1005#endif
1006#endif
[608]1007  WRITE_CODE( pcVPS->getVPSId(),                    4,        "vps_video_parameter_set_id" );
[1313]1008#if NH_MV
[964]1009  WRITE_FLAG( pcVPS->getVpsBaseLayerInternalFlag( ) ? 1 : 0 , "vps_base_layer_internal_flag" );
[1066]1010  WRITE_FLAG( pcVPS->getVpsBaseLayerAvailableFlag( ) ? 1 : 0 , "vps_base_layer_available_flag" );
[964]1011#else
[1313]1012  WRITE_FLAG(                                       1,        "vps_base_layer_internal_flag" );
1013  WRITE_FLAG(                                       1,        "vps_base_layer_available_flag" );
[964]1014#endif
[1313]1015#if NH_MV
[622]1016  WRITE_CODE( pcVPS->getMaxLayersMinus1(),       6,        "vps_max_layers_minus1" );
1017#else
[1313]1018  WRITE_CODE( 0,                                    6,        "vps_max_layers_minus1" );
[608]1019#endif
1020  WRITE_CODE( pcVPS->getMaxTLayers() - 1,           3,        "vps_max_sub_layers_minus1" );
1021  WRITE_FLAG( pcVPS->getTemporalNestingFlag(),                "vps_temporal_id_nesting_flag" );
1022  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
[1313]1023  WRITE_CODE( 0xffff,                              16,        "vps_reserved_0xffff_16bits" );
[608]1024  codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 );
1025  const Bool subLayerOrderingInfoPresentFlag = 1;
1026  WRITE_FLAG(subLayerOrderingInfoPresentFlag,              "vps_sub_layer_ordering_info_present_flag");
1027  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
1028  {
1029    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1,       "vps_max_dec_pic_buffering_minus1[i]" );
[1313]1030    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "vps_max_num_reorder_pics[i]" );
[608]1031    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "vps_max_latency_increase_plus1[i]" );
1032    if (!subLayerOrderingInfoPresentFlag)
[2]1033    {
[608]1034      break;
[2]1035    }
1036  }
[1313]1037
[608]1038  assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS );
[1313]1039#if NH_MV
[608]1040  assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 );
1041  WRITE_CODE( pcVPS->getVpsMaxLayerId(), 6,                 "vps_max_layer_id" ); 
[1066]1042  WRITE_UVLC( pcVPS->getVpsNumLayerSetsMinus1(),  "vps_num_layer_sets_minus1" );
[608]1043  for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ )
[2]1044  {
[608]1045    // Operation point set
1046    for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ )
1047    {
1048#else
1049  assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 );
[1313]1050  WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6,     "vps_max_layer_id" );
1051  WRITE_UVLC( pcVPS->getMaxOpSets() - 1,                    "vps_num_layer_sets_minus1" );
[608]1052  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ )
1053  {
1054    // Operation point set
1055    for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
1056    {
1057      // Only applicable for version 1
[1313]1058      // pcVPS->setLayerIdIncludedFlag( true, opsIdx, i );
[608]1059#endif
1060      WRITE_FLAG( pcVPS->getLayerIdIncludedFlag( opsIdx, i ) ? 1 : 0, "layer_id_included_flag[opsIdx][i]" );
1061    }
1062  }
[1313]1063  const TimingInfo *timingInfo = pcVPS->getTimingInfo();
[608]1064  WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(),          "vps_timing_info_present_flag");
1065  if(timingInfo->getTimingInfoPresentFlag())
1066  {
1067    WRITE_CODE(timingInfo->getNumUnitsInTick(), 32,           "vps_num_units_in_tick");
1068    WRITE_CODE(timingInfo->getTimeScale(),      32,           "vps_time_scale");
1069    WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(),  "vps_poc_proportional_to_timing_flag");
1070    if(timingInfo->getPocProportionalToTimingFlag())
1071    {
1072      WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(),   "vps_num_ticks_poc_diff_one_minus1");
1073    }
1074    WRITE_UVLC( pcVPS->getNumHrdParameters(),                 "vps_num_hrd_parameters" );
[56]1075
[608]1076    if( pcVPS->getNumHrdParameters() > 0 )
[56]1077    {
[1313]1078      for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ )
[608]1079      {
[1313]1080        // Only applicable for version 1
1081        WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ),                "hrd_layer_set_idx" );
1082        if( i > 0 )
1083        {
1084          WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" );
1085        }
1086        codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
[608]1087      }
1088    }
[2]1089  }
[1313]1090#if NH_MV
[964]1091  WRITE_FLAG( pcVPS->getVpsExtensionFlag(),                     "vps_extension_flag" );
[622]1092  m_pcBitIf->writeAlignOne();
1093  codeVPSExtension( pcVPS );                           
[1313]1094#if NH_3D
[1124]1095  WRITE_FLAG( 1,                     "vps_extension2_flag" ); 
1096  WRITE_FLAG( 1,                     "vps_3d_extension_flag" );
[622]1097  m_pcBitIf->writeAlignOne();     
[1124]1098  codeVPS3dExtension( pcVPS ); 
[622]1099  WRITE_FLAG( 0,                     "vps_extension3_flag" );
1100#else
1101  WRITE_FLAG( 0,                     "vps_extension2_flag" );
1102#endif
1103#else
1104  WRITE_FLAG( 0,                     "vps_extension_flag" );
1105#endif
[1313]1106
[622]1107  //future extensions here..
[1313]1108  xWriteRbspTrailingBits();
[622]1109}
[2]1110
[1313]1111#if NH_MV
1112Void TEncCavlc::codeVPSExtension( const TComVPS *pcVPS ) 
[1066]1113{ 
1114  if( pcVPS->getMaxLayersMinus1() > 0  &&  pcVPS->getVpsBaseLayerInternalFlag() )
1115  {
1116    codePTL( pcVPS->getPTL( 1 ),0, pcVPS->getMaxSubLayersMinus1()  );
1117  }
1118
[884]1119  WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0,             "splitting_flag" );
[872]1120
[622]1121  for( Int type = 0; type < MAX_NUM_SCALABILITY_TYPES; type++ )
1122  {
1123    WRITE_FLAG( pcVPS->getScalabilityMaskFlag( type ) ? 1 : 0,   "scalability_mask_flag[i]" );
1124  }
1125
1126  for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ )
1127  {
1128    WRITE_CODE( pcVPS->getDimensionIdLen( sIdx ) - 1 , 3,    "dimension_id_len_minus1[j]");   
1129  }
1130
1131  if ( pcVPS->getSplittingFlag() )
[1313]1132  {   
1133    assert( pcVPS->getDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1 ) == pcVPS->inferLastDimsionIdLenMinus1() + 1 );
[622]1134  }   
1135
1136  WRITE_FLAG( pcVPS->getVpsNuhLayerIdPresentFlag() ? 1 : 0,  "vps_nuh_layer_id_present_flag");
1137
1138  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
1139  {
1140    if ( pcVPS->getVpsNuhLayerIdPresentFlag() )
1141    {     
1142      WRITE_CODE( pcVPS->getLayerIdInNuh( i ), 6,          "layer_id_in_nuh[i]");
[884]1143    }
[622]1144    else
1145    {
1146      assert( pcVPS->getLayerIdInNuh( i ) == i ); 
[884]1147    }
[622]1148
1149    assert(  pcVPS->getLayerIdInVps( pcVPS->getLayerIdInNuh( i ) ) == i ); 
1150
1151    for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ )
1152    {
1153      if ( !pcVPS->getSplittingFlag() )
1154      {
1155        WRITE_CODE( pcVPS->getDimensionId( i, j ), pcVPS->getDimensionIdLen( j ), "dimension_id[i][j]");     
1156      }
1157      else
1158      {
1159        assert( pcVPS->getDimensionId( i, j ) ==  pcVPS->inferDimensionId( i, j )  );
1160      }
1161    }
1162  }
1163
[884]1164  WRITE_CODE( pcVPS->getViewIdLen( ), 4, "view_id_len" );
1165
1166  if ( pcVPS->getViewIdLen( ) > 0 )
1167  {   
1168    for( Int i = 0; i < pcVPS->getNumViews(); i++ )
1169    {
1170      WRITE_CODE( pcVPS->getViewIdVal( i ), pcVPS->getViewIdLen( ), "view_id_val[i]" );
[738]1171    }
[884]1172  }
1173  else
1174  {
1175    for( Int i = 0; i < pcVPS->getNumViews(); i++ )
[738]1176    {
[884]1177      assert( pcVPS->getViewIdVal( i ) == 0 ); 
[738]1178    }
[884]1179  }
[622]1180
1181
1182  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
1183  {
1184    for( Int j = 0; j < i; j++ )
1185    {
1186      WRITE_FLAG( pcVPS->getDirectDependencyFlag( i, j ),    "direct_dependency_flag[i][j]" );
1187    }
1188  }
[964]1189
[1066]1190  if ( pcVPS->getNumIndependentLayers() > 1 ) 
1191  {
1192    WRITE_UVLC( pcVPS->getNumAddLayerSets( ), "num_add_layer_sets" );
1193  }
1194  for (Int i = 0; i < pcVPS->getNumAddLayerSets(); i++)
1195  {
1196    for (Int j = 1; j < pcVPS->getNumIndependentLayers(); j++)
1197    {
1198      WRITE_CODE( pcVPS->getHighestLayerIdxPlus1( i, j ), pcVPS->getHighestLayerIdxPlus1Len( j )  , "highest_layer_idx_plus1" );
1199    }
1200 
1201  }
1202
1203
[738]1204  WRITE_FLAG( pcVPS->getVpsSubLayersMaxMinus1PresentFlag( ) ? 1 : 0 , "vps_sub_layers_max_minus1_present_flag" );
1205  if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
1206  {
[872]1207    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
[738]1208    {
1209      WRITE_CODE( pcVPS->getSubLayersVpsMaxMinus1( i ), 3, "sub_layers_vps_max_minus1" );
1210      pcVPS->checkSubLayersVpsMaxMinus1( i ); 
1211    }
1212  } 
1213  else
1214  {
[872]1215    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
[738]1216    {
1217      assert( pcVPS->getSubLayersVpsMaxMinus1( i ) + 1 == pcVPS->getMaxTLayers( ) );   
1218    }
1219  }
[622]1220  WRITE_FLAG( pcVPS->getMaxTidRefPresentFlag( ) ? 1 : 0 , "max_tid_ref_present_flag" );
1221
1222  if ( pcVPS->getMaxTidRefPresentFlag() )
1223  {   
1224    for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
1225    {
[738]1226      for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ )
1227      {
1228        if ( pcVPS->getDirectDependencyFlag(j,i) )
1229        {
1230          WRITE_CODE( pcVPS->getMaxTidIlRefPicsPlus1( i, j ), 3, "max_tid_il_ref_pics_plus1" );
1231        }
1232      }
[622]1233    }
1234  }
1235
1236  WRITE_FLAG( pcVPS->getAllRefLayersActiveFlag( ) ? 1 : 0 , "all_ref_layers_active_flag" );
[872]1237  WRITE_UVLC( pcVPS->getVpsNumProfileTierLevelMinus1( ), "vps_num_profile_tier_level_minus1" );
[622]1238
[1066]1239  Int offsetVal =  ( pcVPS->getMaxLayersMinus1() > 0  &&  pcVPS->getVpsBaseLayerInternalFlag() ) ? 2 : 1;   
1240  for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 2 : 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ )
1241  {
1242    WRITE_FLAG( pcVPS->getVpsProfilePresentFlag( i ) ? 1 : 0, "vps_profile_present_flag[i]" );
1243    codePTL( pcVPS->getPTL( offsetVal ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers() - 1 );
1244    offsetVal++;
1245  }
[622]1246
[1066]1247
[964]1248  if (pcVPS->getNumLayerSets() > 1)
1249  {
1250    WRITE_UVLC( pcVPS->getNumAddOlss( ), "num_add_olss" );
1251    WRITE_CODE( pcVPS->getDefaultOutputLayerIdc( ), 2, "default_output_layer_idc" );
1252  }
[872]1253
[738]1254  assert( pcVPS->getOutputLayerFlag(0, 0) == pcVPS->inferOutputLayerFlag( 0, 0 )); 
[964]1255  assert( pcVPS->getLayerSetIdxForOlsMinus1( 0 ) == -1 ); 
[872]1256
[964]1257
[1066]1258  if (pcVPS->getVpsBaseLayerInternalFlag() )
1259  { 
1260    assert( pcVPS->getProfileTierLevelIdx(0,0) == pcVPS->inferProfileTierLevelIdx(0,0) );
1261  }
[964]1262
1263
[872]1264  for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ )
1265  {
[1124]1266    if( pcVPS->getNumLayerSets() > 2 && i >= pcVPS->getNumLayerSets( ) )   
[622]1267    {     
[1066]1268      WRITE_CODE( pcVPS->getLayerSetIdxForOlsMinus1( i ), pcVPS->getLayerSetIdxForOlsMinus1Len( i ) ,      "layer_set_idx_for_ols_minus1[i]" );
[872]1269    }
1270
[964]1271    if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultOutputLayerIdc() == 2 )
[872]1272    {       
[964]1273      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ )
[872]1274      {
1275        WRITE_FLAG( pcVPS->getOutputLayerFlag( i, j) ? 1 : 0, "output_layer_flag" );
1276      }             
1277    }
1278    else
1279    {
[964]1280      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ) - 1; j++ )
[872]1281      {             
1282        assert( pcVPS->getOutputLayerFlag( i , j ) == pcVPS->inferOutputLayerFlag( i, j )); 
1283      }
1284    }       
[1066]1285       
1286    for ( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx(i)); j++ )
1287    {   
1288      if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() > 0 )
1289      {
1290        WRITE_CODE( pcVPS->getProfileTierLevelIdx( i, j ), pcVPS->getProfileTierLevelIdxLen() ,"profile_tier_level_idx[ i ][ j ]" );   
1291      }
1292      if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() == 0 )
1293      {
1294        assert( pcVPS->getProfileTierLevelIdx( i , j ) == pcVPS->inferProfileTierLevelIdx( i, j ) );
1295      }
[872]1296
[1066]1297    }
[872]1298    if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 )
1299    {
1300      WRITE_FLAG( pcVPS->getAltOutputLayerFlag( i ) ? 1 : 0 , "alt_output_layer_flag[ i ]" );
1301    }
[622]1302  }
1303
[964]1304  WRITE_UVLC( pcVPS->getVpsNumRepFormatsMinus1( ), "vps_num_rep_formats_minus1" );
[622]1305
1306  for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
1307  {   
[1313]1308    const TComRepFormat* curRepFormat = pcVPS->getRepFormat(i);     
1309    const TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 
[738]1310    codeRepFormat( i, curRepFormat ,  prevRepFormat); 
[622]1311  }
1312
[964]1313  if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
1314  {
1315    WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" );
1316  }
[976]1317
[622]1318  if( pcVPS->getRepFormatIdxPresentFlag() ) 
1319  {
[964]1320    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
[622]1321    {
[872]1322        WRITE_CODE( pcVPS->getVpsRepFormatIdx(i), pcVPS->getVpsRepFormatIdxLen(), "vps_rep_format_idx[i]" );
[622]1323    }
1324  }
[964]1325  else
1326  {
1327    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
1328    {
1329      assert( pcVPS->getVpsRepFormatIdx( i ) ==  pcVPS->inferVpsRepFormatIdx( i ) );
1330    }
1331  }
[622]1332
1333  WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" );
[872]1334  WRITE_FLAG( pcVPS->getVpsPocLsbAlignedFlag( ) ? 1 : 0 , "vps_poc_lsb_aligned_flag" );
[738]1335  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
1336  {
1337    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) )  ==  0 )
1338    {     
1339      WRITE_FLAG( pcVPS->getPocLsbNotPresentFlag( i ) ? 1 : 0 , "poc_lsb_not_present_flag" );
1340    }
1341  }
[964]1342
[738]1343  codeDpbSize( pcVPS ); 
1344
[622]1345  WRITE_UVLC( pcVPS->getDirectDepTypeLenMinus2 ( ),         "direct_dep_type_len_minus2"); 
1346
[738]1347  WRITE_FLAG( pcVPS->getDefaultDirectDependencyFlag( ) ? 1 : 0 , "default_direct_dependency_flag" );
1348  if ( pcVPS->getDefaultDirectDependencyFlag( ) )
1349  { 
1350    WRITE_CODE( pcVPS->getDefaultDirectDependencyType( ), pcVPS->getDirectDepTypeLenMinus2( ) + 2 , "default_direct_dependency_type" );   
1351  }
1352
[964]1353  for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ?  1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ )
1354  {
1355    for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ?  0 : 1; j < i; j++ )
[738]1356    {
1357      if (pcVPS->getDirectDependencyFlag( i, j) )
1358      {       
1359        if ( pcVPS->getDefaultDirectDependencyFlag( ) )
1360        { 
1361          assert( pcVPS->getDirectDependencyType( i, j ) == pcVPS->getDefaultDirectDependencyType( ) );
1362        }
1363        else
1364        {
1365          assert ( pcVPS->getDirectDependencyType( i, j ) != -1 ); 
1366          WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2,  "direct_dependency_type[i][j]" );
1367        }
1368      }
1369    }
1370  } 
[872]1371  WRITE_UVLC( 0, "vps_non_vui_extension_length" );
[964]1372 
1373
1374
1375
[976]1376  WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" );
[884]1377  if( pcVPS->getVpsVuiPresentFlag() )
1378  {
1379    m_pcBitIf->writeAlignOne();  // vps_vui_alignment_bit_equal_to_one
1380    codeVPSVUI( pcVPS ); 
1381  }     
[1124]1382  else
[884]1383  {
[1313]1384    const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
[884]1385    assert( pcVPSVUI ); 
[1313]1386    assert( !pcVPSVUI->getCrossLayerIrapAlignedFlag() );     
[884]1387  }
[964]1388
[622]1389}
[884]1390
[1313]1391Void TEncCavlc::codeVideoSignalInfo( const TComVideoSignalInfo* pcVideoSignalInfo )
[738]1392{
1393  assert( pcVideoSignalInfo ); 
1394  WRITE_CODE( pcVideoSignalInfo->getVideoVpsFormat( ), 3, "video_vps_format" );
1395  WRITE_FLAG( pcVideoSignalInfo->getVideoFullRangeVpsFlag( ) ? 1 : 0 , "video_full_range_vps_flag" );
1396  WRITE_CODE( pcVideoSignalInfo->getColourPrimariesVps( ), 8, "colour_primaries_vps" );
1397  WRITE_CODE( pcVideoSignalInfo->getTransferCharacteristicsVps( ), 8, "transfer_characteristics_vps" );
1398  WRITE_CODE( pcVideoSignalInfo->getMatrixCoeffsVps( ), 8, "matrix_coeffs_vps" );
1399}
[622]1400
[1313]1401Void TEncCavlc::codeDpbSize( const TComVPS* vps )
[738]1402{ 
[1313]1403  const TComDpbSize * dpbSize = vps->getDpbSize(); 
[738]1404
1405  for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ )
1406  { 
[964]1407    Int currLsIdx = vps->olsIdxToLsIdx( i ); 
[738]1408    WRITE_FLAG( dpbSize->getSubLayerFlagInfoPresentFlag( i ) ? 1 : 0 , "sub_layer_flag_info_present_flag" );
[964]1409    for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ )
[738]1410    { 
1411      if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  ) 
1412      {
1413        WRITE_FLAG( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ? 1 : 0 , "sub_layer_dpb_info_present_flag" );
1414      }
1415      if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
1416      { 
[964]1417        for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ )   
[738]1418        {
[1066]1419          if ( vps->getNecessaryLayerFlag( i, k ) && ( vps->getVpsBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(vps->olsIdxToLsIdx(i),k) != 0 ) ))
1420          {
1421            WRITE_UVLC( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ), "max_vps_dec_pic_buffering_minus1" );
1422          }
1423          else
1424          {
1425            if ( vps->getNecessaryLayerFlag( i, k ) && ( j == 0 ) && ( k == 0 ) ) 
1426            {
1427              assert( dpbSize->getMaxVpsDecPicBufferingMinus1(i ,k, j ) ==  0 );
1428            }
1429          }
[738]1430        }
1431        WRITE_UVLC( dpbSize->getMaxVpsNumReorderPics( i, j ), "max_vps_num_reorder_pics" );
1432        WRITE_UVLC( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ), "max_vps_latency_increase_plus1" );
1433      }
1434      else
1435      {
1436        if ( j > 0 )
1437        {
[964]1438          for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ )   
[738]1439          {
[1066]1440            if ( vps->getNecessaryLayerFlag(i, k ) )
1441            {           
1442              assert( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) == dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
1443            }
[738]1444          }
1445          assert( dpbSize->getMaxVpsNumReorderPics      ( i, j ) ==  dpbSize->getMaxVpsNumReorderPics      ( i, j - 1 ) );
1446          assert( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) ==  dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) );
1447        }
1448      }
[964]1449    }
1450  }
[738]1451}
1452
[1313]1453Void TEncCavlc::codeRepFormat( Int i, const TComRepFormat* pcRepFormat, const TComRepFormat* pcPrevRepFormat )
[622]1454{
1455  assert( pcRepFormat ); 
1456
[738]1457  WRITE_CODE( pcRepFormat->getPicWidthVpsInLumaSamples( ),  16, "pic_width_vps_in_luma_samples" );
1458  WRITE_CODE( pcRepFormat->getPicHeightVpsInLumaSamples( ), 16, "pic_height_vps_in_luma_samples" );
1459  WRITE_FLAG( pcRepFormat->getChromaAndBitDepthVpsPresentFlag( ) ? 1 : 0 , "chroma_and_bit_depth_vps_present_flag" );
1460 
1461  pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); 
1462
1463  if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() )
1464  { 
[1179]1465    WRITE_CODE( pcRepFormat->getChromaFormatVpsIdc( ), 2, "chroma_format_vps_idc" ); 
[622]1466
[1179]1467    if ( pcRepFormat->getChromaFormatVpsIdc() == 3 )
1468    {
1469      WRITE_FLAG( pcRepFormat->getSeparateColourPlaneVpsFlag( ) ? 1 : 0 , "separate_colour_plane_vps_flag" );
1470    }
1471    WRITE_CODE( pcRepFormat->getBitDepthVpsLumaMinus8( ),      4, "bit_depth_vps_luma_minus8" );
1472    WRITE_CODE( pcRepFormat->getBitDepthVpsChromaMinus8( ),    4, "bit_depth_vps_chroma_minus8" );
[622]1473  }
[738]1474  else
1475  {
[1313]1476    pcRepFormat->checkInferChromaAndBitDepth(pcPrevRepFormat ); 
[738]1477  }
[1066]1478  WRITE_FLAG( pcRepFormat->getConformanceWindowVpsFlag( ) ? 1 : 0 , "conformance_window_vps_flag" );
1479  if ( pcRepFormat->getConformanceWindowVpsFlag() )
1480  {   
1481    WRITE_UVLC( pcRepFormat->getConfWinVpsLeftOffset( ), "conf_win_vps_left_offset" );
1482    WRITE_UVLC( pcRepFormat->getConfWinVpsRightOffset( ), "conf_win_vps_right_offset" );
1483    WRITE_UVLC( pcRepFormat->getConfWinVpsTopOffset( ), "conf_win_vps_top_offset" );
1484    WRITE_UVLC( pcRepFormat->getConfWinVpsBottomOffset( ), "conf_win_vps_bottom_offset" );
1485  }
[622]1486}
1487
[1313]1488Void TEncCavlc::codeVPSVUI( const TComVPS* pcVPS )
[622]1489{
1490  assert( pcVPS ); 
1491
[1313]1492  const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
[622]1493
1494  assert( pcVPSVUI ); 
1495
[964]1496
[738]1497  WRITE_FLAG( pcVPSVUI->getCrossLayerPicTypeAlignedFlag( ) ? 1 : 0 , "cross_layer_pic_type_aligned_flag" );
1498  if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() )
1499  { 
1500    WRITE_FLAG( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" );
1501  }
[872]1502  if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) )
1503  {
1504    WRITE_FLAG( pcVPSVUI->getAllLayersIdrAlignedFlag( ) ? 1 : 0 , "all_layers_idr_aligned_flag" );
1505  }
[622]1506  WRITE_FLAG( pcVPSVUI->getBitRatePresentVpsFlag( ) ? 1 : 0 , "bit_rate_present_vps_flag" );
1507  WRITE_FLAG( pcVPSVUI->getPicRatePresentVpsFlag( ) ? 1 : 0 , "pic_rate_present_vps_flag" );
1508  if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
1509  {
[1066]1510    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i < pcVPS->getNumLayerSets(); i++ )
[622]1511    {
[964]1512      for( Int j = 0; j  <=  pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) 
[622]1513      {
1514        if( pcVPSVUI->getBitRatePresentVpsFlag( ) )
1515        {
1516          WRITE_FLAG( pcVPSVUI->getBitRatePresentFlag( i, j ) ? 1 : 0 , "bit_rate_present_flag" );
1517        }
1518        if( pcVPSVUI->getBitRatePresentVpsFlag( )  )
1519        {
1520          WRITE_FLAG( pcVPSVUI->getPicRatePresentFlag( i, j ) ? 1 : 0 , "pic_rate_present_flag" );
1521        }
1522        if( pcVPSVUI->getBitRatePresentFlag( i, j ) )
1523        {
1524          WRITE_CODE( pcVPSVUI->getAvgBitRate( i, j ), 16, "avg_bit_rate" );
1525          WRITE_CODE( pcVPSVUI->getMaxBitRate( i, j ), 16, "max_bit_rate" );
1526        }
1527        if( pcVPSVUI->getPicRatePresentFlag( i, j ) )
1528        {
1529          WRITE_CODE( pcVPSVUI->getConstantPicRateIdc( i, j ), 2, "constant_pic_rate_idc" );
1530          WRITE_CODE( pcVPSVUI->getAvgPicRate( i, j ), 16, "avg_pic_rate" );
1531        }
1532      }
1533    }
1534  }
1535
[872]1536  WRITE_FLAG( pcVPSVUI->getVideoSignalInfoIdxPresentFlag( ) ? 1 : 0 , "video_signal_info_idx_present_flag" );
1537  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
1538  {
1539    WRITE_CODE( pcVPSVUI->getVpsNumVideoSignalInfoMinus1( ), 4, "vps_num_video_signal_info_minus1" );
1540  }
1541  else
1542  {
[1066]1543    assert( pcVPSVUI->getVpsNumVideoSignalInfoMinus1() == pcVPS->getMaxLayersMinus1() - ( pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1)  ); 
[872]1544  }
1545
1546  for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ )
1547  {
1548    assert( pcVPSVUI->getVideoSignalInfo( i ) != NULL ); 
[1313]1549    const TComVideoSignalInfo* curVideoSignalInfo = pcVPSVUI->getVideoSignalInfo( i ); 
[872]1550    codeVideoSignalInfo( curVideoSignalInfo );     
1551
1552  }
1553
1554  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
1555  {
[1066]1556    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
1557    {
1558      WRITE_CODE( pcVPSVUI->getVpsVideoSignalInfoIdx( i ), 4, "vps_video_signal_info_idx" );
1559    }
[872]1560  }
[738]1561  WRITE_FLAG( pcVPSVUI->getTilesNotInUseFlag( ) ? 1 : 0 , "tiles_not_in_use_flag" );
1562  if( !pcVPSVUI->getTilesNotInUseFlag() ) 
1563  {     
[964]1564    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
[738]1565    {
1566      WRITE_FLAG( pcVPSVUI->getTilesInUseFlag( i ) ? 1 : 0 , "tiles_in_use_flag[i]" );
1567      if( pcVPSVUI->getTilesInUseFlag( i ) ) 
1568      {
1569        WRITE_FLAG( pcVPSVUI->getLoopFilterNotAcrossTilesFlag( i ) ? 1 : 0, "loop_filter_not_across_tiles_flag[i]" );
1570      }
1571    } 
[964]1572    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i  <=  pcVPS->getMaxLayersMinus1(); i++ ) 
[738]1573    {
1574      for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ )
1575      { 
[1066]1576        Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getIdRefLayer(pcVPS->getLayerIdInNuh( i ) , j  )); 
[738]1577        if( pcVPSVUI->getTilesInUseFlag( i )  &&  pcVPSVUI->getTilesInUseFlag( layerIdx ) ) 
1578        {
1579          WRITE_FLAG( pcVPSVUI->getTileBoundariesAlignedFlag( i, j ) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" );
1580        }
1581      } 
1582    }
1583  } 
1584
1585  WRITE_FLAG( pcVPSVUI->getWppNotInUseFlag( ) ? 1 : 0 , "wpp_not_in_use_flag" );
1586
1587  if( !pcVPSVUI->getWppNotInUseFlag( ) )
1588  {
1589    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ ) 
1590    {
1591      WRITE_FLAG( pcVPSVUI->getWppInUseFlag( i ) ? 1 : 0 , "wpp_in_use_flag[i]" );
1592    }
1593  }
[1066]1594  WRITE_FLAG( pcVPSVUI->getSingleLayerForNonIrapFlag( ) ? 1 : 0 , "single_layer_for_non_irap_flag" );
1595  WRITE_FLAG( pcVPSVUI->getHigherLayerIrapSkipFlag( ) ? 1 : 0 , "higher_layer_irap_skip_flag" );
[622]1596  WRITE_FLAG( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ? 1 : 0 , "ilp_restricted_ref_layers_flag" );
1597
1598  if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) )
1599  {
1600    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
1601    {
1602      for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ )
1603      {
[1066]1604        if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getIdRefLayer( pcVPS->getLayerIdInNuh( i ), j ) > 0 )
[964]1605        {       
[976]1606          WRITE_UVLC( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ), "min_spatial_segment_offset_plus1" );
1607          if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
[622]1608          {
[976]1609            WRITE_FLAG( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ? 1 : 0 , "ctu_based_offset_enabled_flag" );
1610            if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) )
1611            {
1612              WRITE_UVLC( pcVPSVUI->getMinHorizontalCtuOffsetPlus1( i, j ), "min_horizontal_ctu_offset_plus1" );
1613            }
[622]1614          }
1615        }
1616      }
1617    }
1618  }
[872]1619
[738]1620
1621  WRITE_FLAG( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ? 1 : 0 , "vps_vui_bsp_hrd_present_flag" );
1622  if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
1623  {
1624    codeVpsVuiBspHrdParameters( pcVPS ); 
1625  }
[872]1626  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
1627  {
1628    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) 
1629    {
1630      WRITE_FLAG( pcVPSVUI->getBaseLayerParameterSetCompatibilityFlag( i ) ? 1 : 0 , "base_layer_parameter_set_compatibility_flag" );
1631    }
[884]1632  }
[738]1633}
[872]1634
[1313]1635Void TEncCavlc::codeVpsVuiBspHrdParameters( const TComVPS* pcVPS )
[738]1636{
1637  assert( pcVPS ); 
[622]1638
[1313]1639  const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
[738]1640
1641  assert( pcVPSVUI ); 
1642
[1313]1643  const TComVpsVuiBspHrdParameters*  vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); 
[738]1644
1645  assert ( vpsVuiBspHrdP );
[1066]1646 
1647  WRITE_UVLC( vpsVuiBspHrdP->getVpsNumAddHrdParams( ), "vps_num_add_hrd_params" );
[738]1648
[1066]1649  for( Int i = pcVPS->getNumHrdParameters(); i < pcVPS->getNumHrdParameters() + vpsVuiBspHrdP->getVpsNumAddHrdParams(); i++ )
1650  { 
1651    if( i > 0 ) 
1652    {
1653      WRITE_FLAG( vpsVuiBspHrdP->getCprmsAddPresentFlag( i ) ? 1 : 0 , "cprms_add_present_flag" );
1654    }
1655    WRITE_UVLC( vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ), "num_sub_layer_hrd_minus1" );
[1313]1656    const TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); 
[1066]1657    codeHrdParameters( hrdParameters, vpsVuiBspHrdP->getCprmsAddPresentFlag( i ), vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ) );     
1658  }
1659
1660  for( Int h = 1; h < pcVPS->getNumOutputLayerSets(); h++ )
1661  { 
1662    WRITE_UVLC( vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ), "num_signalled_partitioning_schemes" );
1663
1664    for( Int j = 1; j < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; j++ )
1665    { 
1666      WRITE_UVLC( vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ), "num_partitions_in_scheme_minus1" );
1667      for( Int k = 0; k  <=  vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ ) 
1668      {
1669        for( Int r = 0; r < pcVPS->getNumLayersInIdList(pcVPS->olsIdxToLsIdx( h ) )   ; r++ ) 
1670        {
1671          WRITE_FLAG( vpsVuiBspHrdP->getLayerIncludedInPartitionFlag( h, j, k, r ) ? 1 : 0 , "layer_included_in_partition_flag" );
1672        }
1673      }
1674    } 
1675    for( Int i = 0; i < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; i++ ) 
1676    {
1677      for( Int t = 0; t  <=  pcVPS->getMaxSubLayersInLayerSetMinus1( pcVPS->olsIdxToLsIdx( h ) ); t++ )
1678      { 
1679        WRITE_UVLC( vpsVuiBspHrdP->getNumBspSchedulesMinus1( h, i, t ), "num_bsp_schedules_minus1" );
1680        for( Int j = 0; j  <=  vpsVuiBspHrdP->getNumBspSchedulesMinus1( h, i, t ); j++ ) 
1681        {
1682          for( Int k = 0; k  <=  vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ )
1683          { 
1684            WRITE_CODE( vpsVuiBspHrdP->getBspHrdIdx( h, i, t, j, k ), vpsVuiBspHrdP->getBspHrdIdxLen( pcVPS ), "bsp_hrd_idx" );
1685            WRITE_UVLC( vpsVuiBspHrdP->getBspSchedIdx( h, i, t, j, k ), "bsp_sched_idx" );
1686          } 
1687        }
1688      } 
1689    }
1690  } 
[738]1691} 
1692#endif
1693
[1313]1694#if NH_3D
1695Void TEncCavlc::codeVPS3dExtension( const TComVPS* pcVPS )
[622]1696{ 
[1179]1697  WRITE_UVLC( pcVPS->getCpPrecision( ), "cp_precision" );
1698  for (Int n = 1; n < pcVPS->getNumViews(); n++)
1699  {
1700    Int i      = pcVPS->getViewOIdxList( n );
1701    Int iInVps = pcVPS->getVoiInVps( i ); 
1702    WRITE_CODE( pcVPS->getNumCp( iInVps ), 6, "num_cp" );
1703
1704    if( pcVPS->getNumCp( iInVps ) > 0 )
1705    {
1706      WRITE_FLAG( pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) ? 1 : 0 , "cp_in_slice_segment_header_flag" );
1707      for( Int m = 0; m < pcVPS->getNumCp( iInVps ); m++ )
1708      {
1709        WRITE_UVLC( pcVPS->getCpRefVoi( iInVps, m ), "cp_ref_voi" );
1710        if( !pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) )
1711        {
1712          Int j      = pcVPS->getCpRefVoi( iInVps, m );
1713          Int jInVps = pcVPS->getVoiInVps( j ); 
1714          WRITE_SVLC( pcVPS->getVpsCpScale   ( iInVps, jInVps ), "vps_cp_scale" );
1715          WRITE_SVLC( pcVPS->getVpsCpOff     ( iInVps, jInVps ), "vps_cp_off" );
1716          WRITE_SVLC( pcVPS->getVpsCpInvScale( iInVps, jInVps ) + pcVPS->getVpsCpScale( iInVps, jInVps ), "vps_cp_inv_scale_plus_scale" );
1717          WRITE_SVLC( pcVPS->getVpsCpInvOff  ( iInVps, jInVps ) + pcVPS->getVpsCpOff  ( iInVps, jInVps ), "vps_cp_inv_off_plus_off" );
1718        }
1719      }
1720    }
1721  } 
[622]1722}
1723#endif
1724
[1313]1725
[56]1726Void TEncCavlc::codeSliceHeader         ( TComSlice* pcSlice )
[2]1727{
[1313]1728#if NH_MV
1729  const TComVPS* vps = pcSlice->getVPS(); 
[608]1730#endif
[1313]1731
1732#if ENC_DEC_TRACE
1733#if NH_MV
1734  tracePSHeader( "Slice", pcSlice->getLayerId() ); 
1735#else
1736  xTraceSliceHeader ();
[2]1737#endif
[1313]1738#endif
[2]1739
[1313]1740  const ChromaFormat format                = pcSlice->getSPS()->getChromaFormatIdc();
1741  const UInt         numberValidComponents = getNumberValidComponents(format);
1742  const Bool         chromaEnabled         = isChromaEnabled(format);
1743
[56]1744  //calculate number of bits required for slice address
[1313]1745  Int maxSliceSegmentAddress = pcSlice->getPic()->getNumberOfCtusInFrame();
[608]1746  Int bitsSliceSegmentAddress = 0;
[1313]1747  while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress))
[2]1748  {
[608]1749    bitsSliceSegmentAddress++;
[2]1750  }
[1313]1751  const Int ctuTsAddress = pcSlice->getSliceSegmentCurStartCtuTsAddr();
1752
[56]1753  //write slice address
[1313]1754  const Int sliceSegmentRsAddress = pcSlice->getPic()->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddress);
[1321]1755#if NH_MV
1756  // This should actually be done somewhere else and not in writing process.
1757  pcSlice->setFirstSliceSegementInPicFlag( sliceSegmentRsAddress==0 ); 
1758  WRITE_FLAG( pcSlice->getFirstSliceSegementInPicFlag() , "first_slice_segment_in_pic_flag" );
1759#else
[1313]1760  WRITE_FLAG( sliceSegmentRsAddress==0, "first_slice_segment_in_pic_flag" );
[1321]1761#endif
[608]1762  if ( pcSlice->getRapPicFlag() )
[189]1763  {
[964]1764    WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" );
[608]1765  }
[773]1766#if PPS_FIX_DEPTH
1767  if( pcSlice->getIsDepth() )
1768  {
1769    WRITE_UVLC( 1, "slice_pic_parameter_set_id" );
1770  }
1771  else
1772#endif
[608]1773  WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" );
[1313]1774  if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) )
[608]1775  {
1776    WRITE_FLAG( pcSlice->getDependentSliceSegmentFlag() ? 1 : 0, "dependent_slice_segment_flag" );
1777  }
[1313]1778  if(sliceSegmentRsAddress>0)
[608]1779  {
[1313]1780    WRITE_CODE( sliceSegmentRsAddress, bitsSliceSegmentAddress, "slice_segment_address" );
[608]1781  }
1782  if ( !pcSlice->getDependentSliceSegmentFlag() )
1783  {
[1313]1784#if NH_MV   
[622]1785    Int esb = 0;  //Don't use i, otherwise will shadow something below
1786
1787    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
1788    {
1789      esb++; 
1790      WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" );
[1066]1791      if (pcSlice->getDiscardableFlag( ))
1792      {
1793        assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R &&
1794          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R &&
1795          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R &&
1796          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R &&
1797          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R);
1798      }
[622]1799    }
1800
[738]1801    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
1802    {
1803      esb++; 
1804      WRITE_FLAG( pcSlice->getCrossLayerBlaFlag( ) ? 1 : 0 , "cross_layer_bla_flag" );
1805    }
1806    pcSlice->checkCrossLayerBlaFlag( ); 
1807
[622]1808    for (; esb < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)   
1809#else
[608]1810    for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
1811#endif
[443]1812    {
[1313]1813      WRITE_FLAG(0, "slice_reserved_flag[]");
[443]1814    }
[189]1815
[1313]1816
1817
[608]1818    WRITE_UVLC( pcSlice->getSliceType(),       "slice_type" );
[2]1819
[56]1820    if( pcSlice->getPPS()->getOutputFlagPresentFlag() )
[2]1821    {
[56]1822      WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" );
[2]1823    }
[608]1824
[1313]1825#if NH_MV
[738]1826    if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() )
1827    {
1828      Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
1829      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb");
[964]1830      pcSlice->setSlicePicOrderCntLsb( picOrderCntLSB ); 
[738]1831    }
[964]1832
[738]1833#endif
[1313]1834
[608]1835    if( !pcSlice->getIdrPicFlag() )
[2]1836    {
[1313]1837#if !NH_MV
[655]1838      Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
[1313]1839      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb");
[738]1840#endif
[1313]1841      const TComReferencePictureSet* rps = pcSlice->getRPS();
1842
[608]1843      // check for bitstream restriction stating that:
1844      // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
1845      // Ideally this process should not be repeated for each slice in a picture
1846      if (pcSlice->isIRAP())
1847      {
[1313]1848        for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
1849        {
[608]1850          assert (!rps->getUsed(picIdx));
1851        }
[1313]1852      }
[608]1853
1854      if(pcSlice->getRPSidx() < 0)
[77]1855      {
[608]1856        WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag");
[1313]1857        codeShortTermRefPicSet( rps, true, pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets());
[608]1858      }
1859      else
1860      {
1861        WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag");
1862        Int numBits = 0;
1863        while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets())
[77]1864        {
[608]1865          numBits++;
[77]1866        }
[608]1867        if (numBits > 0)
[77]1868        {
[1313]1869          WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" );
[77]1870        }
[608]1871      }
[1321]1872#if NH_MV
1873      if(pcSlice->getSPS()->getLongTermRefPicsPresentFlag())
1874#else
[608]1875      if(pcSlice->getSPS()->getLongTermRefsPresent())
[1321]1876#endif
[608]1877      {
1878        Int numLtrpInSH = rps->getNumberOfLongtermPictures();
1879        Int ltrpInSPS[MAX_NUM_REF_PICS];
1880        Int numLtrpInSPS = 0;
1881        UInt ltrpIndex;
1882        Int counter = 0;
[1313]1883        // WARNING: The following code only works only if a matching long-term RPS is
1884        //          found in the SPS for ALL long-term pictures
1885        //          The problem is that the SPS coded long-term pictures are moved to the
1886        //          beginning of the list which causes a mismatch when no reference picture
1887        //          list reordering is used
1888        //          NB: Long-term coding is currently not supported in general by the HM encoder
1889        for(Int k = rps->getNumberOfPictures()-1; k > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; k--)
[77]1890        {
[1313]1891          if (findMatchingLTRP(pcSlice, &ltrpIndex, rps->getPOC(k), rps->getUsed(k)))
[77]1892          {
[608]1893            ltrpInSPS[numLtrpInSPS] = ltrpIndex;
1894            numLtrpInSPS++;
[77]1895          }
[608]1896          else
1897          {
1898            counter++;
1899          }
[77]1900        }
[608]1901        numLtrpInSH -= numLtrpInSPS;
[1313]1902        // check that either all long-term pictures are coded in SPS or in slice header (no mixing)
1903        assert (numLtrpInSH==0 || numLtrpInSPS==0); 
[608]1904
1905        Int bitsForLtrpInSPS = 0;
1906        while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
[56]1907        {
[608]1908          bitsForLtrpInSPS++;
[56]1909        }
[1313]1910        if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0)
[2]1911        {
[608]1912          WRITE_UVLC( numLtrpInSPS, "num_long_term_sps");
[2]1913        }
[608]1914        WRITE_UVLC( numLtrpInSH, "num_long_term_pics");
1915        // Note that the LSBs of the LT ref. pic. POCs must be sorted before.
1916        // Not sorted here because LT ref indices will be used in setRefPicList()
1917        Int prevDeltaMSB = 0, prevLSB = 0;
1918        Int offset = rps->getNumberOfNegativePictures() + rps->getNumberOfPositivePictures();
[1313]1919        counter = 0;
1920        // Warning: If some pictures are moved to ltrpInSPS, i is referring to a wrong index
1921        //          (mapping would be required)
1922        for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--, counter++)
[2]1923        {
[608]1924          if (counter < numLtrpInSPS)
[56]1925          {
[608]1926            if (bitsForLtrpInSPS > 0)
[56]1927            {
[1313]1928              WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]");
[56]1929            }
[608]1930          }
[1313]1931          else
[608]1932          {
1933            WRITE_CODE( rps->getPocLSBLT(i), pcSlice->getSPS()->getBitsForPOC(), "poc_lsb_lt");
[1313]1934            WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag");
[608]1935          }
1936          WRITE_FLAG( rps->getDeltaPocMSBPresentFlag(i), "delta_poc_msb_present_flag");
1937
1938          if(rps->getDeltaPocMSBPresentFlag(i))
1939          {
1940            Bool deltaFlag = false;
1941            //  First LTRP from SPS                 ||  First LTRP from SH                              || curr LSB            != prev LSB
1942            if( (i == rps->getNumberOfPictures()-1) || (i == rps->getNumberOfPictures()-1-numLtrpInSPS) || (rps->getPocLSBLT(i) != prevLSB) )
[56]1943            {
[608]1944              deltaFlag = true;
[56]1945            }
[608]1946            if(deltaFlag)
[56]1947            {
[608]1948              WRITE_UVLC( rps->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i]" );
[56]1949            }
1950            else
[1313]1951            {
[608]1952              Int differenceInDeltaMSB = rps->getDeltaPocMSBCycleLT(i) - prevDeltaMSB;
1953              assert(differenceInDeltaMSB >= 0);
1954              WRITE_UVLC( differenceInDeltaMSB, "delta_poc_msb_cycle_lt[i]" );
[56]1955            }
[608]1956            prevLSB = rps->getPocLSBLT(i);
1957            prevDeltaMSB = rps->getDeltaPocMSBCycleLT(i);
[56]1958          }
[2]1959        }
1960      }
[608]1961      if (pcSlice->getSPS()->getTMVPFlagsPresent())
1962      {
[1313]1963#if NH_MV
[1066]1964        WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" );
1965#else
[1313]1966        WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" );
[1066]1967#endif
[608]1968      }
[2]1969    }
[1313]1970#if NH_MV
[738]1971    Bool interLayerPredLayerIdcPresentFlag = false; 
[622]1972    Int layerId = pcSlice->getLayerId(); 
[1313]1973#if NH_3D
[1124]1974    if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 )
1975#else
[622]1976    if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )
[1124]1977#endif
[622]1978    {   
1979      WRITE_FLAG( pcSlice->getInterLayerPredEnabledFlag( ) ? 1 : 0 , "inter_layer_pred_enabled_flag" );
[1313]1980#if NH_3D
[1124]1981      if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 )
1982#else
[622]1983      if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 )
[1124]1984#endif
[622]1985      {           
1986        if( !vps->getMaxOneActiveRefLayerFlag()) 
1987        {
1988          WRITE_CODE( pcSlice->getNumInterLayerRefPicsMinus1( ), pcSlice->getNumInterLayerRefPicsMinus1Len( ), "num_inter_layer_ref_pics_minus1" );
1989        }
[1313]1990#if NH_3D
[1124]1991        if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) )
1992#else
[622]1993        if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) )
[1124]1994#endif
[622]1995        {       
[738]1996          interLayerPredLayerIdcPresentFlag = true; 
[622]1997          for( Int idx = 0; idx < pcSlice->getNumActiveRefLayerPics(); idx++ )   
1998          {
1999            WRITE_CODE( pcSlice->getInterLayerPredLayerIdc( idx ), pcSlice->getInterLayerPredLayerIdcLen( ), "inter_layer_pred_layer_idc" );
2000          }
2001        }
2002      } 
2003    }
[738]2004    if ( !interLayerPredLayerIdcPresentFlag )
2005    {
2006      for( Int i = 0; i < pcSlice->getNumActiveRefLayerPics(); i++ )   
2007      {
2008        assert( pcSlice->getInterLayerPredLayerIdc( i ) == pcSlice->getRefLayerPicIdc( i ) );
2009      }
2010    }
[608]2011#endif
[1179]2012
[1313]2013#if NH_3D     
[1179]2014  if( getEncTop()->decProcAnnexI() )
2015  {
2016      if ( pcSlice->getInCmpPredAvailFlag() )
2017      {
2018        WRITE_FLAG( pcSlice->getInCompPredFlag(), "in_comp_pred_flag" );
2019      }
2020  }
2021#endif
[1313]2022
[608]2023    if(pcSlice->getSPS()->getUseSAO())
2024    {
[1313]2025       WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag" );
2026       if (chromaEnabled)
2027       {
2028         WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag" );
2029       }
[2]2030    }
[56]2031
[608]2032    //check if numrefidxes match the defaults. If not, override
2033
[56]2034    if (!pcSlice->isIntra())
2035    {
[608]2036      Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive()));
[773]2037#if PPS_FIX_DEPTH
2038      overrideFlag |= (pcSlice->getIsDepth() && !pcSlice->getViewIndex());
2039#endif
[608]2040      WRITE_FLAG( overrideFlag ? 1 : 0,                               "num_ref_idx_active_override_flag");
[1313]2041      if (overrideFlag)
[608]2042      {
2043        WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1,      "num_ref_idx_l0_active_minus1" );
2044        if (pcSlice->isInterB())
2045        {
2046          WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1,    "num_ref_idx_l1_active_minus1" );
2047        }
2048        else
2049        {
2050          pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
2051        }
2052      }
[56]2053    }
[2]2054    else
2055    {
[56]2056      pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0);
2057      pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
[2]2058    }
[773]2059#if PPS_FIX_DEPTH
2060    if( (pcSlice->getPPS()->getListsModificationPresentFlag() || (pcSlice->getIsDepth() && !pcSlice->getViewIndex())) && pcSlice->getNumRpsCurrTempList() > 1)
2061#else
[608]2062    if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1)
[773]2063#endif
[56]2064    {
[608]2065      TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
2066      if(!pcSlice->isIntra())
[2]2067      {
[608]2068        WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0,       "ref_pic_list_modification_flag_l0" );
2069        if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0())
[2]2070        {
[608]2071          Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList();
2072          if (numRpsCurrTempList0 > 1)
[2]2073          {
[608]2074            Int length = 1;
2075            numRpsCurrTempList0 --;
[1313]2076            while ( numRpsCurrTempList0 >>= 1)
[608]2077            {
2078              length ++;
2079            }
2080            for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++)
2081            {
2082              WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0");
2083            }
[2]2084          }
2085        }
2086      }
[608]2087      if(pcSlice->isInterB())
[1313]2088      {
[608]2089        WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0,       "ref_pic_list_modification_flag_l1" );
2090        if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1())
[2]2091        {
[608]2092          Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList();
2093          if ( numRpsCurrTempList1 > 1 )
[2]2094          {
[608]2095            Int length = 1;
2096            numRpsCurrTempList1 --;
2097            while ( numRpsCurrTempList1 >>= 1)
2098            {
2099              length ++;
2100            }
2101            for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++)
2102            {
2103              WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1");
2104            }
[2]2105          }
2106        }
2107      }
2108    }
[1313]2109
[608]2110    if (pcSlice->isInterB())
2111    {
2112      WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0,   "mvd_l1_zero_flag");
[56]2113    }
[608]2114
2115    if(!pcSlice->isIntra())
[56]2116    {
[608]2117      if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag())
[2]2118      {
[608]2119        SliceType sliceType   = pcSlice->getSliceType();
[1313]2120        SliceType  encCABACTableIdx = pcSlice->getEncCABACTableIdx();
[608]2121        Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=I_SLICE) ? true : false;
2122        pcSlice->setCabacInitFlag( encCabacInitFlag );
2123        WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" );
[2]2124      }
2125    }
2126
[608]2127    if ( pcSlice->getEnableTMVPFlag() )
[2]2128    {
[608]2129      if ( pcSlice->getSliceType() == B_SLICE )
2130      {
2131        WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" );
2132      }
2133
2134      if ( pcSlice->getSliceType() != I_SLICE &&
2135        ((pcSlice->getColFromL0Flag()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)||
2136        (pcSlice->getColFromL0Flag()==0  && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1)))
2137      {
2138        WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" );
2139      }
[2]2140    }
[608]2141    if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) )
2142    {
2143      xCodePredWeightTable( pcSlice );
2144    }
[1313]2145#if NH_3D_IC
[1179]2146    else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE )
2147      && !pcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0 
2148      && getEncTop()->decProcAnnexI()       
2149      )
[608]2150    {
2151      WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" );
2152      if( pcSlice->getApplyIC() )
2153      {
[1313]2154        WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, "slice_ic_disabled_merge_zero_idx_flag" );
[608]2155      }
2156    }
2157#endif
[1313]2158#if NH_3D_IV_MERGE
[608]2159    assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_MEM);
[2]2160#else
[608]2161    assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS);
[2]2162#endif
[608]2163    if (!pcSlice->isIntra())
2164    {
[1313]2165#if NH_3D_IV_MERGE
[1124]2166      WRITE_UVLC( ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( ) ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
2167#else
[608]2168      WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
2169#endif
2170    }
[56]2171    Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 );
[1313]2172    WRITE_SVLC( iCode, "slice_qp_delta" );
[608]2173    if (pcSlice->getPPS()->getSliceChromaQpFlag())
[2]2174    {
[1313]2175      if (numberValidComponents > COMPONENT_Cb)
2176      {
2177        WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset" );
2178      }
2179      if (numberValidComponents > COMPONENT_Cr)
2180      {
2181        WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset" );
2182      }
2183      assert(numberValidComponents <= COMPONENT_Cr+1);
[608]2184    }
[1313]2185
2186    if (pcSlice->getPPS()->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag())
2187    {
2188      WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag");
2189    }
2190
[608]2191    if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
2192    {
2193      if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() )
[2]2194      {
[608]2195        WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag");
[2]2196      }
[608]2197      if (pcSlice->getDeblockingFilterOverrideFlag())
[2]2198      {
[608]2199        WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_disable_deblocking_filter_flag");
2200        if(!pcSlice->getDeblockingFilterDisable())
[56]2201        {
[608]2202          WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2");
2203          WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(),   "slice_tc_offset_div2");
[56]2204        }
[2]2205      }
[56]2206    }
[608]2207
[1313]2208    Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (chromaEnabled && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA)));
[608]2209    Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable());
2210
[1321]2211      if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
[56]2212    {
[608]2213      WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag");
[56]2214    }
[1313]2215#if NH_3D
[1179]2216    if (getEncTop()->decProcAnnexI() )
2217    {
2218      Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() ); 
[1313]2219      if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) )
[1179]2220      {
2221        for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ )
2222        {
2223          Int jInVps = vps->getVoiInVps( vps->getCpRefVoi( voiInVps, m ));
2224          WRITE_SVLC( pcSlice->getCpScale   ( jInVps )   , "cp_scale" );
2225          WRITE_SVLC( pcSlice->getCpOff     ( jInVps )   , "cp_off" );
2226          WRITE_SVLC( pcSlice->getCpInvScale( jInVps ) + pcSlice->getCpScale( jInVps ) , "cp_inv_scale_plus_scale" );
2227          WRITE_SVLC( pcSlice->getCpInvOff  ( jInVps ) + pcSlice->getCpOff  ( jInVps ) , "cp_inv_off_plus_off" );
2228        }
2229      }
2230    }
2231#endif
[1313]2232
[608]2233  }
[1313]2234#if !NH_MV
[872]2235  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
2236  {
[1313]2237    WRITE_UVLC(0,"slice_segment_header_extension_length");
[872]2238  }
2239#else
2240  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
2241  {
2242    // Derive the value of PocMsbValRequiredFlag
2243
2244    // Determine value of SH extension length.
2245    Int shExtnLengthInBit = 0;
2246    if (pcSlice->getPPS()->getPocResetInfoPresentFlag())
2247    {
2248      shExtnLengthInBit += 2;
2249    }
2250    if (pcSlice->getPocResetIdc() > 0)
2251    {
2252      shExtnLengthInBit += 6;
2253    }
2254    if (pcSlice->getPocResetIdc() == 3)
2255    {
2256      shExtnLengthInBit += (pcSlice->getSPS()->getBitsForPOC() + 1);
2257    }
2258
2259
[1124]2260    if( !pcSlice->getPocMsbValRequiredFlag() &&  pcSlice->getVPS()->getVpsPocLsbAlignedFlag() )
[872]2261    {
2262      shExtnLengthInBit++;    // For poc_msb_val_present_flag
2263    }
2264    else
2265    {
2266      if( pcSlice->getPocMsbValRequiredFlag() )
2267      {
[1321]2268        pcSlice->setPocMsbCycleValPresentFlag( true );
[872]2269      }
2270      else
2271      {
[1321]2272        pcSlice->setPocMsbCycleValPresentFlag( false );
[872]2273      }
2274    }
2275
[1321]2276    if( pcSlice->getPocMsbCycleValPresentFlag() )
[872]2277    {
2278//      Int iMaxPOClsb = 1<< pcSlice->getSPS()->getBitsForPOC(); currently unused
2279
2280      UInt lengthVal = 1;
[1321]2281      UInt tempVal = pcSlice->getPocMsbCycleVal() + 1;
[872]2282      assert ( tempVal );
2283      while( 1 != tempVal )
2284      {
2285        tempVal >>= 1;
2286        lengthVal += 2;
2287      }
2288      shExtnLengthInBit += lengthVal;
2289    }
2290    Int shExtnAdditionalBits = 0;
2291    if(shExtnLengthInBit % 8 != 0)
2292    {
2293      shExtnAdditionalBits = 8 - (shExtnLengthInBit % 8);
2294    }
2295    pcSlice->setSliceSegmentHeaderExtensionLength((shExtnLengthInBit + shExtnAdditionalBits) / 8);
2296     
2297
2298    WRITE_UVLC( pcSlice->getSliceSegmentHeaderExtensionLength( ), "slice_segment_header_extension_length" );
2299    UInt posFollSliceSegHeaderExtLen = m_pcBitIf->getNumberOfWrittenBits();
2300    if( pcSlice->getPPS()->getPocResetInfoPresentFlag() )
2301    {
2302      WRITE_CODE( pcSlice->getPocResetIdc( ), 2, "poc_reset_idc" );
2303    }
2304    else
2305    {
2306      assert( pcSlice->getPocResetIdc( ) == 0 );
2307    }
2308
[964]2309    pcSlice->checkPocResetIdc(); 
2310
[872]2311    if( pcSlice->getPocResetIdc() !=  0 )
2312    {
2313      WRITE_CODE( pcSlice->getPocResetPeriodId( ), 6, "poc_reset_period_id" );
2314    }
2315   
2316    if( pcSlice->getPocResetIdc() ==  3 ) 
2317    {
2318      WRITE_FLAG( pcSlice->getFullPocResetFlag( ) ? 1 : 0 , "full_poc_reset_flag" );
2319      WRITE_CODE( pcSlice->getPocLsbVal( ), pcSlice->getPocLsbValLen() , "poc_lsb_val" );
2320    }             
[964]2321    pcSlice->checkPocLsbVal(); 
2322
[1124]2323    if( !pcSlice->getPocMsbValRequiredFlag() &&  pcSlice->getVPS()->getVpsPocLsbAlignedFlag()  )
[872]2324    {
[1321]2325      WRITE_FLAG( pcSlice->getPocMsbCycleValPresentFlag( ) ? 1 : 0 , "poc_msb_cycle_val_present_flag" );
[872]2326    }
[964]2327    else
2328    {
[1321]2329      assert( pcSlice->getPocMsbCycleValPresentFlag() ==  pcSlice->inferPocMsbCycleValPresentFlag( ) ); 
[964]2330    }
[872]2331   
[1321]2332    if( pcSlice->getPocMsbCycleValPresentFlag() )
[872]2333    {
[1321]2334      WRITE_UVLC( pcSlice->getPocMsbCycleVal( ), "poc_msb_cycle_val" );
[872]2335    }
2336   
2337    while( ( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) < pcSlice->getSliceSegmentHeaderExtensionLength() * 8 )
2338    {
2339      WRITE_FLAG( 0, "slice_segment_header_extension_data_bit" );
2340    }
2341
2342    assert( ( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) == pcSlice->getSliceSegmentHeaderExtensionLength() * 8  ); 
2343  }
2344#endif
[1313]2345
[608]2346}
[2]2347
[1313]2348Void TEncCavlc::codePTL( const TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1)
[608]2349{
2350  if(profilePresentFlag)
[2]2351  {
[1313]2352    codeProfileTier(pcPTL->getGeneralPTL(), false);    // general_...
[608]2353  }
[1313]2354  WRITE_CODE( Int(pcPTL->getGeneralPTL()->getLevelIdc()), 8, "general_level_idc" );
[608]2355
2356  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
2357  {
[1313]2358    WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" );
[608]2359    WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i),   "sub_layer_level_present_flag[i]" );
[2]2360  }
[1313]2361
[608]2362  if (maxNumSubLayersMinus1 > 0)
2363  {
2364    for (Int i = maxNumSubLayersMinus1; i < 8; i++)
2365    {
2366      WRITE_CODE(0, 2, "reserved_zero_2bits");
2367    }
2368  }
[1313]2369
[608]2370  for(Int i = 0; i < maxNumSubLayersMinus1; i++)
2371  {
[1313]2372    if( pcPTL->getSubLayerProfilePresentFlag(i) )
[608]2373    {
[1313]2374      codeProfileTier(pcPTL->getSubLayerPTL(i), true);  // sub_layer_...
[608]2375    }
2376    if( pcPTL->getSubLayerLevelPresentFlag(i) )
2377    {
[1313]2378      WRITE_CODE( Int(pcPTL->getSubLayerPTL(i)->getLevelIdc()), 8, "sub_layer_level_idc[i]" );
[608]2379    }
2380  }
[2]2381}
[1313]2382
2383#if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS
2384Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool bIsSubLayer )
2385#define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt)
2386#else
2387Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool /*bIsSubLayer*/ )
2388#define PTL_TRACE_TEXT(txt) txt
2389#endif
[2]2390{
[1313]2391  WRITE_CODE( ptl->getProfileSpace(), 2 ,      PTL_TRACE_TEXT("profile_space"                   ));
2392  WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, PTL_TRACE_TEXT("tier_flag"                       ));
2393  WRITE_CODE( Int(ptl->getProfileIdc()), 5 ,   PTL_TRACE_TEXT("profile_idc"                     ));
[608]2394  for(Int j = 0; j < 32; j++)
[56]2395  {
[1313]2396    WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), PTL_TRACE_TEXT("profile_compatibility_flag[][j]" ));
[56]2397  }
[2]2398
[1313]2399  WRITE_FLAG(ptl->getProgressiveSourceFlag(),   PTL_TRACE_TEXT("progressive_source_flag"         ));
2400  WRITE_FLAG(ptl->getInterlacedSourceFlag(),    PTL_TRACE_TEXT("interlaced_source_flag"          ));
2401  WRITE_FLAG(ptl->getNonPackedConstraintFlag(), PTL_TRACE_TEXT("non_packed_constraint_flag"      ));
2402  WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), PTL_TRACE_TEXT("frame_only_constraint_flag"      ));
2403
2404#if NH_MV
[1066]2405  if( ptl->getV2ConstraintsPresentFlag() ) 
2406  {
2407    WRITE_FLAG( ptl->getMax12bitConstraintFlag( ) ? 1 : 0 , "max_12bit_constraint_flag" );
2408    WRITE_FLAG( ptl->getMax10bitConstraintFlag( ) ? 1 : 0 , "max_10bit_constraint_flag" );
2409    WRITE_FLAG( ptl->getMax8bitConstraintFlag( ) ? 1 : 0 , "max_8bit_constraint_flag" );
2410    WRITE_FLAG( ptl->getMax422chromaConstraintFlag( ) ? 1 : 0 , "max_422chroma_constraint_flag" );
2411    WRITE_FLAG( ptl->getMax420chromaConstraintFlag( ) ? 1 : 0 , "max_420chroma_constraint_flag" );
2412    WRITE_FLAG( ptl->getMaxMonochromeConstraintFlag( ) ? 1 : 0 , "max_monochrome_constraint_flag" );
2413    WRITE_FLAG( ptl->getIntraConstraintFlag( ) ? 1 : 0 , "intra_constraint_flag" );
2414    WRITE_FLAG( ptl->getOnePictureOnlyConstraintFlag( ) ? 1 : 0 , "one_picture_only_constraint_flag" );
2415    WRITE_FLAG( ptl->getLowerBitRateConstraintFlag( ) ? 1 : 0 , "lower_bit_rate_constraint_flag" );
2416    WRITE_CODE( 0, 16, "XXX_reserved_zero_34bits[0..15]");
2417    WRITE_CODE( 0, 16, "XXX_reserved_zero_34bits[16..31]");
2418    WRITE_CODE( 0, 2 , "XXX_reserved_zero_34bits[32..33]");
2419  }
2420  else
2421  {
2422    WRITE_CODE( 0, 16, "XXX_reserved_zero_43bits[0..15]");
2423    WRITE_CODE( 0, 16, "XXX_reserved_zero_43bits[16..31]");
2424    WRITE_CODE( 0, 11, "XXX_reserved_zero_43bits[32..42]");
2425  }
2426    if( ptl->getInbldPresentFlag() )
2427  {
2428    WRITE_FLAG( ptl->getInbldFlag( ) ? 1 : 0 , "inbld_flag" );
2429  }
2430  else
2431  {
2432    WRITE_FLAG(0, "reserved_zero_bit");
2433  }
2434#else
[1313]2435  if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT )
2436  {
2437    const UInt         bitDepthConstraint=ptl->getBitDepthConstraint();
2438    WRITE_FLAG(bitDepthConstraint<=12,          PTL_TRACE_TEXT("max_12bit_constraint_flag"       ));
2439    WRITE_FLAG(bitDepthConstraint<=10,          PTL_TRACE_TEXT("max_10bit_constraint_flag"       ));
2440    WRITE_FLAG(bitDepthConstraint<= 8,          PTL_TRACE_TEXT("max_8bit_constraint_flag"        ));
2441    const ChromaFormat chromaFmtConstraint=ptl->getChromaFormatConstraint();
2442    WRITE_FLAG(chromaFmtConstraint==CHROMA_422||chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_422chroma_constraint_flag" ));
2443    WRITE_FLAG(chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400,                                  PTL_TRACE_TEXT("max_420chroma_constraint_flag" ));
2444    WRITE_FLAG(chromaFmtConstraint==CHROMA_400,                                                                   PTL_TRACE_TEXT("max_monochrome_constraint_flag"));
2445    WRITE_FLAG(ptl->getIntraConstraintFlag(),        PTL_TRACE_TEXT("intra_constraint_flag"           ));
2446    WRITE_FLAG(ptl->getOnePictureOnlyConstraintFlag(), PTL_TRACE_TEXT("one_picture_only_constraint_flag"));
2447    WRITE_FLAG(ptl->getLowerBitRateConstraintFlag(), PTL_TRACE_TEXT("lower_bit_rate_constraint_flag"  ));
2448    WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]"     ));
2449    WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]"    ));
2450    WRITE_CODE(0 ,  2, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]"    ));
2451  }
2452  else
2453  {
2454    WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]"     ));
2455    WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]"    ));
2456    WRITE_CODE(0x000  , 11, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]"    ));
2457  }
2458  WRITE_FLAG(false,   PTL_TRACE_TEXT("inbld_flag" ));
2459#undef PTL_TRACE_TEXT
[1066]2460#endif
2461}
[608]2462
[56]2463/**
[1313]2464 * Write tiles and wavefront substreams sizes for the slice header (entry points).
2465 *
2466 * \param pSlice TComSlice structure that contains the substream size information.
[56]2467 */
2468Void  TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice )
[2]2469{
[608]2470  if (!pSlice->getPPS()->getTilesEnabledFlag() && !pSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
[2]2471  {
[56]2472    return;
[2]2473  }
[1313]2474  UInt maxOffset = 0;
2475  for(Int idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++)
[2]2476  {
[1313]2477    UInt offset=pSlice->getSubstreamSize(idx);
2478    if ( offset > maxOffset )
[2]2479    {
[1313]2480      maxOffset = offset;
[2]2481    }
2482  }
[1313]2483
[56]2484  // Determine number of bits "offsetLenMinus1+1" required for entry point information
[1313]2485  UInt offsetLenMinus1 = 0;
[608]2486  while (maxOffset >= (1u << (offsetLenMinus1 + 1)))
[56]2487  {
[608]2488    offsetLenMinus1++;
[1313]2489    assert(offsetLenMinus1 + 1 < 32);
[2]2490  }
2491
[1313]2492  WRITE_UVLC(pSlice->getNumberOfSubstreamSizes(), "num_entry_point_offsets");
2493  if (pSlice->getNumberOfSubstreamSizes()>0)
[2]2494  {
[56]2495    WRITE_UVLC(offsetLenMinus1, "offset_len_minus1");
2496
[1313]2497    for (UInt idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++)
2498    {
2499      WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1");
2500    }
[2]2501  }
2502}
2503
[1313]2504Void TEncCavlc::codeTerminatingBit      ( UInt /*uilsLast*/ )
[2]2505{
[56]2506}
[2]2507
[56]2508Void TEncCavlc::codeSliceFinish ()
2509{
2510}
[2]2511
[1313]2512Void TEncCavlc::codeMVPIdx ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ )
[56]2513{
2514  assert(0);
2515}
[2]2516
[1313]2517Void TEncCavlc::codePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
[56]2518{
2519  assert(0);
2520}
[2]2521
[1313]2522Void TEncCavlc::codePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2523{
2524  assert(0);
2525}
[2]2526
[1313]2527Void TEncCavlc::codeMergeFlag    ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2528{
2529  assert(0);
2530}
[2]2531
[1313]2532Void TEncCavlc::codeMergeIndex    ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2533{
2534  assert(0);
2535}
[2]2536
[1313]2537#if NH_3D_ARP
[608]2538Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
[56]2539{
2540  assert(0);
2541}
[2]2542#endif
[608]2543
[1313]2544#if NH_3D_IC
[608]2545Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
[443]2546{
[608]2547  assert(0);
[443]2548}
2549#endif
[2]2550
[1313]2551Void TEncCavlc::codeInterModeFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiEncMode*/ )
[56]2552{
2553  assert(0);
2554}
[2]2555
[1313]2556Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2557{
2558  assert(0);
2559}
[2]2560
[1313]2561Void TEncCavlc::codeSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[189]2562{
2563  assert(0);
2564}
[1313]2565#if NH_3D_DIS
[1179]2566Void TEncCavlc::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx )
2567{
2568  assert(0);
2569}
[1039]2570#endif
[1179]2571
[1313]2572Void TEncCavlc::codeSplitFlag   ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
[56]2573{
2574  assert(0);
2575}
[2]2576
[1313]2577Void TEncCavlc::codeTransformSubdivFlag( UInt /*uiSymbol*/, UInt /*uiCtx*/ )
[56]2578{
2579  assert(0);
2580}
[2]2581
[1313]2582Void TEncCavlc::codeQtCbf( TComTU& /*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ )
[56]2583{
2584  assert(0);
2585}
[2]2586
[1313]2587Void TEncCavlc::codeQtRootCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2588{
2589  assert(0);
2590}
[2]2591
[1313]2592Void TEncCavlc::codeQtCbfZero( TComTU& /*rTu*/, const ChannelType /*chType*/ )
[608]2593{
2594  assert(0);
2595}
[1313]2596Void TEncCavlc::codeQtRootCbfZero( )
[608]2597{
2598  assert(0);
2599}
2600
[1313]2601Void TEncCavlc::codeTransformSkipFlags (TComTU& /*rTu*/, ComponentID /*component*/ )
[608]2602{
2603  assert(0);
2604}
2605
2606/** Code I_PCM information.
[56]2607 * \param pcCU pointer to CU
2608 * \param uiAbsPartIdx CU index
2609 * \returns Void
2610 */
[1313]2611Void TEncCavlc::codeIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2612{
2613  assert(0);
2614}
[2]2615
[1313]2616Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, Bool /*isMultiple*/)
[56]2617{
2618  assert(0);
2619}
[2]2620
[1313]2621Void TEncCavlc::codeIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2622{
2623  assert(0);
[2]2624}
2625
[1313]2626Void TEncCavlc::codeInterDir( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[2]2627{
[56]2628  assert(0);
2629}
[2]2630
[1313]2631Void TEncCavlc::codeRefFrmIdx( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ )
[56]2632{
2633  assert(0);
[2]2634}
2635
[1313]2636Void TEncCavlc::codeMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ )
[2]2637{
[56]2638  assert(0);
[2]2639}
2640
[1313]2641Void TEncCavlc::codeCrossComponentPrediction( TComTU& /*rTu*/, ComponentID /*compID*/ )
2642{
2643  assert(0);
2644}
2645
[56]2646Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx )
2647{
2648  Int iDQp  = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx );
2649
[1313]2650  Int qpBdOffsetY =  pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
[56]2651  iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2);
2652
2653  xWriteSvlc( iDQp );
[1313]2654
[56]2655  return;
2656}
2657
[1313]2658Void TEncCavlc::codeChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ )
[56]2659{
2660  assert(0);
2661}
2662
[1313]2663Void TEncCavlc::codeCoeffNxN    ( TComTU& /*rTu*/, TCoeff* /*pcCoef*/, const ComponentID /*compID*/ )
[2]2664{
[1313]2665  assert(0);
2666}
2667
2668Void TEncCavlc::estBit( estBitsSbacStruct* /*pcEstBitsCabac*/, Int /*width*/, Int /*height*/, ChannelType /*chType*/ )
2669{
[2]2670  // printf("error : no VLC mode support in this version\n");
2671  return;
2672}
2673
2674// ====================================================================================================================
2675// Protected member functions
2676// ====================================================================================================================
2677
[1313]2678//! Code weighted prediction tables
[56]2679Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice )
[2]2680{
[1313]2681  WPScalingParam  *wp;
2682  const ChromaFormat    format                = pcSlice->getPic()->getChromaFormat();
2683  const UInt            numberValidComponents = getNumberValidComponents(format);
2684  const Bool            bChroma               = isChromaEnabled(format);
2685  const Int             iNbRef                = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1);
2686        Bool            bDenomCoded           = false;
2687        UInt            uiTotalSignalledWeightFlags = 0;
2688
[608]2689  if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) )
2690  {
[1313]2691    for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements
[2]2692    {
[56]2693      RefPicList  eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
[608]2694
[1313]2695      // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings.
2696
2697      for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
[2]2698      {
[56]2699        pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
[1313]2700        if ( !bDenomCoded )
[2]2701        {
[56]2702          Int iDeltaDenom;
[1313]2703          WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" );
[2]2704
[56]2705          if( bChroma )
[2]2706          {
[1313]2707            assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); // check the channel-type settings are consistent across components.
2708            iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom);
2709            WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );
[2]2710          }
[56]2711          bDenomCoded = true;
2712        }
[1313]2713        WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" );
2714        uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
[608]2715      }
[1313]2716      if (bChroma)
[608]2717      {
[1313]2718        for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
[608]2719        {
2720          pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
[1313]2721          assert(wp[COMPONENT_Cb].bPresentFlag == wp[COMPONENT_Cr].bPresentFlag); // check the channel-type settings are consistent across components.
2722          WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" );
2723          uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag;
[608]2724        }
2725      }
[2]2726
[1313]2727      for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
[608]2728      {
2729        pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
[1313]2730        if ( wp[COMPONENT_Y].bPresentFlag )
[56]2731        {
[1313]2732          Int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom));
2733          WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" );
2734          WRITE_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" );
[56]2735        }
[2]2736
[1313]2737        if ( bChroma )
[56]2738        {
[1313]2739          if ( wp[COMPONENT_Cb].bPresentFlag )
[2]2740          {
[1313]2741            for ( Int j = COMPONENT_Cb ; j < numberValidComponents ; j++ )
[2]2742            {
[1313]2743              assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom);
2744              Int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom));
2745              WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" );
[56]2746
[1313]2747              Int range=pcSlice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128;
2748              Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
[608]2749              Int iDeltaChroma = (wp[j].iOffset - pred);
[1313]2750              WRITE_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" );
[2]2751            }
2752          }
2753        }
2754      }
2755    }
[608]2756    assert(uiTotalSignalledWeightFlags<=24);
[2]2757  }
[56]2758}
[2]2759
[56]2760/** code quantization matrix
2761 *  \param scalingList quantization matrix information
2762 */
[1313]2763Void TEncCavlc::codeScalingList( const TComScalingList &scalingList )
[56]2764{
[1313]2765  //for each size
2766  for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++)
2767  {
2768    const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries.
[2]2769
[1313]2770    for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep)
[2]2771    {
[1313]2772      Bool scalingListPredModeFlag = scalingList.getScalingListPredModeFlag(sizeId, listId);
2773      WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" );
2774      if(!scalingListPredModeFlag)// Copy Mode
[2]2775      {
[1313]2776        if (sizeId == SCALING_LIST_32x32)
[2]2777        {
[1313]2778          // adjust the code, to cope with the missing chroma entries
2779          WRITE_UVLC( ((Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId)) / (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES), "scaling_list_pred_matrix_id_delta");
[2]2780        }
[1313]2781        else
[2]2782        {
[1313]2783          WRITE_UVLC( (Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta");
[2]2784        }
2785      }
[1313]2786      else// DPCM Mode
2787      {
2788        xCodeScalingList(&scalingList, sizeId, listId);
2789      }
[2]2790    }
[1313]2791  }
[2]2792  return;
2793}
[56]2794/** code DPCM
2795 * \param scalingList quantization matrix information
[1313]2796 * \param sizeId      size index
2797 * \param listId      list index
[56]2798 */
[1313]2799Void TEncCavlc::xCodeScalingList(const TComScalingList* scalingList, UInt sizeId, UInt listId)
[2]2800{
[56]2801  Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]);
[1313]2802  UInt* scan  = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3];
[56]2803  Int nextCoef = SCALING_LIST_START_VALUE;
2804  Int data;
[1313]2805  const Int *src = scalingList->getScalingListAddress(sizeId, listId);
[56]2806    if( sizeId > SCALING_LIST_8x8 )
[2]2807    {
[56]2808      WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8");
[608]2809      nextCoef = scalingList->getScalingListDC(sizeId,listId);
[2]2810    }
[56]2811    for(Int i=0;i<coefNum;i++)
[2]2812    {
[56]2813      data = src[scan[i]] - nextCoef;
2814      nextCoef = src[scan[i]];
2815      if(data > 127)
[2]2816      {
[56]2817        data = data - 256;
[2]2818      }
[56]2819      if(data < -128)
[2]2820      {
[56]2821        data = data + 256;
[2]2822      }
2823
[56]2824      WRITE_SVLC( data,  "scaling_list_delta_coef");
[2]2825    }
[608]2826}
2827Bool TEncCavlc::findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag )
2828{
2829  // Bool state = true, state2 = false;
[655]2830  Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
[608]2831  for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++)
2832  {
2833    if ( (lsb == pcSlice->getSPS()->getLtRefPicPocLsbSps(k)) && (usedFlag == pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(k)) )
2834    {
2835      *ltrpsIndex = k;
2836      return true;
2837    }
[2]2838  }
[608]2839  return false;
[2]2840}
[189]2841
[1313]2842Void TEncCavlc::codeExplicitRdpcmMode( TComTU& /*rTu*/, const ComponentID /*compID*/ )
2843 {
2844   assert(0);
2845 }
2846#if NH_3D_SDC_INTRA || NH_3D_SDC_INTER
[833]2847Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx )
2848{
2849  assert(0);
2850}
[189]2851#endif
[833]2852   
[1313]2853#if NH_3D_DBBP
[833]2854Void TEncCavlc::codeDBBPFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx )
2855{
2856  assert(0);
2857}
2858#endif
[1313]2859
2860
[56]2861//! \}
Note: See TracBrowser for help on using the repository browser.