Changeset 677 in SHVCSoftware for branches/SHM-6-dev/source/Lib/TLibEncoder


Ignore:
Timestamp:
15 Apr 2014, 05:23:37 (11 years ago)
Author:
qualcomm
Message:

Integration of JCTVC-Q0048 Asymmetric 3D LUT based CGS

Location:
branches/SHM-6-dev/source/Lib/TLibEncoder
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r674 r677  
    154154
    155155
    156 Void TEncCavlc::codePPS( TComPPS* pcPPS )
     156Void TEncCavlc::codePPS( TComPPS* pcPPS
     157#if Q0048_CGS_3D_ASYMLUT
     158  , TEnc3DAsymLUT * pc3DAsymLUT
     159#endif
     160  )
    157161{
    158162#if ENC_DEC_TRACE 
     
    268272    {
    269273      WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" );
     274#if Q0048_CGS_3D_ASYMLUT
     275      UInt uiPos = getNumberOfWrittenBits();
     276      WRITE_FLAG( pcPPS->getCGSFlag() , "colour_mapping_enabled_flag" );
     277      if( pcPPS->getCGSFlag() == Q0048_CGS_3D_ASYMLUT_PPSUPDATE )
     278      {
     279        assert( pc3DAsymLUT != NULL );
     280        xCode3DAsymLUT( pc3DAsymLUT );
     281      }
     282      pc3DAsymLUT->setPPSBit( getNumberOfWrittenBits() - uiPos );
     283#endif
    270284#endif
    271285    }
     
    26892703  return true;
    26902704}
     2705
     2706#if Q0048_CGS_3D_ASYMLUT
     2707Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
     2708{
     2709  assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
     2710  WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
     2711  assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 );
     2712  WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
     2713  assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
     2714  WRITE_CODE( pc3DAsymLUT->getInputBitDepthY() - 8 , 3 , "cm_input_bit_depth_minus8" );
     2715  WRITE_SVLC(pc3DAsymLUT->getInputBitDepthC()-pc3DAsymLUT->getInputBitDepthY(), "cm_input_bit_depth_chroma delta");
     2716  assert( pc3DAsymLUT->getOutputBitDepthY() < 16 );
     2717  WRITE_CODE( pc3DAsymLUT->getOutputBitDepthY() - 8 , 3 , "cm_output_bit_depth_minus8" );
     2718  WRITE_SVLC(pc3DAsymLUT->getOutputBitDepthC()-pc3DAsymLUT->getOutputBitDepthY(), "cm_output_bit_depth_chroma_delta");
     2719  assert( pc3DAsymLUT->getResQuantBit() < 4 );
     2720  WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
     2721
     2722  xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
     2723}
     2724
     2725Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
     2726{
     2727  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
     2728  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
     2729    WRITE_FLAG( uiOctantSplit , "split_octant_flag" );
     2730  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
     2731  if( uiOctantSplit )
     2732  {
     2733    Int nHalfLength = nLength >> 1;
     2734    for( Int l = 0 ; l < 2 ; l++ )
     2735    {
     2736      for( Int m = 0 ; m < 2 ; m++ )
     2737      {
     2738        for( Int n = 0 ; n < 2 ; n++ )
     2739        {
     2740          xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
     2741        }
     2742      }
     2743    }
     2744  }
     2745  else
     2746  {
     2747    for( Int l = 0 ; l < nYPartNum ; l++ )
     2748    {
     2749      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     2750      {
     2751        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
     2752        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
     2753        WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
     2754        if( uiCodeVertex )
     2755        {
     2756          WRITE_SVLC( sRes.Y , "resY" );
     2757          WRITE_SVLC( sRes.U , "resU" );
     2758          WRITE_SVLC( sRes.V , "resV" );
     2759        }
     2760      }
     2761    }
     2762  }
     2763}
     2764#endif
    26912765//! \}
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncCavlc.h

    r644 r677  
    4848#include "TEncEntropy.h"
    4949#include "SyntaxElementWriter.h"
     50#if Q0048_CGS_3D_ASYMLUT
     51#include "../TLibCommon/TCom3DAsymLUT.h"
     52#include "TEnc3DAsymLUT.h"
     53#endif
    5054
    5155//! \ingroup TLibEncoder
     
    5357
    5458class TEncTop;
     59#if Q0048_CGS_3D_ASYMLUT
     60class TCom3DAsymLUT;
     61#endif
    5562
    5663// ====================================================================================================================
     
    9097  Void  codeVUI                 ( TComVUI *pcVUI, TComSPS* pcSPS );
    9198  Void  codeSPS                 ( TComSPS* pcSPS );
    92   Void  codePPS                 ( TComPPS* pcPPS );
     99  Void  codePPS                 ( TComPPS* pcPPS
     100#if Q0048_CGS_3D_ASYMLUT
     101    , TEnc3DAsymLUT * pc3DAsymLUT
     102#endif
     103    );
    93104  Void  codeSliceHeader         ( TComSlice* pcSlice );
    94105  Void  codePTL                 ( TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1);
     
    162173  Void  codeVpsDpbSizeTable      (TComVPS *vps);
    163174#endif
     175#if Q0048_CGS_3D_ASYMLUT
     176protected:
     177  Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
     178  Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
     179#endif
    164180#endif //SVC_EXTENSION
    165181
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncCfg.h

    r652 r677  
    364364  UInt      m_bottomRightTileIndex[1024];
    365365  UInt      m_ilcIdc[1024];
     366#endif
     367#if Q0048_CGS_3D_ASYMLUT
     368  Int  m_nCGSFlag;
     369  Int  m_nCGSMaxOctantDepth;
     370  Int  m_nCGSMaxYPartNumLog2;
     371  Int  m_nCGSLUTBit;
    366372#endif
    367373#endif //SVC_EXTENSION
     
    904910  UInt  getIlcIdc(UInt b)                                  { return m_ilcIdc[b]; }
    905911#endif
     912#if Q0048_CGS_3D_ASYMLUT
     913  Void      setCGSFlag(Int n)  { m_nCGSFlag = n;    }
     914  Int       getCGSFlag()       { return m_nCGSFlag; }
     915  Void      setCGSMaxOctantDepth(Int n)  { m_nCGSMaxOctantDepth = n;    }
     916  Int       getCGSMaxOctantDepth()       { return m_nCGSMaxOctantDepth; }
     917  Void      setCGSMaxYPartNumLog2(Int n)  { m_nCGSMaxYPartNumLog2 = n;    }
     918  Int       getCGSMaxYPartNumLog2()       { return m_nCGSMaxYPartNumLog2; }
     919  Void      setCGSLUTBit(Int n)  { m_nCGSLUTBit = n;    }
     920  Int       getCGSLUTBit()       { return m_nCGSLUTBit; }
     921#endif
    906922#endif
    907923};
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncEntropy.cpp

    r644 r677  
    7979}
    8080
    81 Void TEncEntropy::encodePPS( TComPPS* pcPPS )
    82 {
    83   m_pcEntropyCoderIf->codePPS( pcPPS );
     81Void TEncEntropy::encodePPS( TComPPS* pcPPS
     82#if Q0048_CGS_3D_ASYMLUT
     83  , TEnc3DAsymLUT * pc3DAsymLUT
     84#endif
     85  )
     86{
     87  m_pcEntropyCoderIf->codePPS( pcPPS
     88#if Q0048_CGS_3D_ASYMLUT
     89    , pc3DAsymLUT
     90#endif
     91    );
    8492  return;
    8593}
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncEntropy.h

    r644 r677  
    5050class TEncCavlc;
    5151class SEI;
     52#if Q0048_CGS_3D_ASYMLUT
     53class TEnc3DAsymLUT;
     54#endif
    5255
    5356// ====================================================================================================================
     
    7073  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
    7174  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
    72   virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
     75  virtual Void  codePPS                 ( TComPPS* pcPPS
     76#if Q0048_CGS_3D_ASYMLUT
     77    , TEnc3DAsymLUT * pc3DAsymLUT
     78#endif
     79    )                                      = 0;
    7380  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
    7481
     
    156163  // SPS
    157164  Void encodeSPS               ( TComSPS* pcSPS );
    158   Void encodePPS               ( TComPPS* pcPPS );
     165  Void encodePPS               ( TComPPS* pcPPS
     166#if Q0048_CGS_3D_ASYMLUT
     167    , TEnc3DAsymLUT * pc3DAsymLUT
     168#endif
     169    );
    159170  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
    160171  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r675 r677  
    106106  m_pcPredSearch        = NULL;
    107107#endif
     108#if Q0048_CGS_3D_ASYMLUT
     109  m_temp = NULL;
     110  m_pColorMappedPic = NULL;
     111#endif
    108112  return;
    109113}
     
    111115TEncGOP::~TEncGOP()
    112116{
     117#if Q0048_CGS_3D_ASYMLUT
     118  if(m_pColorMappedPic)
     119  {
     120    m_pColorMappedPic->destroy();
     121    delete m_pColorMappedPic;
     122    m_pColorMappedPic = NULL;               
     123  }
     124  if(m_temp)
     125  {
     126    free_mem2DintWithPad(m_temp, m_iTap>>1, 0);
     127    m_temp = NULL;
     128  }
     129#endif
    113130}
    114131
     
    159176#if SVC_UPSAMPLING
    160177  m_pcPredSearch         = pcTEncTop->getPredSearch();                       ///< encoder search class
     178#endif
     179#if Q0048_CGS_3D_ASYMLUT
     180  if( pcTEncTop->getLayerId() )
     181  {
     182    m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthYLayer[pcTEncTop->getLayerId()-1] , g_bitDepthCLayer[pcTEncTop->getLayerId()-1] , g_bitDepthYLayer[pcTEncTop->getLayerId()] , g_bitDepthCLayer[pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     183    m_Enc3DAsymLUTPPS.create(   m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthYLayer[pcTEncTop->getLayerId()-1] , g_bitDepthCLayer[pcTEncTop->getLayerId()-1] , g_bitDepthYLayer[pcTEncTop->getLayerId()] , g_bitDepthCLayer[pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     184    if(!m_pColorMappedPic)
     185    {
     186      m_pColorMappedPic = new TComPicYuv;
     187      m_pColorMappedPic->create( m_ppcTEncTop[0]->getSourceWidth(), m_ppcTEncTop[0]->getSourceHeight(), CHROMA_420, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     188    }
     189  }
    161190#endif
    162191}
     
    924953        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
    925954
     955#if Q0048_CGS_3D_ASYMLUT
     956        TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
     957        if( pcSlice->getPPS()->getCGSFlag() != Q0048_CGS_3D_ASYMLUT_OFF)
     958        {
     959          if(g_posScalingFactor[refLayerIdc][0] < (1<<16) || g_posScalingFactor[refLayerIdc][1] < (1<<16)) //if(pcPic->isSpatialEnhLayer(refLayerIdc))
     960          {
     961            //downsampling;
     962            downScalePic(pcPic->getPicYuvOrg(), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     963            //pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg()->dump("ds.yuv", true, true);
     964            m_Enc3DAsymLUTPPS.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     965            m_Enc3DAsymLUTPicUpdate.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     966          }
     967          else
     968          {
     969            m_Enc3DAsymLUTPPS.setDsOrigPic(pcPic->getPicYuvOrg());
     970            m_Enc3DAsymLUTPicUpdate.setDsOrigPic(pcPic->getPicYuvOrg());
     971          }
     972
     973          Bool bSignalPPS = m_bSeqFirst;
     974          bSignalPPS |= m_pcCfg->getGOPSize() > 1 ? pocCurr % m_pcCfg->getIntraPeriod() == 0 : pocCurr % m_pcCfg->getFrameRate() == 0;
     975          xDetermin3DAsymLUT( pcSlice , pcPic , refLayerIdc , m_pcCfg , bSignalPPS );
     976          m_Enc3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),  m_pColorMappedPic );
     977          pBaseColRec = m_pColorMappedPic;
     978        }
     979#endif
    926980#if SVC_UPSAMPLING
    927981        if( pcPic->isSpatialEnhLayer(refLayerIdc))
     
    941995#if O0215_PHASE_ALIGNMENT
    942996#if O0194_JOINT_US_BITSHIFT
     997#if Q0048_CGS_3D_ASYMLUT
     998          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     999#else
    9431000          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1001#endif
     1002#else
     1003#if Q0048_CGS_3D_ASYMLUT
     1004          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    9441005#else
    9451006          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    9461007#endif
     1008#endif
    9471009#else
    9481010#if O0194_JOINT_US_BITSHIFT
     1011#if Q0048_CGS_3D_ASYMLUT
     1012          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1013#else
    9491014          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1015#endif
     1016#else
     1017#if Q0048_CGS_3D_ASYMLUT
     1018          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    9501019#else
    9511020          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    9521021#endif
    9531022#endif
     1023#endif
    9541024        }
    9551025        else
    9561026        {
     1027#if Q0048_CGS_3D_ASYMLUT
     1028          pcPic->setFullPelBaseRec( refLayerIdc, pBaseColRec );
     1029#else
    9571030          pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
     1031#endif
    9581032        }
    9591033        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
     
    18841958      assert( pcSlice->getPPS()->getPPSId() == 0 || pcSlice->getPPS()->getPPSId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pcSlice->getPPS()->getPPSId()) );
    18851959#endif
    1886       m_pcEntropyCoder->encodePPS(pcSlice->getPPS());
     1960      m_pcEntropyCoder->encodePPS(pcSlice->getPPS()
     1961#if Q0048_CGS_3D_ASYMLUT
     1962        , & m_Enc3DAsymLUTPPS
     1963#endif
     1964        );
    18871965      writeRBSPTrailingBits(nalu.m_Bitstream);
    18881966      accessUnit.push_back(new NALUnitEBSP(nalu));
     
    19171995      m_bSeqFirst = false;
    19181996    }
     1997#if Q0048_CGS_3D_ASYMLUT
     1998    else if( m_pcCfg->getCGSFlag() == Q0048_CGS_3D_ASYMLUT_PPSUPDATE && pcSlice->getLayerId() && pcSlice->getCGSOverWritePPS() )
     1999    {
     2000#if SVC_EXTENSION
     2001      OutputNALUnit nalu(NAL_UNIT_PPS, 0, m_layerId);
     2002#endif
     2003
     2004      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2005      m_pcEntropyCoder->encodePPS(pcSlice->getPPS() , &m_Enc3DAsymLUTPPS );
     2006      writeRBSPTrailingBits(nalu.m_Bitstream);
     2007      accessUnit.push_back(new NALUnitEBSP(nalu));
     2008    }
     2009#endif
    19192010
    19202011    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
     
    33393430    printf("]");
    33403431  }
     3432#if Q0048_CGS_3D_ASYMLUT
     3433  pcPic->setFrameBit( (Int)uibits );
     3434  if( m_layerId && pcSlice->getPPS()->getCGSFlag())
     3435    m_Enc3DAsymLUTPicUpdate.updatePicCGSBits( pcSlice , m_Enc3DAsymLUTPPS.getPPSBit() );
     3436#endif
    33413437}
    33423438
     
    40454141#endif
    40464142
     4143#if Q0048_CGS_3D_ASYMLUT
     4144Void TEncGOP::xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS )
     4145{
     4146  Int nCGSFlag = pSlice->getPPS()->getCGSFlag();
     4147  m_Enc3DAsymLUTPPS.setPPSBit( 0 );
     4148  Double dErrorUpdatedPPS = 0 , dErrorPPS = 0;
     4149  dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB() );
     4150  if( bSignalPPS )
     4151  {
     4152    m_Enc3DAsymLUTPPS.copy3DAsymLUT( &m_Enc3DAsymLUTPicUpdate );
     4153    pSlice->setCGSOverWritePPS( 1 ); // regular PPS update
     4154  }
     4155  else if( nCGSFlag == Q0048_CGS_3D_ASYMLUT_PPSUPDATE )
     4156  {
     4157    dErrorPPS = m_Enc3DAsymLUTPPS.estimateDistWithCur3DAsymLUT( pCurPic , refLayerIdc );
     4158    Double dFactor = pCfg->getIntraPeriod() == 1 ? 0.99 : 0.9;
     4159    pSlice->setCGSOverWritePPS( dErrorUpdatedPPS < dFactor * dErrorPPS );
     4160    if( pSlice->getCGSOverWritePPS() )
     4161      m_Enc3DAsymLUTPPS.copy3DAsymLUT( &m_Enc3DAsymLUTPicUpdate );
     4162  }
     4163  pSlice->getPPS()->setCGSOutputBitDepthY( m_Enc3DAsymLUTPPS.getOutputBitDepthY() );
     4164  pSlice->getPPS()->setCGSOutputBitDepthC( m_Enc3DAsymLUTPPS.getOutputBitDepthC() );
     4165}
     4166
     4167Void TEncGOP::downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest)
     4168{
     4169  Int inputBitDepth = g_bitDepthYLayer[m_layerId];
     4170  Int outputBitDepth = g_bitDepthYLayer[m_layerId];
     4171  {
     4172    pcYuvSrc->setBorderExtension(false);
     4173    pcYuvSrc->extendPicBorder   (); // extend the border.
     4174    pcYuvSrc->setBorderExtension(false);
     4175
     4176    Int iWidth = pcYuvSrc->getWidth();
     4177    Int iHeight =pcYuvSrc->getHeight();
     4178
     4179    if(!m_temp)
     4180      initDs(iWidth, iHeight, m_pcCfg->getIntraPeriod()>1);
     4181
     4182    filterImg(pcYuvSrc->getLumaAddr(), pcYuvSrc->getStride(), pcYuvDest->getLumaAddr(), pcYuvDest->getStride(), iHeight, iWidth,  inputBitDepth-outputBitDepth, 0);
     4183    filterImg(pcYuvSrc->getCbAddr(), pcYuvSrc->getCStride(), pcYuvDest->getCbAddr(), pcYuvDest->getCStride(), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 1);
     4184    filterImg(pcYuvSrc->getCrAddr(), pcYuvSrc->getCStride(), pcYuvDest->getCrAddr(), pcYuvDest->getCStride(), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 2); 
     4185  }
     4186}
     4187const int TEncGOP::m_phase_filter_0_t0[4][13]={
     4188  {0,  2,  -3,  -9,   6,  39,  58,  39,   6,  -9,  -3,  2,  0}, 
     4189  {0, 0,  0,  -2,  8,-20, 116, 34, -10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4190  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4191  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4192};
     4193
     4194const int TEncGOP::m_phase_filter_0_t1[4][13]={
     4195  {0,  4,  0,  -12, 0,  40,  64,  40, 0, -12,  0,  4,  0},
     4196  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4197  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4198  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4199};
     4200const int TEncGOP::m_phase_filter_0_t1_chroma[4][13]={
     4201  {0,  0,  0,   0,  0,   0,  128, 0,  0,  0,  0,  0,  0},
     4202  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4203  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4204  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4205};
     4206
     4207const int TEncGOP::m_phase_filter_1[8][13]={
     4208  {0,   0,  5,  -6,  -10,37,  76,  37,-10,   -6, 5,  0,   0},   
     4209  {0,  -1,  5,  -3,  -12,29,  75,  45,  -7,   -8, 5,  0,   0},   
     4210  {0,  -1,  4,  -1,  -13,22,  73,  52,  -3,  -10, 4,  1,   0},   
     4211  {0,  -1,  4,   1,  -13,14,  70,  59,   2,  -12, 3,  2,  -1}, 
     4212  {0,  -1,  3,   2,  -13, 8,  65,  65,   8,  -13, 2,  3,  -1},   
     4213  {0,  -1,  2,   3,  -12, 2,  59,  70,  14,  -13, 1,  4,  -1},   
     4214  {0,   0,  1,   4,  -10,-3,  52,  73,  22,  -13,-1,  4,  -1},   
     4215  {0,   0,  0,   5,   -8,-7,  45,  75,  29,  -12,-3,  5,  -1}   
     4216};
     4217
     4218Void TEncGOP::filterImg(
     4219    Pel           *src,
     4220    Int           iSrcStride,
     4221    Pel           *dst,
     4222    Int           iDstStride,
     4223    Int           height1, 
     4224    Int           width1, 
     4225    Int           shift,
     4226    Int           plane)
     4227{
     4228  Int length = m_iTap;
     4229  Int height2,width2;
     4230  Int k,iSum;
     4231  Int i0, div_i0, i1;
     4232  Int j0, div_j0, j1;
     4233  const Int *p_filter;
     4234  Pel *p_src, *p_dst;
     4235  Pel *p_src_line, *p_dst_line;
     4236  Int **p_temp, *p_tmp;
     4237  Int shift2 = 2*7+shift;
     4238  Int shift_round = (1 << (shift2 - 1));
     4239  Int iMax = (1<<(g_bitDepthY-shift))-1;
     4240  height2 = (height1 * m_iM) / m_iN;
     4241  width2  = (width1  * m_iM) / m_iN;
     4242
     4243  m_phase_filter = plane? m_phase_filter_chroma : m_phase_filter_luma;
     4244
     4245  // horizontal filtering
     4246  p_src_line = src;
     4247  for(j1 = 0; j1 < height1; j1++)
     4248  {
     4249    i0=-m_iN;
     4250    p_tmp = m_temp[j1];
     4251   
     4252    for(i1 = 0; i1 < width2; i1++)
     4253    {
     4254      i0      += m_iN;
     4255      div_i0   = (i0 / m_iM);
     4256      //p_src    = &src[j1][ div_i0 - (length >> 1)];
     4257      p_src    =  p_src_line + ( div_i0 - (length >> 1));
     4258      p_filter = m_phase_filter[i0 - div_i0 * m_iM]; // phase_filter[i0 % M]
     4259      iSum     = 0;
     4260      for(k = 0; k < length; k++)
     4261      {
     4262        iSum += (*p_src++) * (*p_filter++);
     4263      }
     4264      *p_tmp++ = iSum;
     4265    }
     4266    p_src_line +=  iSrcStride;
     4267  }
     4268
     4269  // pad temp (vertical)
     4270  for (k=-(length>>1); k<0; k++)
     4271    memcpy(m_temp[k], m_temp[0], width2*sizeof(int));
     4272  for (k=height1; k<(height1+(length>>1)); k++)
     4273    memcpy(m_temp[k], m_temp[k-1], (width2)* sizeof(int));
     4274
     4275  // vertical filtering
     4276  j0 = (plane == 0) ? -m_iN : -(m_iN-1);
     4277 
     4278  p_dst_line = dst;
     4279  for(j1 = 0; j1 < height2; j1++)
     4280  {
     4281    j0      += m_iN;
     4282    div_j0   = (j0 / m_iM);
     4283    //p_dst    = dst[j1];
     4284    p_dst = p_dst_line;
     4285    p_temp   = &m_temp[div_j0 - (length>>1)];
     4286    p_filter = m_phase_filter[j0 - div_j0 * m_iM]; // phase_filter[j0 % M]
     4287    for(i1 = 0; i1 < width2;i1++)
     4288    {
     4289      iSum=0;
     4290      for(k = 0; k < length; k++)
     4291      {
     4292        iSum += p_temp[k][i1] * p_filter[k];
     4293      }
     4294      iSum=((iSum + shift_round) >> shift2);
     4295      *p_dst++ = (short)(iSum > iMax ? iMax : (iSum < 0 ? 0 : iSum));
     4296    }
     4297    p_dst_line += iDstStride;
     4298  }
     4299}
     4300
     4301Void TEncGOP::initDs(Int iWidth, Int iHeight, Int iType)
     4302{
     4303  m_iTap = 13;
     4304  if(g_posScalingFactor[0][0] == (1<<15))
     4305  {
     4306    m_iM = 4;
     4307    m_iN = 8;
     4308    m_phase_filter_luma = iType? m_phase_filter_0_t1 : m_phase_filter_0_t0;
     4309    m_phase_filter_chroma = m_phase_filter_0_t1_chroma;
     4310  }
     4311  else
     4312  {
     4313    m_iM = 8;
     4314    m_iN = 12;
     4315    m_phase_filter_luma = m_phase_filter_chroma =  m_phase_filter_1;
     4316    m_phase_filter = m_phase_filter_1;
     4317  }
     4318
     4319  get_mem2DintWithPad (&m_temp, iHeight, iWidth*m_iM/m_iN,   m_iTap>>1, 0);
     4320}
     4321
     4322Int TEncGOP::get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX)
     4323{
     4324  Int i;
     4325  Int *curr = NULL;
     4326  Int iHeight, iWidth;
     4327
     4328  iHeight = dim0+2*iPadY;
     4329  iWidth = dim1+2*iPadX;
     4330  (*array2D) = (Int**)malloc(iHeight*sizeof(Int*));
     4331  *(*array2D) = (Int* )xMalloc(Int, iHeight*iWidth);
     4332
     4333  (*array2D)[0] += iPadX;
     4334  curr = (*array2D)[0];
     4335  for(i = 1 ; i < iHeight; i++)
     4336  {
     4337    curr += iWidth;
     4338    (*array2D)[i] = curr;
     4339  }
     4340  (*array2D) = &((*array2D)[iPadY]);
     4341
     4342  return 0;
     4343}
     4344
     4345Void TEncGOP::free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX)
     4346{
     4347  if (array2D)
     4348  {
     4349    if (*array2D)
     4350      xFree(array2D[-iPadY]-iPadX);
     4351    else
     4352      printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     4353
     4354    free (&array2D[-iPadY]);
     4355  }
     4356  else
     4357  {
     4358    printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     4359  }
     4360}
     4361#endif
    40474362#endif //SVC_EXTENSION
    40484363
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncGOP.h

    r652 r677  
    5454#include "TEncSbac.h"
    5555#include "SEIwrite.h"
     56#if Q0048_CGS_3D_ASYMLUT
     57#include "TEnc3DAsymLUT.h"
     58#endif
    5659
    5760#include "TEncAnalyze.h"
     
    135138  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
    136139#endif 
     140#if Q0048_CGS_3D_ASYMLUT
     141  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
     142  TEnc3DAsymLUT           m_Enc3DAsymLUTPPS;
     143  TComPicYuv*             m_pColorMappedPic;
     144
     145  Int m_iTap;
     146  const Int (*m_phase_filter)[13];
     147  const Int (*m_phase_filter_luma)[13];
     148  const Int (*m_phase_filter_chroma)[13];
     149  Int m_iM, m_iN;
     150  static const Int m_phase_filter_0_t0[4][13];
     151  static const Int m_phase_filter_0_t1[4][13];
     152  static const Int m_phase_filter_0_t1_chroma[4][13];
     153  static const Int m_phase_filter_1[8][13];
     154  Int   **m_temp;
     155#endif
    137156#endif
    138157 
     
    217236  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice);
    218237#endif
     238#if Q0048_CGS_3D_ASYMLUT
     239  Void xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS );
     240  Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest);
     241  Void downScaleComponent2x2( const Pel* pSrc, Pel* pDest, const Int iSrcStride, const Int iDestStride, const Int iSrcWidth, const Int iSrcHeight, const Int inputBitDepth, const Int outputBitDepth );
     242  inline Short  xClip( Short x , Int bitdepth );
     243  Void initDs(Int iWidth, Int iHeight, Int iType);
     244  Void filterImg(
     245    Pel           *src,
     246    Int           iSrcStride,
     247    Pel           *dst,
     248    Int           iDstStride,
     249    Int           height1, 
     250    Int           width1, 
     251    Int           shift,
     252    Int           plane);
     253
     254  Int get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX);
     255  Void free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX);
     256#endif
    219257#endif //SVC_EXTENSION
    220258};// END CLASS DEFINITION TEncGOP
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncSbac.cpp

    r644 r677  
    248248}
    249249
    250 Void TEncSbac::codePPS( TComPPS* pcPPS )
     250Void TEncSbac::codePPS( TComPPS* pcPPS
     251#if Q0048_CGS_3D_ASYMLUT
     252  , TEnc3DAsymLUT * pc3DAsymLUT
     253#endif
     254  )
    251255{
    252256  assert (0);
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncSbac.h

    r652 r677  
    9292  Void  codeVPS                 ( TComVPS* pcVPS );
    9393  Void  codeSPS                 ( TComSPS* pcSPS     );
    94   Void  codePPS                 ( TComPPS* pcPPS     );
     94  Void  codePPS                 ( TComPPS* pcPPS     
     95#if Q0048_CGS_3D_ASYMLUT
     96    , TEnc3DAsymLUT * pc3DAsymLUT
     97#endif
     98    );
    9599  Void  codeSliceHeader         ( TComSlice* pcSlice );
    96100  Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r644 r677  
    795795          Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    796796
    797           if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths )
     797          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths
     798#if Q0048_CGS_3D_ASYMLUT
     799            || m_cPPS.getCGSFlag() > 0
     800#endif
     801            )
    798802#else
    799803          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     
    11881192  }
    11891193#endif
     1194#if Q0048_CGS_3D_ASYMLUT
     1195  m_cPPS.setCGSFlag( m_nCGSFlag );
     1196#endif
    11901197}
    11911198
Note: See TracChangeset for help on using the changeset viewer.