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


Ignore:
Timestamp:
9 Aug 2012, 12:53:16 (13 years ago)
Author:
tech
Message:

Adopted modifications:

  • disparity vector generation (A0097)
  • inter-view motion prediction modification (A0049)
  • simplification of disparity vector derivation (A0126)
  • region boundary chain coding (A0070)
  • residual skip intra (A0087)
  • VSO modification (A0033/A0093)

+ Clean ups + Bug fixes

Update of cfg files (A0033 modification 2)

File:
1 edited

Legend:

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

    r77 r100  
    106106, m_cDmmDataSCModel           ( 1,             1,               NUM_DMM_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    107107#endif
     108#if LGE_EDGE_INTRA
     109, m_cEdgeIntraSCModel         ( 1,             1,               NUM_EDGE_INTRA_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
     110#if LGE_EDGE_INTRA_DELTA_DC
     111, m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
     112#endif
     113#endif
    108114{
    109115  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
     
    181187  m_cDmmDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_DATA );
    182188#endif
     189#if LGE_EDGE_INTRA
     190  m_cEdgeIntraSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA );
     191#if LGE_EDGE_INTRA_DELTA_DC
     192  m_cEdgeIntraDeltaDCSCModel.initBuffer  ( eSliceType, iQp, (UChar*)INIT_EDGE_INTRA_DELTA_DC );
     193#endif
     194#endif
    183195
    184196  // new structure
     
    345357Void TEncSbac::codeVPS( TComVPS* pcVPS )
    346358{
    347         assert (0);
     359  assert (0);
    348360  return;
    349361}
     
    828840  DTRACE_CABAC_T( "\n" )
    829841}
     842
     843#if LGE_EDGE_INTRA
     844Void TEncSbac::xCodeEdgeIntraInfo( TComDataCU* pcCU, UInt uiPartIdx )
     845{
     846  UInt   uiDepth        = pcCU->getDepth( uiPartIdx ) + (pcCU->getPartitionSize( uiPartIdx ) == SIZE_NxN ? 1 : 0);
     847  UInt   uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiPartIdx );
     848  UChar* pucSymbolList  = pcCU->getEdgeCode( uiPartIdx );
     849  UChar  ucEdgeNumber   = pcCU->getEdgeNumber( uiPartIdx );
     850  Bool   bLeft          = pcCU->getEdgeLeftFirst( uiPartIdx );
     851  UChar  ucStart        = pcCU->getEdgeStartPos( uiPartIdx );
     852  UInt   uiSymbol;
     853
     854  // 1. Top(0) or Left(1)
     855  uiSymbol = (bLeft == false) ? 0 : 1;
     856  m_pcBinIf->encodeBinEP( uiSymbol );
     857
     858  // 2. Start position (lowest bit first)
     859  uiSymbol = ucStart;
     860  for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2
     861  {
     862    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
     863    uiSymbol >>= 1;
     864  }
     865
     866  // 3. Number of edges
     867  uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0;
     868  for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3
     869  {
     870    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
     871    uiSymbol >>= 1;
     872  }
     873
     874  if(uiSymbol != 0)
     875  {
     876    printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth);
     877    assert(false);
     878  }
     879
     880  // 4. Edges
     881  for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ )
     882  {
     883    UInt uiReorderSymbol = pucSymbolList[iPtr2];
     884
     885    //printf ("Ptr = %d, Symbol = %d\n", iPtr2, uiSymbol);
     886
     887    // Left-friendly direction (Top start)
     888    // 0 (   0deg) => 0
     889    // 1 (  45deg) => 10
     890    // 2 ( -45deg) => 110
     891    // 3 (  90deg) => 1110
     892    // 4 ( -90deg) => 11110
     893    // 5 ( 135deg) => 111110
     894    // 6 (-135deg) => 111111
     895    // Right-friendly direction (Left start)
     896    // 0 (   0deg) => 0
     897    // 2 ( -45deg) => 10
     898    // 1 (  45deg) => 110
     899    // 4 ( -90deg) => 1110
     900    // 3 (  90deg) => 11110
     901    // 6 (-135deg) => 111110
     902    // 5 ( 135deg) => 111111
     903
     904    // refer to a paper "An efficient chain code with Huffman coding"
     905
     906    for( UInt ui = 0; ui < uiReorderSymbol; ui++ )
     907    {
     908      m_pcBinIf->encodeBin( 1, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
     909    }
     910
     911    if( uiReorderSymbol != 6 )
     912      m_pcBinIf->encodeBin( 0, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
     913  }
     914}
     915#endif
     916
    830917Void TEncSbac::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx )
    831918{
     
    835922  if( pcCU->getSlice()->getSPS()->getUseDMM() && pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE )
    836923  {
     924#if LGE_EDGE_INTRA
     925    m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX, m_cDmmFlagSCModel.get(0, 0, 0) );
     926#else
    837927    m_pcBinIf->encodeBin( uiDir >= NUM_INTRA_MODE, m_cDmmFlagSCModel.get(0, 0, 0) );
    838   }
     928#endif
     929  }
     930#if LGE_EDGE_INTRA
     931  if( uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX )
     932#else
    839933  if( uiDir >= NUM_INTRA_MODE )
     934#endif
    840935  {
    841936    assert( pcCU->getWidth( uiAbsPartIdx ) <= DMM_WEDGEMODEL_MAX_SIZE );
     
    870965  }
    871966  else
     967#if LGE_EDGE_INTRA
     968    if ( uiDir >= EDGE_INTRA_IDX)
     969    {
     970      m_pcBinIf->encodeBin( 0, m_cCUIntraPredSCModel.get( 0, 0, 0 ) );
     971      m_pcBinIf->encodeBinsEP( 63, 6 );
     972      xCodeEdgeIntraInfo( pcCU, uiAbsPartIdx );
     973#if LGE_EDGE_INTRA_DELTA_DC
     974      m_pcBinIf->encodeBin( (uiDir == EDGE_INTRA_DELTA_IDX), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
     975      if( uiDir == EDGE_INTRA_DELTA_IDX )
     976      {
     977        Int iDeltaDC0 = pcCU->getEdgeDeltaDC0( uiAbsPartIdx );
     978        Int iDeltaDC1 = pcCU->getEdgeDeltaDC1( uiAbsPartIdx );
     979
     980        xWriteExGolombLevel( UInt( abs( iDeltaDC0 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
     981        if ( iDeltaDC0 != 0 )
     982        {
     983          UInt uiSign = iDeltaDC0 > 0 ? 0 : 1;
     984          m_pcBinIf->encodeBinEP( uiSign );
     985        }
     986        xWriteExGolombLevel( UInt( abs( iDeltaDC1 ) ), m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
     987        if ( iDeltaDC1 != 0 )
     988        {
     989          UInt uiSign = iDeltaDC1 > 0 ? 0 : 1;
     990          m_pcBinIf->encodeBinEP( uiSign );
     991        }
     992      }
     993#endif
     994    }
     995    else
     996#endif // LGE_EDGE_INTRA
    872997  {
    873998#endif
    874999#if !LOGI_INTRA_NAME_3MPM
    8751000  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
     1001#endif
     1002#if LGE_EDGE_INTRA
     1003  Bool bCodeEdgeIntra = false;
     1004  if( pcCU->getSlice()->getSPS()->isDepth() )
     1005  {
     1006    UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
     1007    if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE )
     1008      bCodeEdgeIntra = true;
     1009  }
    8761010#endif
    8771011 
     
    9321066#if LOGI_INTRA_NAME_3MPM
    9331067    m_pcBinIf->encodeBinsEP( uiDir, 5 );
     1068#if LGE_EDGE_INTRA
     1069  if (bCodeEdgeIntra)
     1070    if (uiDir == 31) m_pcBinIf->encodeBinsEP(0,1);
     1071#endif
    9341072#else
    9351073    if ( uiDir < 31 )
     
    22702408}
    22712409
    2272 #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
     2410#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA && LGE_EDGE_INTRA_DELTA_DC)
    22732411Void TEncSbac::xWriteExGolombLevel( UInt uiSymbol, ContextModel& rcSCModel  )
    22742412{
Note: See TracChangeset for help on using the changeset viewer.