Changeset 25 in SHVCSoftware for branches/SHM-1.0-dev


Ignore:
Timestamp:
4 Feb 2013, 08:30:23 (12 years ago)
Author:
qualcomm
Message:

L0336: motion field mapping of inter-layer reference picture from Qualcomm, cjianle@…

Location:
branches/SHM-1.0-dev/source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-1.0-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r2 r25  
    9898    m_acTEncTop[layer].setFrameToBeEncoded             ( m_iFrameToBeEncoded );
    9999
     100#if REF_IDX_MFM
     101        if(layer == 0)
     102                m_acTEncTop[layer].setMFMEnabledFlag(false);
     103        else
     104                m_acTEncTop[layer].setMFMEnabledFlag(true);
     105#endif
    100106    // set layer ID
    101107    m_acTEncTop[layer].setLayerId ( layer );
  • branches/SHM-1.0-dev/source/Lib/TLibCommon/TComDataCU.h

    r23 r25  
    597597};
    598598
     599#if REF_IDX_MFM
     600class TComUpsampledMvFieldCU
     601{
     602  TComCUMvField m_acCUMvField[2];  //array of motion vector field
     603  UInt          m_uiCUAddr;
     604  UInt          m_uiCUPelX;
     605  UInt          m_uiCUPelY;
     606
     607public:
     608  Void          createMvField(Int CUAddr, Int uiWidthInCU, UInt uiNumPartitions)
     609  {
     610    m_uiCUAddr      = CUAddr;
     611    m_uiCUPelX      = (CUAddr % uiWidthInCU) * g_uiMaxCUWidth;
     612    m_uiCUPelY      = (CUAddr / uiWidthInCU) * g_uiMaxCUWidth;
     613
     614    m_acCUMvField[0].create( uiNumPartitions );
     615                m_acCUMvField[1].create( uiNumPartitions );
     616    return;
     617  }
     618
     619  Void          initMvField()
     620  {
     621    m_acCUMvField[0].clearMvField();
     622    m_acCUMvField[1].clearMvField();
     623    return;
     624  }
     625  Void          destroy()
     626  {
     627    m_acCUMvField[0].destroy();
     628    m_acCUMvField[1].destroy();
     629    return;
     630  }
     631  TComCUMvField* getCUMvField         ( RefPicList e )          { return  &m_acCUMvField[e]; }
     632  UInt           getAddr              ()                        { return  m_uiCUAddr;}
     633  UInt           getCUPelX            ()                        { return  m_uiCUPelX; }
     634  UInt           getCUPelY            ()                        { return  m_uiCUPelY; }
     635};
     636#endif
     637
    599638namespace RasterAddress
    600639{
  • branches/SHM-1.0-dev/source/Lib/TLibCommon/TComMotionInfo.h

    r2 r25  
    158158  Void compress(Char* pePredMode, Int scale);
    159159#endif
     160
     161#if REF_IDX_MFM
     162  UInt    getNumPartition()    { return m_uiNumPartition; }       
     163  Void    setMvField( TComMvField const  & mvField, Int iIdx)
     164  {
     165    m_pcMv[iIdx]      = mvField.getMv();
     166    m_piRefIdx[iIdx]  = mvField.getRefIdx();
     167    return;
     168  }
     169
     170  Void    setMvField( TComMv  cMv,  Int iRefIdx, Int iIdx)
     171  {
     172    m_pcMv[iIdx]      = cMv;
     173    m_piRefIdx[iIdx]  = iRefIdx;
     174    return;
     175  }
     176#endif
    160177};
    161178
  • branches/SHM-1.0-dev/source/Lib/TLibCommon/TComPic.cpp

    r21 r25  
    6868, m_bSpatialEnhLayer( false )
    6969, m_pcFullPelBaseRec( NULL )
    70 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE
     70#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
    7171, m_bIsILR                                (false)
     72#endif
     73#if REF_IDX_MFM
     74, m_bIsUpsampledMvField                   (false)
     75, m_apcTComUpsampledMvFieldCU             (NULL)
     76, m_peUpsampledPredMode                   (NULL)
     77, m_iNumCUInUpsampledPic                  (-1)
    7278#endif
    7379#endif
     
    554560    upsampledRowWidthCroma);
    555561}
     562
     563#if REF_IDX_MFM
     564Void TComPic::createUpSampledMvField(Int upSampledHeight, Int upSampledWidth, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth )
     565{
     566        UInt uiNumPartitions   = 1<<(uiMaxDepth<<1);
     567        UInt uiWidthInCU       = ( upSampledWidth % uiMaxWidth  ) ? upSampledWidth /uiMaxWidth  + 1 : upSampledWidth /uiMaxWidth;
     568  UInt uiHeightInCU      = ( upSampledHeight% uiMaxHeight ) ? upSampledHeight/uiMaxHeight + 1 : upSampledHeight/uiMaxHeight;
     569        UInt uiNumCUsInFrame   = uiWidthInCU * uiHeightInCU;
     570        m_iNumCUInUpsampledPic = uiNumCUsInFrame;
     571
     572        m_apcTComUpsampledMvFieldCU     = new TComUpsampledMvFieldCU*[uiNumCUsInFrame];
     573        m_peUpsampledPredMode           = new char*[uiNumCUsInFrame];
     574
     575        for (Int i = 0; i < uiNumCUsInFrame; i++ )
     576        {
     577                m_apcTComUpsampledMvFieldCU[i] = new TComUpsampledMvFieldCU;
     578                m_apcTComUpsampledMvFieldCU[i]->createMvField(i, uiWidthInCU, uiNumPartitions);  //create Mv field
     579                m_apcTComUpsampledMvFieldCU[i]->initMvField();                                   //initialize Mv field
     580
     581          m_peUpsampledPredMode[i]     = new char[uiNumPartitions];
     582        }
     583
     584        return;
     585}
     586
     587Void TComPic::deriveUnitIdxBase(UInt uiUpsamplePelX, UInt uiUpsamplePelY, float ratio, UInt& uiBaseCUAddr, UInt& uiBaseAbsPartIdx)
     588{
     589  //pixel in the base layer
     590  UInt uiPelX       = (UInt)((float)uiUpsamplePelX/ratio);
     591  UInt uiPelY       = (UInt)((float)uiUpsamplePelY/ratio);
     592  UInt uiBaseWidth  = getPicYuvRec()->getWidth();
     593  UInt uiBaseHeight = getPicYuvRec()->getHeight();
     594
     595  UInt uiWidthInCU       = ( uiBaseWidth % g_uiMaxCUWidth  ) ? uiBaseWidth /g_uiMaxCUWidth  + 1 : uiBaseWidth /g_uiMaxCUWidth;
     596  UInt uiHeightInCU      = ( uiBaseHeight% g_uiMaxCUHeight ) ? uiBaseHeight/ g_uiMaxCUHeight + 1 : uiBaseHeight/ g_uiMaxCUHeight;
     597
     598  uiPelX     = (UInt)Clip3<UInt>(0, uiWidthInCU * g_uiMaxCUWidth - 1, uiPelX);
     599  uiPelY     = (UInt)Clip3<UInt>(0, uiHeightInCU * g_uiMaxCUHeight - 1, uiPelY);
     600 
     601  uiBaseCUAddr = uiPelY / g_uiMaxCUHeight * uiWidthInCU + uiPelX / g_uiMaxCUWidth;
     602
     603  UInt uiWidthMinPU = g_uiMaxCUWidth / (1<<g_uiMaxCUDepth);
     604  UInt uiHeightMinPU = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
     605 
     606  UInt uiAbsPelX = uiPelX - (uiPelX / g_uiMaxCUWidth) * g_uiMaxCUWidth;
     607  UInt uiAbsPelY = uiPelY - (uiPelY / g_uiMaxCUHeight) * g_uiMaxCUHeight;
     608
     609  UInt RasterIdx = uiAbsPelY / uiHeightMinPU * (g_uiMaxCUWidth/uiWidthMinPU) + uiAbsPelX / uiWidthMinPU;
     610  uiBaseAbsPartIdx = g_auiRasterToZscan[RasterIdx];
     611
     612  return;
     613}
     614
     615
     616//MV field up-sampling
     617Void TComPic::doTheUpSampleMvField(UInt upSampleRatio)
     618{
     619  UInt uiWidthMinPU      = g_uiMaxCUWidth/(1<<g_uiMaxCUDepth);
     620  UInt uiHeightMinPU     = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
     621  UInt uiNumPartitions   = 1<<(g_uiMaxCUDepth<<1);
     622  UInt uiPelX, uiPelY;
     623  UInt uiBaseCUAddr, uiBaseAbsPartIdx;
     624  float ratio = 0;
     625
     626  //????????????????????????????
     627  if(upSampleRatio == 0)       //ONE_TO_ONE
     628    ratio = 1.0;
     629  else if(upSampleRatio == 1)  //ONE_TO_TWO
     630    ratio = 2.0;
     631  else if(upSampleRatio == 2)  //TWO_TO_THREE
     632    ratio = 1.5;
     633
     634  for(UInt uiCUAddr = 0; uiCUAddr < m_iNumCUInUpsampledPic; uiCUAddr++)  //each LCU
     635  {
     636    TComUpsampledMvFieldCU*& pcMvFieldCU = getUpsampledMvFieldCU(uiCUAddr);
     637    pcMvFieldCU->initMvField();                                          //MV field initialization
     638
     639    Int unitNum = max (1, (Int)((16/uiWidthMinPU)*(16/uiHeightMinPU)) );
     640    for(UInt uiAbsPartIdx = 0; uiAbsPartIdx < uiNumPartitions; uiAbsPartIdx+=unitNum )  //each 16x16 unit
     641    {
     642      //pixel position of each unit in up-sampled layer
     643      uiPelX = pcMvFieldCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
     644      uiPelY = pcMvFieldCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
     645
     646      //????????????????????????????
     647      deriveUnitIdxBase(uiPelX + 8, uiPelY + 8, ratio, uiBaseCUAddr, uiBaseAbsPartIdx);
     648      if( (getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_NONE) && (getCU(uiBaseCUAddr)->getPredictionMode(uiBaseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
     649      {
     650        for(UInt list = 0; list < 2; list++)  //each list
     651        {
     652          TComMv cMv = getCU(uiBaseCUAddr)->getCUMvField((RefPicList)list)->getMv(uiBaseAbsPartIdx);
     653          Int refIdx = getCU(uiBaseCUAddr)->getCUMvField((RefPicList)list)->getRefIdx(uiBaseAbsPartIdx);
     654        //????????????????????????????
     655        Int Hor = (Short) (ratio * cMv.getHor());
     656        Int Ver = (Short) (ratio * cMv.getVer());
     657
     658        TComMv cScaledMv(Hor, Ver);
     659        TComMvField sMvField;
     660        sMvField.setMvField(cScaledMv, refIdx);
     661
     662        pcMvFieldCU->getCUMvField((RefPicList)list)->setMvField(sMvField, uiAbsPartIdx);
     663        m_peUpsampledPredMode[uiCUAddr][uiAbsPartIdx] = MODE_INTER;
     664        }
     665      }
     666      else
     667      {
     668        TComMvField zeroMvField;  //zero MV and invalid reference index
     669        pcMvFieldCU->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, uiAbsPartIdx);
     670        pcMvFieldCU->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, uiAbsPartIdx);
     671
     672          m_peUpsampledPredMode[uiCUAddr][uiAbsPartIdx]     = MODE_INTRA;
     673      }
     674
     675      //MV compression
     676      for(UInt i = 1; i < unitNum; i++ ) 
     677      {
     678        pcMvFieldCU->getCUMvField(REF_PIC_LIST_0)->setMvField(pcMvFieldCU->getCUMvField(REF_PIC_LIST_0)->getMv(uiAbsPartIdx), pcMvFieldCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx), uiAbsPartIdx + i);
     679        pcMvFieldCU->getCUMvField(REF_PIC_LIST_1)->setMvField(pcMvFieldCU->getCUMvField(REF_PIC_LIST_1)->getMv(uiAbsPartIdx), pcMvFieldCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx), uiAbsPartIdx + i);
     680          m_peUpsampledPredMode[uiCUAddr][uiAbsPartIdx+i]     = m_peUpsampledPredMode[uiCUAddr][uiAbsPartIdx];
     681      }
     682
     683    }  //ending for(UInt uiAbsPartIdx = 0; uiAbsPartIdx < uiNumPartitions; uiAbsPartIdx++)
     684  }  //ending for(UInt uiCUAddr = 0; uiCUAddr < m_iNumCUInUpsampledPic; uiCUAddr++)
     685  return;
     686}
     687
     688Void TComPic::copyUpsampledMvField(TComPic* pcPicBase)
     689{
     690  assert( getPicSym()->getNumberOfCUsInFrame() == pcPicBase->getNumCUInUpsampledPic() );
     691
     692  for(UInt cuIdx = 0; cuIdx < getPicSym()->getNumberOfCUsInFrame(); cuIdx++)  //each LCU
     693  {
     694    UInt uiNumPartitions   = 1<<(g_uiMaxCUDepth<<1);
     695
     696    TComDataCU*             pcCUDes = getCU(cuIdx);
     697    TComUpsampledMvFieldCU* pcMvFieldCU = pcPicBase->getUpsampledMvFieldCU(cuIdx);
     698    for(UInt list = 0; list < 2; list++)  //each reference list
     699    {
     700      TComCUMvField* pcCUMvFieldDes = pcCUDes->getCUMvField((RefPicList)list);
     701      TComCUMvField* pcCUMvFieldOrg = pcMvFieldCU->getCUMvField((RefPicList)list);
     702
     703      assert(pcCUMvFieldDes->getNumPartition() == pcCUMvFieldOrg->getNumPartition());
     704      assert(pcCUMvFieldDes->getNumPartition() == uiNumPartitions);
     705
     706      pcCUMvFieldDes->clearMvField();
     707      pcCUMvFieldDes->copyFrom(pcCUMvFieldOrg, pcCUMvFieldDes->getNumPartition(), 0);     
     708    }
     709
     710    char* pPredModeSrc = pcPicBase->getUpsampledPreModeCU(cuIdx);
     711    char* pPredModeDst = pcCUDes->getPredictionMode();
     712    memcpy(pPredModeDst, pPredModeSrc, sizeof(char)*uiNumPartitions);
     713    memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(char)*uiNumPartitions);
     714  }
     715}
    556716#endif
    557717
     718#endif
     719
    558720//! \}
  • branches/SHM-1.0-dev/source/Lib/TLibCommon/TComPic.h

    r21 r25  
    8888  Bool                  m_bSpatialEnhLayer;       // whether current layer is a spatial enhancement layer,
    8989  TComPicYuv*           m_pcFullPelBaseRec;    // upsampled base layer recontruction for difference domain inter prediction
    90 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE
     90#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
    9191  Bool                  m_bIsILR;                 //  Is ILR picture
     92#endif
     93#if REF_IDX_MFM
     94  Bool                          m_bIsUpsampledMvField;
     95  TComUpsampledMvFieldCU**      m_apcTComUpsampledMvFieldCU;
     96  Char**                        m_peUpsampledPredMode;
     97  Int                           m_iNumCUInUpsampledPic;
    9298#endif
    9399#endif
     
    118124  TComPicYuv*   getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
    119125#endif
    120 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE
     126#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
    121127  Void          setIsILR( Bool bIsILR)      {m_bIsILR = bIsILR;}
    122128  Bool          getIsILR()                  {return m_bIsILR;}
     129#endif
     130#if REF_IDX_MFM
     131  Bool          IsUpsampledMvField()                         { return m_bIsUpsampledMvField; }
     132  Void          setUpsampledMvField(Bool isUpsampledMvField) { m_bIsUpsampledMvField = isUpsampledMvField; }
     133  Bool          upsampledMvFieldIsNull()     
     134                {
     135                  if (m_apcTComUpsampledMvFieldCU == NULL)
     136                    return true;
     137                  else
     138                    return false;
     139                }
     140  Void          createUpSampledMvField(  Int upSampledHeight, Int upSampledWidth, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth );
     141  Void          doTheUpSampleMvField  (  UInt upSampleRatio );
     142  Void          copyUpsampledMvField  (  TComPic* pcPicBase );
     143  Void deriveUnitIdxBase(UInt uiUpsamplePelX, UInt uiUpsamplePelY, float ratio, UInt& uiBaseCUAddr, UInt& uiBaseAbsPartIdx);
     144
     145  Int           getNumCUInUpsampledPic()       { return m_iNumCUInUpsampledPic; }
     146  TComUpsampledMvFieldCU*&  getUpsampledMvFieldCU( UInt uiCUAddr )  { return m_apcTComUpsampledMvFieldCU[uiCUAddr]; }
     147  char*  getUpsampledPreModeCU( UInt uiCUAddr )  { return m_peUpsampledPredMode[uiCUAddr]; }
     148
     149
    123150#endif
    124151
  • branches/SHM-1.0-dev/source/Lib/TLibCommon/TComSlice.cpp

    r11 r25  
    519519  if(getSPS()->getLayerId() && m_eSliceType != I_SLICE)
    520520  {
     521#if REF_IDX_MFM
     522    assert(iRefPicNum == 1);
     523    if(getPOC() != 0)
     524    {
     525      assert(getBaseColPic()->IsUpsampledMvField() == true);
     526      pIlpPicList[0]->copyUpsampledMvField(getBaseColPic());
     527    }
     528#endif
    521529    //add to list 0;
    522530    Int iOffset;
     
    546554  }
    547555}
     556
     557#if REF_IDX_MFM
     558Void TComSlice::setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL)
     559{
     560  //set reference picture POC of each ILP reference
     561  Int thePoc = ilpPic[0]->getPOC();
     562  assert(thePoc >= 0);
     563  assert(thePoc == pcRefPicBL->getPOC());
     564
     565  //initialize reference POC of ILP
     566  for(Int refIdx = 0; refIdx < MAX_NUM_REF; refIdx++)
     567  {
     568    ilpPic[0]->getSlice(0)->setRefPOC(0, REF_PIC_LIST_0, refIdx);
     569    ilpPic[0]->getSlice(0)->setRefPOC(0, REF_PIC_LIST_1, refIdx);
     570
     571    ilpPic[0]->getSlice(0)->setRefPic(NULL, REF_PIC_LIST_0, refIdx);
     572    ilpPic[0]->getSlice(0)->setRefPic(NULL, REF_PIC_LIST_1, refIdx);
     573  }
     574
     575  //set reference POC of ILP
     576  ilpPic[0]->getSlice(0)->setNumRefIdx(REF_PIC_LIST_0, pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0));
     577  assert(ilpPic[0]->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0) <= MAX_NUM_REF);
     578  ilpPic[0]->getSlice(0)->setNumRefIdx(REF_PIC_LIST_1, pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1));
     579  assert(ilpPic[0]->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1) <= MAX_NUM_REF);
     580 
     581  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0); refIdx++)
     582    ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(REF_PIC_LIST_0, refIdx), REF_PIC_LIST_0, refIdx);
     583
     584  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1); refIdx++)
     585    ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(REF_PIC_LIST_1, refIdx), REF_PIC_LIST_1, refIdx);
     586
     587  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_0); refIdx++)
     588    ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(REF_PIC_LIST_0, refIdx), REF_PIC_LIST_0, refIdx);
     589
     590  for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(REF_PIC_LIST_1); refIdx++)
     591    ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(REF_PIC_LIST_1, refIdx), REF_PIC_LIST_1, refIdx);
     592return;
     593}
     594#endif
     595
    548596#endif
    549597
  • branches/SHM-1.0-dev/source/Lib/TLibCommon/TComSlice.h

    r11 r25  
    649649  UInt m_layerId;
    650650#endif
     651#if REF_IDX_MFM
     652  Bool m_bMFMEnabledFlag;
     653#endif
    651654public:
    652655  TComSPS();
     
    837840  UInt     getLayerId() { return m_layerId; }
    838841#endif
     842#if REF_IDX_MFM
     843  Void     setMFMEnabledFlag(Bool flag) {m_bMFMEnabledFlag = flag;}
     844  Bool     getMFMEnabledFlag()          {return m_bMFMEnabledFlag;}
     845#endif
    839846};
    840847
     
    14481455  TComPicYuv* getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
    14491456#endif
     1457
     1458#if REF_IDX_MFM
     1459  Void      setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL);
     1460#endif
     1461
    14501462  Void      setRefPicList       ( TComList<TComPic*>& rcListPic );
    14511463  Void      setRefPOCList       ();
  • branches/SHM-1.0-dev/source/Lib/TLibCommon/TypeDef.h

    r21 r25  
    6060#define REF_IDX_ME_ZEROMV                1      ///< L0051: use zero motion for inter-layer reference picture (without fractional ME)
    6161#define ENCODER_FAST_MODE                1      ///< L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
     62#define REF_IDX_MFM                      1      ///< L0336: motion vector mapping of inter-layer reference picture
    6263#else
    6364#define INTRA_BL                         1      ///< inter-layer texture prediction
  • branches/SHM-1.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r2 r25  
    844844#endif
    845845  READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" );            pcSPS->setTMVPFlagsPresent(uiCode);
     846#if REF_IDX_MFM
     847  if(pcSPS->getLayerId() > 0)
     848  {
     849          READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" );
     850          pcSPS->setMFMEnabledFlag( uiCode ? true : false );
     851          assert(pcSPS->getMFMEnabledFlag());
     852  }
     853#endif
    846854#if SUPPORT_FOR_VUI
    847855  READ_FLAG( uiCode, "vui_parameters_present_flag" );             pcSPS->setVuiParametersPresentFlag(uiCode);
  • branches/SHM-1.0-dev/source/Lib/TLibDecoder/TDecGop.cpp

    r2 r25  
    287287
    288288  rpcPic->compressMotion();
     289
     290#if REF_IDX_MFM
     291  if( rpcPic->getLayerId() == 0 && rpcPic->upsampledMvFieldIsNull() )
     292  {
     293    TComSPS *spsEL = m_ppcTDecTop[1]->getSPS();
     294
     295    rpcPic->createUpSampledMvField(spsEL->getPicHeightInLumaSamples(), spsEL->getPicWidthInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);  //create up-sampled mv field
     296  }
     297
     298  if( rpcPic->getLayerId() == 0 && rpcPic->IsUpsampledMvField() == false )
     299  {
     300    TComSPS *spsBL = m_ppcTDecTop[0]->getSPS();
     301    TComSPS *spsEL = m_ppcTDecTop[1]->getSPS();
     302
     303    Int iBWidth  = spsBL->getPicWidthInLumaSamples() - spsBL->getPicCropLeftOffset() - spsBL->getPicCropRightOffset();
     304    Int iBHeight = spsBL->getPicHeightInLumaSamples() - spsBL->getPicCropTopOffset() - spsBL->getPicCropBottomOffset();
     305
     306    Int iEWidth  = spsEL->getPicWidthInLumaSamples() - spsEL->getPicCropLeftOffset() - spsEL->getPicCropRightOffset();
     307    Int iEHeight = spsEL->getPicHeightInLumaSamples() - spsEL->getPicCropTopOffset() - spsEL->getPicCropBottomOffset();
     308
     309    UInt upSampleRatio;
     310    if(iEWidth == iBWidth && iEHeight == iBHeight)
     311      upSampleRatio = 0;
     312    else if(iEWidth == 2*iBWidth && iEHeight == 2*iBHeight)
     313      upSampleRatio = 1;
     314    else if(2*iEWidth == 3*iBWidth && 2*iEHeight == 3*iBHeight)
     315      upSampleRatio = 2;
     316    else
     317      assert(0);
     318
     319    rpcPic->doTheUpSampleMvField(upSampleRatio);
     320    rpcPic->setUpsampledMvField(true);
     321  }
     322#endif
     323
    289324  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
    290325  if (!pcSlice->isReferenced()) c += 32;
  • branches/SHM-1.0-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r21 r25  
    164164        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
    165165#endif
    166 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV
     166#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || REF_IDX_MFM
    167167        m_cIlpPic[j]->setIsILR(true);
    168168#endif
     
    270270    rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
    271271#endif
     272
     273#if REF_IDX_MFM
     274    rpcPic->setUpsampledMvField(false);
     275#endif
    272276    m_cListPic.pushBack( rpcPic );
    273277   
     
    315319#if REMOVE_APS
    316320  rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
     321#endif
     322
     323#if REF_IDX_MFM
     324  rpcPic->setUpsampledMvField(false);
    317325#endif
    318326}
     
    768776    {
    769777      setILRPic(pcPic);
     778#if REF_IDX_MFM
     779      pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
     780#endif
     781
    770782      pcSlice->addRefPicList ( m_cIlpPic,
    771783                               1,
     
    880892  m_cEntropyDecoder.decodeSPS( sps );
    881893  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
     894#if REF_IDX_MFM
     895  m_pcSPS = sps;
     896  setMFMEnabledFlag(sps->getMFMEnabledFlag());
     897#endif
    882898#if !REMOVE_ALF
    883899  m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
  • branches/SHM-1.0-dev/source/Lib/TLibDecoder/TDecTop.h

    r2 r25  
    8080  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
    8181#endif
     82
     83#if REF_IDX_MFM
     84  TComSPS*               m_pcSPS;
     85  Bool                   m_bMFMEnabledFlag;
     86#endif
     87
    8288  TComSlice*              m_apcSlicePilot;
    8389 
     
    170176  Void      setILRPic(TComPic *pcPic);
    171177#endif
     178#if REF_IDX_MFM
     179  TComSPS*  getSPS()                       {return m_pcSPS;}
     180  Void      setMFMEnabledFlag(Bool flag)   {m_bMFMEnabledFlag = flag;}
     181  Bool      getMFMEnabledFlag()            {return m_bMFMEnabledFlag;}
     182#endif
     183
    172184protected:
    173185  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
  • branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r2 r25  
    600600#endif
    601601  WRITE_FLAG( pcSPS->getTMVPFlagsPresent()  ? 1 : 0,           "sps_temporal_mvp_enable_flag" );
     602#if REF_IDX_MFM
     603  if( pcSPS->getLayerId() > 0 )
     604  {
     605          assert(pcSPS->getMFMEnabledFlag());
     606          WRITE_FLAG( pcSPS->getMFMEnabledFlag() ? 1 : 0,          "sps_enh_mfm_enable_flag" );
     607  }
     608#endif
    602609#if SUPPORT_FOR_VUI
    603610  WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(),             "vui_parameters_present_flag" );
  • branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r2 r25  
    465465#endif
    466466
     467#if REF_IDX_FRAMEWORK
     468    if (pcSlice->getSliceType() == B_SLICE)
     469      pcSlice->setColFromL0Flag(1-uiColDir);
     470#endif
     471
    467472    //  Set reference list
    468473    pcSlice->setRefPicList ( rcListPic );
     
    471476    {
    472477      m_pcEncTop->setILRPic(pcPic);
     478
     479#if REF_IDX_MFM
     480      pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic());
     481#endif
    473482      pcSlice->addRefPicList ( m_pcEncTop->getIlpList(), 1);
     483
     484#if REF_IDX_MFM
     485      Bool found         = false;
     486      UInt ColFromL0Flag = pcSlice->getColFromL0Flag();
     487      UInt ColRefIdx     = pcSlice->getColRefIdx();
     488      for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
     489      {
     490        if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getIsILR() )
     491        {
     492          ColRefIdx = colIdx;
     493          found = true;
     494          break;
     495        }
     496      }
     497
     498      if( found == false )
     499      {
     500        ColFromL0Flag = 1 - ColFromL0Flag;
     501        for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
     502        {
     503          if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getIsILR() )
     504          {
     505            ColRefIdx = colIdx;
     506            found = true;
     507            break;
     508          }
     509        }
     510      }
     511
     512      if(found == true)
     513      {
     514        pcSlice->setColFromL0Flag(ColFromL0Flag);
     515        pcSlice->setColRefIdx(ColRefIdx);
     516      }
     517#endif
    474518    }
    475519#endif
     
    495539    if (pcSlice->getSliceType() == B_SLICE)
    496540    {
     541#if !REF_IDX_FRAMEWORK
    497542      pcSlice->setColFromL0Flag(1-uiColDir);
     543#endif
    498544      Bool bLowDelay = true;
    499545      Int  iCurrPOC  = pcSlice->getPOC();
     
    15151561
    15161562      pcPic->compressMotion();
     1563#if REF_IDX_MFM
     1564      if( m_layerId == 0 && pcPic->upsampledMvFieldIsNull() )
     1565      {
     1566        Int     iEHeight     = m_ppcTEncTop[m_layerId+1]->getSourceHeight();
     1567        Int     iEWidth      = m_ppcTEncTop[m_layerId+1]->getSourceWidth();
     1568        pcPic->createUpSampledMvField(iEHeight, iEWidth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);  //create up-sampled mv field
     1569      }
     1570
     1571        if( m_layerId == 0 && pcPic->IsUpsampledMvField() == false )
     1572      {
     1573        Int iBWidth  = m_ppcTEncTop[m_layerId]->getSourceWidth() - m_ppcTEncTop[m_layerId]->getCropLeft() - m_ppcTEncTop[m_layerId]->getCropRight();
     1574        Int iBHeight = m_ppcTEncTop[m_layerId]->getSourceHeight() - m_ppcTEncTop[m_layerId]->getCropTop() - m_ppcTEncTop[m_layerId]->getCropBottom();
     1575
     1576        Int iEWidth  = m_ppcTEncTop[m_layerId+1]->getSourceWidth() - m_ppcTEncTop[m_layerId+1]->getCropLeft() - m_ppcTEncTop[m_layerId+1]->getCropRight();
     1577        Int iEHeight = m_ppcTEncTop[m_layerId+1]->getSourceHeight() - m_ppcTEncTop[m_layerId+1]->getCropTop() - m_ppcTEncTop[m_layerId+1]->getCropBottom();
     1578
     1579        UInt upSampleRatio;
     1580        if(iEWidth == iBWidth && iEHeight == iBHeight)
     1581          upSampleRatio = 0;
     1582        else if(iEWidth == 2*iBWidth && iEHeight == 2*iBHeight)
     1583          upSampleRatio = 1;
     1584        else if(2*iEWidth == 3*iBWidth && 2*iEHeight == 3*iBHeight)
     1585          upSampleRatio = 2;
     1586        else
     1587          assert(0);
     1588
     1589        pcPic->doTheUpSampleMvField(upSampleRatio);
     1590        pcPic->setUpsampledMvField(true);
     1591      }
     1592#endif
    15171593     
    15181594      //-- For time output for each slice
  • branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r21 r25  
    8585  memset(m_cIlpPic, 0, sizeof(m_cIlpPic));
    8686#endif
     87#if REF_IDX_MFM
     88  m_bMFMEnabledFlag = false;
     89#endif
    8790}
    8891
     
    394397        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
    395398#endif
    396 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE
     399#if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
    397400        m_cIlpPic[j]->setIsILR(true);
    398401#endif
     
    599602  // mark it should be extended
    600603  rpcPic->getPicYuvRec()->setBorderExtension(false);
     604#if REF_IDX_MFM
     605  rpcPic->setUpsampledMvField(false);
     606#endif
    601607}
    602608
     
    605611#if SVC_EXTENSION
    606612  m_cSPS.setLayerId(m_layerId);
     613#endif
     614#if REF_IDX_MFM
     615  m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag);
    607616#endif
    608617
  • branches/SHM-1.0-dev/source/Lib/TLibEncoder/TEncTop.h

    r2 r25  
    140140  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
    141141#endif
     142#if REF_IDX_MFM
     143  Bool                    m_bMFMEnabledFlag;
     144#endif
    142145protected:
    143146  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    228231  Void setILRPic(TComPic *pcPic);
    229232#endif
     233#if REF_IDX_MFM
     234  Void setMFMEnabledFlag       (Bool flag)   {m_bMFMEnabledFlag = flag;}
     235  Bool getMFMEnabledFlag()                   {return m_bMFMEnabledFlag;}   
     236#endif
    230237
    231238};
Note: See TracChangeset for help on using the changeset viewer.