Changeset 5 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncSbac.cpp


Ignore:
Timestamp:
12 Dec 2011, 18:35:44 (13 years ago)
Author:
hhi
Message:

Clean version with cfg-files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibEncoder/TEncSbac.cpp

    r2 r5  
     1/* The copyright in this software is being made available under the BSD
     2 * License, included below. This software may be subject to other third party
     3 * and contributor rights, including patent rights, and no such rights are
     4 * granted under this license.
     5 *
     6 * Copyright (c) 2010-2011, ISO/IEC
     7 * All rights reserved.
     8 *
     9 * Redistribution and use in source and binary forms, with or without
     10 * modification, are permitted provided that the following conditions are met:
     11 *
     12 *  * Redistributions of source code must retain the above copyright notice,
     13 *    this list of conditions and the following disclaimer.
     14 *  * Redistributions in binary form must reproduce the above copyright notice,
     15 *    this list of conditions and the following disclaimer in the documentation
     16 *    and/or other materials provided with the distribution.
     17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
     18 *    be used to endorse or promote products derived from this software without
     19 *    specific prior written permission.
     20 *
     21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
     25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31 * THE POSSIBILITY OF SUCH DAMAGE.
     32 */
     33
    134
    235
     
    2659, m_uiMaxAlfCtrlDepth         ( 0 )
    2760, m_cCUSplitFlagSCModel       ( 1,             1,               NUM_SPLIT_FLAG_CTX            )
    28 #if MW_MVI_SIGNALLING_MODE == 0
    29 , m_cCUMvInheritanceFlagSCModel(1,             1,               NUM_MVI_FLAG_CTX              )
    30 #endif
    3161, m_cCUSkipFlagSCModel        ( 1,             1,               NUM_SKIP_FLAG_CTX             )
    3262, m_cCUMergeFlagExtSCModel    ( 1,             1,               NUM_MERGE_FLAG_EXT_CTX        )
     
    72102#endif
    73103, m_cViewIdxSCModel           ( 1,             1,               NUM_VIEW_IDX_CTX              )
    74 #if HHI_DMM_INTRA
     104#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    75105, m_cIntraDMMSCModel          ( 1,             1,               NUM_DMM_CTX                   )
    76106, m_cIntraWedgeSCModel        ( 1,             1,               NUM_WEDGE_CTX                 )
     
    94124 
    95125  m_cCUSplitFlagSCModel.initBuffer       ( eSliceType, iQp, (Short*)INIT_SPLIT_FLAG );
    96 #if MW_MVI_SIGNALLING_MODE == 0
    97   m_cCUMvInheritanceFlagSCModel.initBuffer( eSliceType, iQp, (Short*)INIT_MVI_FLAG );
    98 #endif
    99126 
    100127  m_cCUSkipFlagSCModel.initBuffer        ( eSliceType, iQp, (Short*)INIT_SKIP_FLAG );
     
    137164#endif
    138165  m_cViewIdxSCModel.initBuffer           ( eSliceType, iQp, (Short*)INIT_VIEW_IDX );
    139 #if HHI_DMM_INTRA
     166#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    140167  m_cIntraDMMSCModel.initBuffer          ( eSliceType, iQp, (Short*)INIT_INTRA_DMM );
    141168  m_cIntraWedgeSCModel.initBuffer        ( eSliceType, iQp, (Short*)INIT_INTRA_WEDGELET );
     
    307334  return;
    308335}
    309 #if HHI_DMM_INTRA
     336#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    310337Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel  )
    311338{
     
    388415 
    389416  this->m_cCUSplitFlagSCModel      .copyFrom( &pSrc->m_cCUSplitFlagSCModel       );
    390 #if MW_MVI_SIGNALLING_MODE == 0
    391   this->m_cCUMvInheritanceFlagSCModel.copyFrom( &pSrc->m_cCUMvInheritanceFlagSCModel );
    392 #endif
    393417  this->m_cCUSkipFlagSCModel       .copyFrom( &pSrc->m_cCUSkipFlagSCModel        );
    394418  this->m_cCUMergeFlagExtSCModel  .copyFrom( &pSrc->m_cCUMergeFlagExtSCModel);
     
    421445  this->m_cMVPIdxSCModel           .copyFrom( &pSrc->m_cMVPIdxSCModel            );
    422446  this->m_cViewIdxSCModel          .copyFrom( &pSrc->m_cViewIdxSCModel           );
    423 #if HHI_DMM_INTRA
     447#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    424448  this->m_cIntraDMMSCModel         .copyFrom( &pSrc->m_cIntraDMMSCModel          );
    425449  this->m_cIntraWedgeSCModel       .copyFrom( &pSrc->m_cIntraWedgeSCModel        );
     
    636660
    637661
     662#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
    638663Void TEncSbac::codeMergeIndexMV( TComDataCU* pcCU, UInt uiAbsPartIdx )
    639664{
     
    641666  Bool  abAvailable[ MRG_MAX_NUM_CANDS ];
    642667  UInt  uiNumCand = 0;
    643 #if MW_MVI_SIGNALLING_MODE == 1
     668#if HHI_MPI
    644669  const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
    645   const UInt uiMviMergePos = bMVIAvailable ? MVI_MERGE_POS : MRG_MAX_NUM_CANDS;
     670  const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : MRG_MAX_NUM_CANDS;
    646671#endif
    647672  for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ )
    648673  {
    649 #if MW_MVI_SIGNALLING_MODE == 1
     674#if HHI_MPI
    650675    if( uiIdx == uiMviMergePos )
    651676    {
     
    693718  //--- determine unary index ---
    694719  UInt  uiMergeIdx  = pcCU->getMergeIndex( uiAbsPartIdx );
    695 #if MW_MVI_SIGNALLING_MODE == 1
     720#if HHI_MPI
    696721  if( bMVIAvailable )
    697722  {
     
    699724    if( bUseMVI )
    700725    {
    701       uiMergeIdx = MVI_MERGE_POS;
    702     }
    703     else if( uiMergeIdx >= MVI_MERGE_POS )
     726      uiMergeIdx = HHI_MPI_MERGE_POS;
     727    }
     728    else if( uiMergeIdx >= HHI_MPI_MERGE_POS )
    704729    {
    705730      uiMergeIdx++;
     
    748773  DTRACE_CABAC_T( "\n" );
    749774}
    750 
     775#endif
    751776
    752777
     
    758783Void TEncSbac::codeMergeIndex( TComDataCU* pcCU, UInt uiAbsPartIdx )
    759784{
    760 #if MW_MVI_SIGNALLING_MODE == 1
     785#if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI
     786#if HHI_INTER_VIEW_MOTION_PRED && HHI_MPI
    761787  if( ( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ) ||
    762788      ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) )
     789#elif HHI_MPI
     790  if( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
    763791#else
    764792  if( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE )
     
    768796    return;
    769797  }
     798#endif
    770799
    771800  Bool bLeftInvolved = false;
     
    884913
    885914
     915#if HHI_INTER_VIEW_RESIDUAL_PRED
    886916Void
    887917TEncSbac::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
     
    891921  m_pcBinIf->encodeBin( uiSymbol, m_cResPredFlagSCModel.get( 0, 0, uiCtx ) );
    892922}
     923#endif
    893924
    894925
     
    907938  return;
    908939}
    909 
    910 #if MW_MVI_SIGNALLING_MODE == 0
    911 Void TEncSbac::codeMvInheritanceFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    912 {
    913   const Int iTextureModeDepth = pcCU->getTextureModeDepth( uiAbsPartIdx );
    914   if( iTextureModeDepth != -1 && uiDepth > iTextureModeDepth )
    915     return;
    916 
    917   UInt uiCtx    = pcCU->getCtxMvInheritanceFlag( uiAbsPartIdx, uiDepth );
    918   UInt uiSymbol = iTextureModeDepth == uiDepth ? 1 : 0;
    919 
    920   assert( uiCtx < 3 );
    921   m_pcBinIf->encodeBin( uiSymbol, m_cCUMvInheritanceFlagSCModel.get( 0, 0, uiCtx ) );
    922 }
    923 #endif
    924940
    925941Void TEncSbac::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx )
     
    935951}
    936952
    937 #if HHI_DMM_INTRA
     953#if HHI_DMM_WEDGE_INTRA
    938954Void TEncSbac::xCodeWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx )
    939955{
     
    10311047  }
    10321048}
    1033 
     1049#endif
     1050#if HHI_DMM_PRED_TEX
    10341051Void TEncSbac::xCodeWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx )
    10351052{
     
    10761093  UInt uiDir = pcCU->getLumaIntraDir( uiAbsPartIdx );
    10771094
    1078 #if HHI_DMM_INTRA
    1079   if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDepthModelModes() && pcCU->getWidth( uiAbsPartIdx ) < 64 )
     1095#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     1096  if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) < 64 )
    10801097  {
    10811098    m_pcBinIf->encodeBin( uiDir > MAX_MODE_ID_INTRA_DIR, m_cIntraDMMSCModel.get(0, 0, 0) );
     
    10861103    UInt uiDMMode = uiDir - (MAX_MODE_ID_INTRA_DIR+1);
    10871104
    1088     if( !pcCU->getTextureModeAllowance( uiAbsPartIdx ) )
    1089     {
     1105#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
     1106    m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
     1107    m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
     1108
    10901109      if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && pcCU->getWidth( uiAbsPartIdx ) > 4 )
    10911110      {
    1092         if( uiDMMode > 1 )
    1093         {
    1094           uiDMMode -= 4;
     1111      m_pcBinIf->encodeBin( (uiDMMode & 0x04) >> 2, m_cIntraDMMSCModel.get(0, 0, 1) );
    10951112        }
     1113#else
    10961114                                  m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
    1097     if( DMM_INTRA_MODE_BITS > 1 ) m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
    1098       }
    1099       else
    1100     {
    1101         m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
    1102     }
    1103     }
    1104     else
    1105     {
    1106                                   m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
    1107     if( DMM_INTRA_MODE_BITS > 1 ) m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
    11081115
    11091116    if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && pcCU->getWidth( uiAbsPartIdx ) > 4 )
    11101117    {
    1111       if( DMM_INTRA_MODE_BITS > 2 ) m_pcBinIf->encodeBin( (uiDMMode & 0x04) >> 2, m_cIntraDMMSCModel.get(0, 0, 1) );
    1112     }
    1113   }
    1114 
     1118      m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
     1119    }
     1120#endif
     1121#if HHI_DMM_WEDGE_INTRA
    11151122    if( uiDir == DMM_WEDGE_FULL_IDX )          { xCodeWedgeFullInfo          ( pcCU, uiAbsPartIdx ); }
    11161123    if( uiDir == DMM_WEDGE_FULL_D_IDX )        { xCodeWedgeFullDeltaInfo     ( pcCU, uiAbsPartIdx ); }
    11171124    if( uiDir == DMM_WEDGE_PREDDIR_IDX )       { xCodeWedgePredDirInfo       ( pcCU, uiAbsPartIdx ); }
    11181125    if( uiDir == DMM_WEDGE_PREDDIR_D_IDX )     { xCodeWedgePredDirDeltaInfo  ( pcCU, uiAbsPartIdx ); }
     1126#endif
     1127#if HHI_DMM_PRED_TEX
    11191128    if( uiDir == DMM_WEDGE_PREDTEX_D_IDX )     { xCodeWedgePredTexDeltaInfo  ( pcCU, uiAbsPartIdx ); }
    11201129    if( uiDir == DMM_CONTOUR_PREDTEX_D_IDX )   { xCodeContourPredTexDeltaInfo( pcCU, uiAbsPartIdx ); }
     1130#endif
    11211131  }
    11221132  else
     
    12041214{
    12051215  UInt uiDir = pcCU->getLumaIntraDir( uiAbsPartIdx );
    1206 #if HHI_DMM_INTRA
    1207   if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDepthModelModes() && pcCU->getWidth( uiAbsPartIdx ) < 64 )
     1216#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     1217  if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) < 64 )
    12081218  {
    12091219    m_pcBinIf->encodeBin( uiDir > MAX_MODE_ID_INTRA_DIR, m_cIntraDMMSCModel.get(0, 0, 0) );
     
    12141224    UInt uiDMMode = uiDir - (MAX_MODE_ID_INTRA_DIR+1);
    12151225
    1216     if( !pcCU->getTextureModeAllowance( uiAbsPartIdx ) )
    1217     {
     1226#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
     1227    m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
     1228    m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
     1229
    12181230      if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && pcCU->getWidth( uiAbsPartIdx ) > 4 )
    12191231      {
    1220         if( uiDMMode > 1 )
    1221         {
    1222           uiDMMode -= 4;
     1232      m_pcBinIf->encodeBin( (uiDMMode & 0x04) >> 2, m_cIntraDMMSCModel.get(0, 0, 1) );
    12231233        }
     1234#else
    12241235        m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
    1225         if( DMM_INTRA_MODE_BITS > 1 ) m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
    1226       }
    1227       else
    1228       {
    1229         m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
    1230       }
    1231     }
    1232     else
    1233     {
    1234       m_pcBinIf->encodeBin( (uiDMMode & 0x01),      m_cIntraDMMSCModel.get(0, 0, 1) );
    1235       if( DMM_INTRA_MODE_BITS > 1 ) m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
    12361236
    12371237      if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && pcCU->getWidth( uiAbsPartIdx ) > 4 )
    12381238      {
    1239         if( DMM_INTRA_MODE_BITS > 2 ) m_pcBinIf->encodeBin( (uiDMMode & 0x04) >> 2, m_cIntraDMMSCModel.get(0, 0, 1) );
    1240       }
    1241     }
    1242 
     1239      m_pcBinIf->encodeBin( (uiDMMode & 0x02) >> 1, m_cIntraDMMSCModel.get(0, 0, 1) );
     1240      }
     1241#endif
     1242#if HHI_DMM_WEDGE_INTRA
    12431243    if( uiDir == DMM_WEDGE_FULL_IDX )          { xCodeWedgeFullInfo          ( pcCU, uiAbsPartIdx ); }
    12441244    if( uiDir == DMM_WEDGE_FULL_D_IDX )        { xCodeWedgeFullDeltaInfo     ( pcCU, uiAbsPartIdx ); }
    12451245    if( uiDir == DMM_WEDGE_PREDDIR_IDX )       { xCodeWedgePredDirInfo       ( pcCU, uiAbsPartIdx ); }
    12461246    if( uiDir == DMM_WEDGE_PREDDIR_D_IDX )     { xCodeWedgePredDirDeltaInfo  ( pcCU, uiAbsPartIdx ); }
     1247#endif
     1248#if HHI_DMM_PRED_TEX
    12471249    if( uiDir == DMM_WEDGE_PREDTEX_D_IDX )     { xCodeWedgePredTexDeltaInfo  ( pcCU, uiAbsPartIdx ); }
    12481250    if( uiDir == DMM_CONTOUR_PREDTEX_D_IDX )   { xCodeContourPredTexDeltaInfo( pcCU, uiAbsPartIdx ); }
     1251#endif
    12491252  }
    12501253  else
Note: See TracChangeset for help on using the changeset viewer.