Changeset 282 in SHVCSoftware for branches/SHM-2.1-dev/source


Ignore:
Timestamp:
11 Jun 2013, 02:30:21 (12 years ago)
Author:
seregin
Message:

merge with SHM-2.1-multilayers-dev branch

Location:
branches/SHM-2.1-dev/source
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-2.1-dev/source

  • branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r245 r282  
    153153    }
    154154  }
     155
     156  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     157  {
     158    if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
     159    {
     160      delete [] m_acLayerCfg[layer].m_predLayerIds;
     161    }
     162  }
    155163#endif
    156164}
     
    329337#if VPS_EXTN_DIRECT_REF_LAYERS
    330338  Int*    cfg_numDirectRefLayers [MAX_LAYERS];
    331   string cfg_refLayerIds   [MAX_LAYERS];
    332   string* cfg_refLayerIdsPtr   [MAX_LAYERS];
     339  string  cfg_refLayerIds        [MAX_LAYERS];
     340  string* cfg_refLayerIdsPtr     [MAX_LAYERS];
     341
     342  Int*    cfg_numActiveRefLayers [MAX_LAYERS];
     343  string  cfg_predLayerIds       [MAX_LAYERS];
     344  string* cfg_predLayerIdsPtr    [MAX_LAYERS];
    333345#endif
    334346#if SCALED_REF_LAYER_OFFSETS
     
    360372    cfg_numDirectRefLayers  [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers;
    361373    cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
     374    cfg_numActiveRefLayers  [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers;
     375    cfg_predLayerIdsPtr     [layer]  = &cfg_predLayerIds[layer];
    362376#endif
    363377#if SCALED_REF_LAYER_OFFSETS
     
    422436  ("NumDirectRefLayers%d",    cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers")
    423437  ("RefLayerIds%d",           cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs")
     438  ("NumActiveRefLayers%d",    cfg_numActiveRefLayers, -1, MAX_LAYERS, "Number of active reference layers")
     439  ("PredLayerIds%d",          cfg_predLayerIdsPtr, string(""), MAX_LAYERS, "inter-layer prediction layer IDs")
    424440#endif
    425441  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
     
    890906        if( i >= m_acLayerCfg[layer].m_numDirectRefLayers )
    891907        {
    892           printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
     908          printf( "NumDirectRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
    893909          exit( EXIT_FAILURE );
    894910        }
     
    899915      if( i < m_acLayerCfg[layer].m_numDirectRefLayers )
    900916      {
    901         printf( "The width of some columns is not defined.\n" );
     917        printf( "NumDirectRefLayers: The width of some columns is not defined.\n" );
    902918        exit( EXIT_FAILURE );
    903919      }
     
    906922    {
    907923      m_acLayerCfg[layer].m_refLayerIds = NULL;
     924    }
     925  }
     926
     927  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     928  {
     929    Char* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str());
     930    if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
     931    {
     932      char *refLayerId;
     933      int  i=0;
     934      m_acLayerCfg[layer].m_predLayerIds = new Int[m_acLayerCfg[layer].m_numActiveRefLayers];
     935      refLayerId = strtok(pPredLayerIds, " ,-");
     936      while(refLayerId != NULL)
     937      {
     938        if( i >= m_acLayerCfg[layer].m_numActiveRefLayers )
     939        {
     940          printf( "NumActiveRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
     941          exit( EXIT_FAILURE );
     942        }
     943        *( m_acLayerCfg[layer].m_predLayerIds + i ) = atoi( refLayerId );
     944        refLayerId = strtok(NULL, " ,-");
     945        i++;
     946      }
     947      if( i < m_acLayerCfg[layer].m_numActiveRefLayers )
     948      {
     949        printf( "NumActiveRefLayers: The width of some columns is not defined.\n" );
     950        exit( EXIT_FAILURE );
     951      }
     952    }
     953    else
     954    {
     955      m_acLayerCfg[layer].m_predLayerIds = NULL;
    908956    }
    909957  }
     
    18401888    }
    18411889  }
     1890
     1891  xConfirmPara( (m_acLayerCfg[0].m_numActiveRefLayers != 0) && (m_acLayerCfg[0].m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" );
     1892  // NOTE: m_numActiveRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
     1893  for(Int layer = 1; layer < MAX_LAYERS; layer++)
     1894  {
     1895    xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers");
     1896    for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++)
     1897    {
     1898      xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference higher layers");
     1899    }
     1900  }
    18421901#endif
    18431902#undef xConfirmPara
  • branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h

    r211 r282  
    4545  Int       *m_refLayerIds;
    4646  Int       m_numDirectRefLayers;
     47  Int       *m_predLayerIds;
     48  Int       m_numActiveRefLayers;
    4749#endif
    4850
     
    108110  Int*    getRefLayerIds()            {return m_refLayerIds;      }
    109111  Int     getRefLayerId(Int i)        {return m_refLayerIds[i];   }
     112
     113  Int     getNumActiveRefLayers()     {return m_numActiveRefLayers;}
     114  Int*    getPredLayerIds()           {return m_predLayerIds;     }
     115  Int     getPredLayerId(Int i)       {return m_predLayerIds[i];  }
    110116#endif
    111117#if RC_SHVC_HARMONIZATION
  • branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r245 r282  
    159159        {
    160160          m_acTEncTop[layer].setRefLayerId             ( i, m_acLayerCfg[layer].getRefLayerId(i));
    161         }       
     161        }
     162      }
     163
     164      if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1)
     165      {
     166        m_acTEncTop[layer].setNumActiveRefLayers( m_acLayerCfg[layer].getNumDirectRefLayers() );
     167        for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ )
     168        {
     169          m_acTEncTop[layer].setPredLayerId(i, i);
     170        }
     171      }
     172      else
     173      {
     174        m_acTEncTop[layer].setNumActiveRefLayers       ( m_acLayerCfg[layer].getNumActiveRefLayers() );     
     175        for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++)
     176        {
     177          m_acTEncTop[layer].setPredLayerId             ( i, m_acLayerCfg[layer].getPredLayerId(i));
     178        }
    162179      }
    163180    }
     
    886903  vps->setNumProfileTierLevel(vps->getNumLayerSets());   
    887904  vps->setDefaultOneTargetOutputLayerFlag(true);
    888   for(Int i = 1; i < vps->getNumLayerSets(); i++)
     905  for(i = 1; i < vps->getNumLayerSets(); i++)
    889906  {
    890907    vps->setProfileLevelTierIdx(i, i);
     
    910927#if VPS_EXTN_DIRECT_REF_LAYERS
    911928  // Direct reference layers
     929  UInt maxDirectRefLayers = 0;
    912930  for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
    913931  {
    914932    vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() );
     933    maxDirectRefLayers = max<UInt>( maxDirectRefLayers, vps->getNumDirectRefLayers( layerCtr ) );
     934
    915935    for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
    916936    {
     
    930950#endif
    931951#if JCTVC_M0458_INTERLAYER_RPS_SIG       
    932     vps->setMaxOneActiveRefLayerFlag(true);
     952    vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true);
    933953#endif
    934954#else
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.cpp

    r212 r282  
    17501750  // check BL mode
    17511751  UInt          uiCUAddrBase, uiAbsPartAddrBase;
    1752   TComDataCU*   pcTempCU = getBaseColCU( uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase );
     1752  // the right reference layerIdc should be specified, currently it is set to m_layerId-1
     1753  TComDataCU*   pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase );
    17531754
    17541755  if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA )
     1756  {
    17551757    return( NUM_INTRA_MODE-1 );
     1758  }
    17561759
    17571760  // compute set of enabled modes g_reducedSetIntraModes[...]
     
    41824185
    41834186#if SVC_COL_BLK
    4184 TComDataCU*  TComDataCU::getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
     4187TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
    41854188{
    41864189#if 1 // it should provide identical resutls
     
    41884191  UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ];
    41894192
    4190   return getBaseColCU( uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase );
     4193  return getBaseColCU( refLayerIdc, uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase );
    41914194#else
    41924195  TComPic* cBaseColPic = m_pcSlice->getBaseColPic();
     
    42374240}
    42384241
    4239 TComDataCU*  TComDataCU::getBaseColCU( UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
    4240 {
    4241   TComPic* cBaseColPic = m_pcSlice->getBaseColPic();
     4242TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
     4243{
     4244  TComPic* cBaseColPic = m_pcSlice->getBaseColPic(refLayerIdc);
    42424245
    42434246#if !SIMPLIFIED_MV_POS_SCALING
     
    42694272  Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowLeftOffset();
    42704273  Int topStartL  = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowTopOffset();
    4271   Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
    4272   Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
     4274  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16;
     4275  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
    42734276#else
    4274   Int iBX = (uiPelX*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
    4275   Int iBY = (uiPelY*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
     4277  Int iBX = (uiPelX*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16;
     4278  Int iBY = (uiPelY*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
    42764279#endif
    42774280#else
     
    42954298  const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
    42964299
    4297   Int widthBL   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
    4298   Int heightBL  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     4300  Int widthBL   = m_pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     4301  Int heightBL  = m_pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
    42994302#endif
    43004303  if( iBX >= widthBL || iBY >= heightBL ) //outside of the reference layer cropped picture
     
    43164319}
    43174320
    4318 Void TComDataCU::scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase )
     4321Void TComDataCU::scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase )
    43194322{
    43204323  TComMvField cMvFieldBase;
    43214324  TComMv cMv;
    43224325#if SIMPLIFIED_MV_POS_SCALING
    4323   cMv = rcMvFieldBase.getMv().scaleMv( g_mvScalingFactor[m_layerId][0], g_mvScalingFactor[m_layerId][1] );
     4326  cMv = rcMvFieldBase.getMv().scaleMv( g_mvScalingFactor[refLayerIdc][0], g_mvScalingFactor[refLayerIdc][1] );
    43244327#else
    43254328  const Window &confBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.h

    r212 r282  
    554554
    555555#if SVC_COL_BLK
    556   TComDataCU*   getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
    557   TComDataCU*   getBaseColCU( UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
    558   Void          scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
     556  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
     557  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
     558  Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
    559559#endif
    560560};
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.cpp

    r191 r282  
    6767, m_pNDBFilterYuvTmp                      (NULL)
    6868, m_bCheckLTMSB                           (false)
     69{
    6970#if SVC_EXTENSION
    70 , m_bSpatialEnhLayer( false )
    71 , m_pcFullPelBaseRec( NULL )
    72 #endif
    73 {
     71  memset( m_pcFullPelBaseRec, 0, sizeof( m_pcFullPelBaseRec ) );
     72  memset( m_bSpatialEnhLayer, false, sizeof( m_bSpatialEnhLayer ) );
     73#endif
    7474  m_apcPicYuv[0]      = NULL;
    7575  m_apcPicYuv[1]      = NULL;
     
    9191  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
    9292
    93   if (m_bSpatialEnhLayer)
    94   {
    95     m_pcFullPelBaseRec = new TComPicYuv;  m_pcFullPelBaseRec->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     93  for( Int i = 0; i < MAX_LAYERS; i++ )
     94  {
     95    if( m_bSpatialEnhLayer[i] )
     96    {
     97      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     98    }
    9699  }
    97100
     
    173176  deleteSEIs(m_SEIs);
    174177#if SVC_EXTENSION && SVC_UPSAMPLING
    175   if (m_bSpatialEnhLayer)
    176   {
    177     m_pcFullPelBaseRec->destroy();
    178     delete m_pcFullPelBaseRec;
    179     m_pcFullPelBaseRec  = NULL;
     178  for( Int i = 0; i < MAX_LAYERS; i++ )
     179  {
     180    if( m_bSpatialEnhLayer[i] )
     181    {
     182      m_pcFullPelBaseRec[i]->destroy();
     183      delete m_pcFullPelBaseRec[i];
     184      m_pcFullPelBaseRec[i]  = NULL;
     185    }
    180186  }
    181187#endif
     
    562568
    563569#if REF_IDX_MFM
    564 Void TComPic::copyUpsampledMvField(TComPic* pcPicBase)
     570Void TComPic::copyUpsampledMvField(UInt refLayerIdc, TComPic* pcPicBase)
    565571{
    566572#if AVC_SYNTAX && !ILP_DECODED_PICTURE
     
    592598
    593599      TComDataCU *pcColCU = 0;
    594       pcColCU = pcCUDes->getBaseColCU(pelX + 8, pelY + 8, baseCUAddr, baseAbsPartIdx);
     600      pcColCU = pcCUDes->getBaseColCU(refLayerIdc, pelX + 8, pelY + 8, baseCUAddr, baseAbsPartIdx);
    595601
    596602#if AVC_SYNTAX && !ILP_DECODED_PICTURE
     
    607613          TComMvField sMvFieldBase, sMvField;
    608614          pcColCU->getMvField( pcColCU, baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
    609           pcCUDes->scaleBaseMV( sMvField, sMvFieldBase );
     615          pcCUDes->scaleBaseMV( refLayerIdc, sMvField, sMvFieldBase );
    610616
    611617          pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, absPartIdx);
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.h

    r191 r282  
    9292  SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
    9393#if SVC_EXTENSION
    94   Bool                  m_bSpatialEnhLayer;       // whether current layer is a spatial enhancement layer,
    95   TComPicYuv*           m_pcFullPelBaseRec;    // upsampled base layer recontruction for difference domain inter prediction
     94  Bool                  m_bSpatialEnhLayer[MAX_LAYERS];       // whether current layer is a spatial enhancement layer,
     95  TComPicYuv*           m_pcFullPelBaseRec[MAX_LAYERS];    // upsampled base layer recontruction for difference domain inter prediction
    9696#endif
    9797
     
    114114  Void          setLayerId (UInt layerId) { m_layerId = layerId; }
    115115  UInt          getLayerId ()               { return m_layerId; }
    116   Bool          isSpatialEnhLayer()             { return m_bSpatialEnhLayer; }
    117   Void          setSpatialEnhLayerFlag (Bool b) { m_bSpatialEnhLayer = b; }
    118   Void          setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
    119   TComPicYuv*   getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
     116  Bool          isSpatialEnhLayer(UInt refLayerIdc)             { return m_bSpatialEnhLayer[refLayerIdc]; }
     117  Void          setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b) { m_bSpatialEnhLayer[refLayerIdc] = b; }
     118  Void          setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; }
     119  TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)  { return  m_pcFullPelBaseRec[refLayerIdc];  }
    120120#endif
    121121#if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
     
    124124
    125125#if REF_IDX_MFM
    126   Void          copyUpsampledMvField  ( TComPic* pcPicBase );
     126  Void          copyUpsampledMvField  ( UInt refLayerIdc, TComPic* pcPicBase );
    127127  Void          initUpsampledMvField  ();
    128128#endif
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.cpp

    r191 r282  
    774774#if SVC_UPSAMPLING
    775775#if SCALED_REF_LAYER_OFFSETS
    776 Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
    777 {
    778   m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic, window);
     776Void TComPrediction::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
     777{
     778  m_cUsf.upsampleBasePic( refLayerIdc, pcUsPic, pcBasePic, pcTempPic, window);
    779779}
    780780#else
    781 Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
    782 {
    783   m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic);
     781Void TComPrediction::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
     782{
     783  m_cUsf.upsampleBasePic( refLayerIdc, pcUsPic, pcBasePic, pcTempPic);
    784784}
    785785#endif
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.h

    r191 r282  
    123123#if SVC_UPSAMPLING
    124124#if SCALED_REF_LAYER_OFFSETS
    125   Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     125  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
    126126#else
    127   Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     127  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
    128128#endif
    129129#endif
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp

    r258 r282  
    9292#if SVC_EXTENSION
    9393, m_layerId                     ( 0 )
    94 , m_pcBaseColPic                  ( NULL )
    9594#endif
    9695, m_bTLayerSwitchingFlag          ( false )
     
    122121  m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0;
    123122#endif
    124  
     123
     124#if SVC_EXTENSION
     125  memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) );
    125126#if REF_IDX_FRAMEWORK
    126127#if JCTVC_M0458_INTERLAYER_RPS_SIG
     
    131132  m_numILRRefIdx = 0;
    132133#endif
     134#endif
    133135#endif
    134136
     
    518520
    519521#if REF_IDX_FRAMEWORK
    520   //inter-layer reference picture
     522  for( i = 0; i < m_activeNumILRRefIdx; i++ )
     523  {
     524    UInt refLayerIdc = m_interLayerPredLayerIdc[i];
     525    //inter-layer reference picture
    521526#if REF_IDX_MFM
    522527
    523528#if ILR_RESTR
    524   Int maxSubLayerForILPPlus1 = (getLayerId() > 0 && m_activeNumILRRefIdx > 0)? getVPS()->getMaxSublayerForIlpPlus1(ilpPic[0]->getSlice(0)->getLayerId()) : 0;
     529    Int maxSubLayerForILPPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0;
    525530#if ZERO_NUM_DIRECT_LAYERS
    526   if( getLayerId() > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) )  )
    527 #else
    528   if( getLayerId() && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) )  )
     531    if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  )
     532#else
     533    if( m_layerId > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  )
    529534#endif
    530535
    531536#else
    532537#if ZERO_NUM_DIRECT_LAYERS
    533   if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
    534 #else
    535   if (getLayerId())
    536 #endif
    537 #endif
    538   {
    539     if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
    540     {
    541       ilpPic[0]->copyUpsampledMvField(getBaseColPic());
    542     }
    543     else
    544     {
    545       ilpPic[0]->initUpsampledMvField();
    546     }
    547   #endif
    548     ilpPic[0]->setIsLongTerm(1);
     538    if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
     539#else
     540    if( m_layerId > 0 )
     541#endif
     542#endif
     543    {
     544      if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && m_pcSPS->getMFMEnabledFlag())
     545      {
     546        ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] );
     547      }
     548      else
     549      {
     550        ilpPic[refLayerIdc]->initUpsampledMvField();
     551      }
     552#endif
     553      ilpPic[refLayerIdc]->setIsLongTerm(1);
     554    }
    549555  }
    550556#endif
     
    555561#if ILR_RESTR
    556562  Int numInterLayerRPSPics = 0;
    557   if (getLayerId()>0)
    558   {
    559     for (i=0; i < getVPS()->getNumDirectRefLayers(getLayerId()); i++)
    560     {
    561       maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
     563  if( m_layerId > 0 )
     564  {
     565    for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ )
     566    {
     567      Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
    562568      if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) )
    563569      {
     
    570576      m_activeNumILRRefIdx = numInterLayerRPSPics;
    571577    }
    572 #if MAX_ONE_RESAMPLING_DIRECT_LAYERS
    573     if(getVPS()->getScalabilityMask(1))
     578#if MAX_ONE_RESAMPLING_DIRECT_LAYERS && SIMPLIFIED_MV_POS_SCALING
     579    if( m_pcVPS->getScalabilityMask(1) )
    574580    {
    575581      Int numResampler = 0;
     
    581587                          );
    582588
    583       Int widthEL   = getPic()->getPicYuvRec()->getWidth();
    584       Int heightEL  = getPic()->getPicYuvRec()->getHeight();     
    585       for (i=0; i < m_activeNumILRRefIdx; i++)
    586       {
    587         Int widthBL   =  ilpPic[getInterLayerPredLayerIdc(i)]->getSlice(0)->getBaseColPic()->getPicYuvRec()->getWidth();
    588         Int heightBL  =  ilpPic[getInterLayerPredLayerIdc(i)]->getSlice(0)->getBaseColPic()->getPicYuvRec()->getHeight();
    589 
    590         if(!(widthEL == widthBL && heightEL == heightBL && (scalingOffset)))
     589      for( i=0; i < m_activeNumILRRefIdx; i++ )
     590      {
     591        UInt refLayerIdc = m_interLayerPredLayerIdc[i];
     592        if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) && (scalingOffset)) // ratio 1x
    591593        {
    592594          numResampler++;
     
    660662    }
    661663#if REF_IDX_FRAMEWORK
    662     if(getLayerId())
     664    if( m_layerId > 0 )
    663665    {
    664666#if JCTVC_M0458_INTERLAYER_RPS_SIG
     
    668670#endif
    669671      {
     672        Int refLayerIdc = m_interLayerPredLayerIdc[i];
    670673#if ILR_RESTR
    671          maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
    672         if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) )
    673 #endif
    674         rpsCurrList0[cIdx] = ilpPic[i];
     674         Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
     675        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
     676#endif
     677        rpsCurrList0[cIdx] = ilpPic[refLayerIdc];
    675678      }
    676679    }
     
    692695    }
    693696#if REF_IDX_FRAMEWORK
    694     if(getLayerId())
     697    if( m_layerId > 0 )
    695698    {
    696699#if JCTVC_M0458_INTERLAYER_RPS_SIG
     
    700703#endif
    701704      {
     705        Int refLayerIdc = m_interLayerPredLayerIdc[i];
    702706#if ILR_RESTR
    703         maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
    704         if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) )
    705 #endif
    706         rpsCurrList1[cIdx] = ilpPic[i];
     707        Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
     708        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
     709#endif
     710        rpsCurrList1[cIdx] = ilpPic[refLayerIdc];
    707711      }
    708712    }
     
    737741Void TComSlice::setRefPicListModificationSvc()
    738742{
    739   if( !this->getPPS()->getListsModificationPresentFlag())
     743  if( !m_pcPPS->getListsModificationPresentFlag())
    740744  {
    741745    return;
    742746  }
    743747
    744   if(this->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && this->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)
     748  if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA)
    745749  {
    746750    return;
    747751  }
    748752
    749   TComRefPicListModification* refPicListModification = this->getRefPicListModification();
     753  TComRefPicListModification* refPicListModification = &m_RefPicListModification;
    750754  Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList();  // total number of ref pics in listTemp0 including inter-layer ref pics
    751755
     
    821825
    822826#if REF_IDX_FRAMEWORK
    823   if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() &&
    824     (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    825     (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) )
     827  if( m_eSliceType == I_SLICE || ( m_pcSPS->getLayerId() &&
     828    (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
     829    (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) )
    826830#else
    827831  if (m_eSliceType == I_SLICE)
     
    846850  }
    847851#if REF_IDX_FRAMEWORK
    848   if(getLayerId())
     852  if( m_layerId > 0 )
    849853  {
    850854#if JCTVC_M0458_INTERLAYER_RPS_SIG
     
    25922596#endif
    25932597
    2594 Void TComSlice::setBaseColPic(  TComList<TComPic*>& rcListPic, UInt layerID )
     2598Void TComSlice::setBaseColPic(  TComList<TComPic*>& rcListPic, UInt refLayerIdc )
    25952599
    2596   if (layerID == 0)
    2597   {
    2598     m_pcBaseColPic = NULL;
     2600  if(m_layerId == 0)
     2601  {
     2602    memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) );
    25992603    return;
    26002604  }       
    2601   setBaseColPic(xGetRefPic(rcListPic, getPOC()));
     2605  setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC()));
    26022606}
    26032607#endif
    26042608
    26052609#if REF_IDX_MFM
    2606 Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic *pcRefPicBL )
    2607 {
    2608   //set reference picture POC of each ILP reference
    2609   Int thePoc = ilpPic[0]->getPOC();
    2610   assert(thePoc >= 0);
    2611   assert(thePoc == pcRefPicBL->getPOC());
    2612 
    2613   ilpPic[0]->getSlice(0)->setBaseColPic( pcRefPicBL );
    2614 
    2615   //copy reference pictures marking from the reference layer
    2616   ilpPic[0]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0));
    2617  
    2618   for( Int refList = 0; refList < 2; refList++ )
    2619   {
    2620     RefPicList refPicList = RefPicList( refList );
    2621    
    2622     //set reference POC of ILP
    2623     ilpPic[0]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList));
    2624     assert(ilpPic[0]->getSlice(0)->getNumRefIdx(refPicList) >= 0);
    2625     assert(ilpPic[0]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF);
    2626 
    2627     //initialize reference POC of ILP
    2628     for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++)
    2629     {
    2630       ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx);
    2631       ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx);
    2632     }
    2633 
    2634     for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++)
    2635     {
    2636       ilpPic[0]->getSlice(0)->setRefPOC(0, refPicList, refIdx);
    2637       ilpPic[0]->getSlice(0)->setRefPic(NULL, refPicList, refIdx);
     2610Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic** pcRefPicRL )
     2611{
     2612  for( UInt i = 0; i < m_activeNumILRRefIdx; i++ )
     2613  {
     2614    UInt refLayerIdc = m_interLayerPredLayerIdc[i];
     2615
     2616    TComPic* pcRefPicBL = pcRefPicRL[refLayerIdc];
     2617    //set reference picture POC of each ILP reference
     2618    Int thePoc = ilpPic[refLayerIdc]->getPOC();
     2619    assert(thePoc >= 0);
     2620    assert(thePoc == pcRefPicBL->getPOC());
     2621
     2622    ilpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL );
     2623
     2624    //copy reference pictures marking from the reference layer
     2625    ilpPic[refLayerIdc]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0));
     2626
     2627    for( Int refList = 0; refList < 2; refList++ )
     2628    {
     2629      RefPicList refPicList = RefPicList( refList );
     2630
     2631      //set reference POC of ILP
     2632      ilpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList));
     2633      assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0);
     2634      assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF);
     2635
     2636      //initialize reference POC of ILP
     2637      for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++)
     2638      {
     2639        ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx);
     2640        ilpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx);
     2641      }
     2642
     2643      for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++)
     2644      {
     2645        ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx);
     2646        ilpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx);
     2647      }
    26382648    }
    26392649  }
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h

    r258 r282  
    14941494#if SVC_EXTENSION
    14951495  UInt        m_layerId;
    1496   TComPic*    m_pcBaseColPic;
    1497   TComPicYuv* m_pcFullPelBaseRec;
     1496  TComPic*    m_pcBaseColPic[MAX_LAYERS];
     1497  TComPicYuv* m_pcFullPelBaseRec[MAX_LAYERS];
    14981498#endif
    14991499  Bool        m_bTLayerSwitchingFlag;
     
    17751775
    17761776#if SVC_EXTENSION
    1777   Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt layerID );
    1778   Void      setBaseColPic       ( TComPic* p)     { m_pcBaseColPic = p; }
    1779   TComPic*  getBaseColPic       ()                { return m_pcBaseColPic; }
     1777  Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt refLayerIdc );
     1778  Void      setBaseColPic       (UInt refLayerIdc, TComPic* p)     { m_pcBaseColPic[refLayerIdc] = p; }
     1779  TComPic*  getBaseColPic       (UInt refLayerIdc)                { return m_pcBaseColPic[refLayerIdc]; }
     1780  TComPic** getBaseColPic       ()                { return &m_pcBaseColPic[0]; }
    17801781
    17811782  Void      setLayerId (UInt layerId)   { m_layerId = layerId; }
    17821783  UInt      getLayerId ()               { return m_layerId;    }
    17831784
    1784   Void        setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
    1785   TComPicYuv* getFullPelBaseRec   ()               { return  m_pcFullPelBaseRec;  }
     1785  Void        setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; }
     1786  TComPicYuv* getFullPelBaseRec   (UInt refLayerIdc)               { return  m_pcFullPelBaseRec[refLayerIdc];  }
    17861787
    17871788#if AVC_SYNTAX
     
    17941795
    17951796#if REF_IDX_MFM
    1796   Void      setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL);
     1797  Void      setRefPOCListILP(TComPic** ilpPic, TComPic** pcRefPicRL);
    17971798#endif
    17981799
     
    18011802  Void      setActiveNumILRRefIdx     ( Int i )         { m_activeNumILRRefIdx = i;     } 
    18021803
    1803   Int       getInterLayerPredLayerIdc (UInt Idx )               { return  m_interLayerPredLayerIdc[Idx];}
    1804   Void      setInterLayerPredLayerIdc (UInt val, UInt Idx)      { m_interLayerPredLayerIdc[Idx] = val;  }
     1804  Int       getInterLayerPredLayerIdc (UInt layerIdx)                        { return  m_interLayerPredLayerIdc[layerIdx];}
     1805  Void      setInterLayerPredLayerIdc (UInt refLayerIdc, UInt layerIdx)      { m_interLayerPredLayerIdc[layerIdx] = refLayerIdc;  }
    18051806
    18061807  Void      setInterLayerPredEnabledFlag     ( Bool   val )    { m_interLayerPredEnabledFlag = val; }
    18071808  Bool      getInterLayerPredEnabledFlag     ()                { return m_interLayerPredEnabledFlag;}
    1808 
    18091809#else
    18101810  Void      setNumILRRefIdx     ( Int i )               { m_numILRRefIdx = i;     }
    18111811#endif
    18121812#endif
     1813
     1814TComPic* getRefPic(TComList<TComPic*>& rcListPic, Int poc) { return xGetRefPic( rcListPic, poc ); }
    18131815
    18141816#endif //SVC_EXTENSION
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r237 r282  
    7474
    7575#if SCALED_REF_LAYER_OFFSETS
    76 Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
    77 #else
    78 Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
     76Void TComUpsampleFilter::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
     77#else
     78Void TComUpsampleFilter::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
    7979#endif
    8080{
     
    127127  Pel* piDstV;
    128128
    129   if( widthEL == widthBL && heightEL == heightBL )
     129#if SIMPLIFIED_MV_POS_SCALING
     130  Int scaleX = g_posScalingFactor[refLayerIdc][0];
     131  Int scaleY = g_posScalingFactor[refLayerIdc][1];
     132#else
     133  Int   scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
     134  Int   scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
     135#endif
     136
     137  if( scaleX == 65536 && scaleY == 65536 ) // ratio 1x
    130138  {
    131139    piSrcY = piSrcBufY - scalEL.getWindowLeftOffset() - scalEL.getWindowTopOffset() * strideEL;
     
    196204    Int shiftYM4 = shiftY - 4;
    197205
    198     Int   scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
    199     Int   scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
    200 
    201206#if ILP_DECODED_PICTURE
    202207    widthEL   = pcUsPic->getWidth ();
     
    334339    shiftYM4 = shiftY - 4;
    335340
     341#if !SIMPLIFIED_MV_POS_SCALING
    336342    scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
    337343    scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
     344#endif
    338345
    339346#if ILP_DECODED_PICTURE
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.h

    r235 r282  
    4444
    4545#if SCALED_REF_LAYER_OFFSETS
    46   Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     46  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
    4747#else
    48  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     48 Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
    4949#endif
    5050};
  • branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h

    r242 r282  
    4747#define SCALED_REF_LAYER_OFFSET_FLAG     1      ///< M0309: Signal scaled reference layer offsets in SPS
    4848#define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
    49 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
     49#define MAX_LAYERS                       3      ///< max number of layers the codec is supposed to handle
    5050
    5151#define VPS_RENAME                       1      ///< Rename variables max_layer_id and num_layer_sets_minus1 in VPS
  • branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r250 r282  
    160160    if (m_cIlpPic[0] == NULL)
    161161    {
    162       for (Int j=0; j< 1/*MAX_NUM_REF*/; j++)  // to be set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
     162      for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++)  // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
    163163      {
    164164
     
    180180Void TDecTop::setILRPic(TComPic *pcPic)
    181181{
    182   if(m_cIlpPic[0])
    183   {
    184     m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    185     m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
    186     m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId
    187     m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    188     m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     182  for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ )
     183  {
     184    Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i);
     185
     186    if(m_cIlpPic[refLayerIdc])
     187    {
     188      m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(refLayerIdc), m_cIlpPic[refLayerIdc]->getPicYuvRec());
     189      m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC());
     190      m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(refLayerIdc)->getLayerId()); //set reference layerId
     191      m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false);
     192      m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder();
     193    }
    189194  }
    190195}
     
    248253    if(m_layerId > 0)
    249254    {
     255      for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ )
     256      {
     257        const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
     258        Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
     259
    250260#if VPS_EXTN_DIRECT_REF_LAYERS
    251       TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( m_layerId - 1 );
    252 #else
    253       TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 );
    254 #endif
    255       //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
    256       TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
    257       if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() )
    258       {
    259         rpcPic->setSpatialEnhLayerFlag( true );
    260 
    261         //only for scalable extension
    262         assert( pcSlice->getVPS()->getScalabilityMask(1) == true );
    263       }
     261        TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i );
     262#else
     263        TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 );
     264#endif
     265        //TComPic*                      pcPic = *(pcTDecTopBase->getListPic()->begin());
     266        TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
     267        if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets )
     268        {
     269          rpcPic->setSpatialEnhLayerFlag( i, true );
     270
     271          //only for scalable extension
     272          assert( pcSlice->getVPS()->getScalabilityMask(1) == true );
     273        }
    264274#if MAX_ONE_RESAMPLING_DIRECT_LAYERS
    265       if(pcSlice->getVPS()->getScalabilityMask(1))
    266       {
    267          pcSlice->setPic(rpcPic);
    268       }
    269 #endif
     275        if(pcSlice->getVPS()->getScalabilityMask(1))
     276        {
     277          pcSlice->setPic(rpcPic);
     278        }
     279#endif
     280      }
    270281    }
    271282#endif
     
    812823    if(m_layerId > 0)
    813824    {
     825      for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     826      {
     827        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
    814828#if AVC_BASE
    815       if( m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
    816       {
    817         pcSlice->setBaseColPic ( *m_ppcTDecTop[0]->getListPic()->begin() );
     829        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
     830        {
     831          pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );
    818832#if AVC_SYNTAX
    819         TComPic* pBLPic = pcSlice->getBaseColPic();
    820         if( pcSlice->getPOC() == 0 )
    821         {
    822           // initialize partition order.
    823           UInt* piTmp = &g_auiZscanToRaster[0];
    824           initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
    825           initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
    826         }     
    827         pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
    828         pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
    829 #endif
    830       }
    831       else
    832       {
     833          TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc);
     834          if( pcSlice->getPOC() == 0 )
     835          {
     836            // initialize partition order.
     837            UInt* piTmp = &g_auiZscanToRaster[0];
     838            initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
     839            initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
     840          }     
     841          pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
     842          pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
     843#endif
     844        }
     845        else
     846        {
    833847#if VPS_EXTN_DIRECT_REF_LAYERS
    834         TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId - 1 );
     848          TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
     849#else
     850          TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
     851#endif
     852          TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
     853          pcSlice->setBaseColPic ( *cListPic, refLayerIdc );
     854        }
     855#else
     856#if VPS_EXTN_DIRECT_REF_LAYERS
     857        TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc );
    835858#else
    836859        TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
    837860#endif
    838861        TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
    839         pcSlice->setBaseColPic ( *cListPic, m_layerId );
    840       }
    841 #else
    842 #if VPS_EXTN_DIRECT_REF_LAYERS
    843       TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( m_layerId );
    844 #else
    845       TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 );
    846 #endif
    847       TComList<TComPic*> *cListPic = pcTDecTop->getListPic();
    848       pcSlice->setBaseColPic ( *cListPic, m_layerId );
     862        pcSlice->setBaseColPic ( *cListPic, refLayerIdc );
    849863#endif
    850864
    851865#if SIMPLIFIED_MV_POS_SCALING
    852866#if SCALED_REF_LAYER_OFFSETS
    853       const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
    854 
    855       Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
    856       Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
    857 
    858       Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    859       Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    860 #else
    861       const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
    862       const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
    863 
    864       Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
    865       Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
    866 
    867       Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
    868       Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    869 #endif
    870       g_mvScalingFactor[m_layerId][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    871       g_mvScalingFactor[m_layerId][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
    872 
    873       g_posScalingFactor[m_layerId][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
    874       g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
     867        const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
     868
     869        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
     870        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
     871
     872        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     873        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     874#else
     875        const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
     876        const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     877
     878        Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     879        Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     880
     881        Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     882        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     883#endif
     884        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     885        g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     886
     887        g_posScalingFactor[refLayerIdc][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
     888        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
    875889#endif
    876890
    877891#if SVC_UPSAMPLING
    878       if ( pcPic->isSpatialEnhLayer())
    879       {   
     892        if( pcPic->isSpatialEnhLayer(refLayerIdc) )
     893        {   
    880894#if SCALED_REF_LAYER_OFFSETS
    881         m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
    882 #else
    883         m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
    884 #endif
    885       }
    886       else
    887       {
    888         pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );
    889       }
    890       pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );
    891 #endif
     895          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     896#else
     897          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec() );
     898#endif
     899        }
     900        else
     901        {
     902          pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
     903        }
     904        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
     905#endif
     906      }
    892907    }
    893908
    894909#if REF_IDX_FRAMEWORK
     910#if ZERO_NUM_DIRECT_LAYERS
     911    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     912#else
    895913    if(m_layerId > 0)
     914#endif
    896915    {
    897916      setILRPic(pcPic);
     
    12921311#endif
    12931312  }
    1294 
    1295   // currently only one reference layer is supported
    1296   assert( vps->getNumDirectRefLayers( m_layerId ) == 1 );
    1297 #if JCTVC_M0458_INTERLAYER_RPS_SIG
    1298   assert( vps->getMaxOneActiveRefLayerFlag() == 1 );
    1299 #endif
    13001313 
    13011314  return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) );
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r258 r282  
    10671067          if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
    10681068          {
    1069             WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1");           
     1069            WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1");
    10701070          }       
    10711071          for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h

    r212 r282  
    145145  Int       m_numDirectRefLayers;
    146146  Int       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
     147
     148  Int       m_numActiveRefLayers;
     149  Int       m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];
    147150#endif
    148151  //======= Transform =============
     
    405408  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
    406409  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
     410
     411  Int       getNumActiveRefLayers           ()                              { return m_numActiveRefLayers;      }
     412  Void      setNumActiveRefLayers           (Int num)                       { m_numActiveRefLayers = num;       }
     413
     414  Int       getPredLayerId                  (Int i)                         { return m_predLayerId[i];          }
     415  Void      setPredLayerId                  (Int i, Int refLayerId)         { m_predLayerId[i] = refLayerId;    }
    407416#endif
    408417  //======== Transform =============
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCu.cpp

    r191 r282  
    108108  // initialize conversion matrix from partition index to pel
    109109  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uhTotalDepth );
     110
    110111}
    111112
     
    455456  {
    456457#if (ENCODER_FAST_MODE)
    457     bool testInter = true;
     458    Bool testInter = true;
    458459    if (rpcBestCU->getLayerId() > 0)
    459460    {
    460       if (rpcBestCU->getSlice()->getBaseColPic()->getSlice(0)->getSliceType() == I_SLICE)
    461       {
    462         testInter = false;
    463       }
    464 
     461        if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx())
     462            testInter = false;
     463        if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx())
     464            testInter = false;
    465465    }
    466466#endif
     
    767767      }
    768768#endif
    769 
    770769#if (ENCODER_FAST_MODE)
    771         if(pcPic->getLayerId() > 0)
    772         {
    773           xCheckRDCostILRUni( rpcBestCU, rpcTempCU);
    774           rpcTempCU->initEstData( uiDepth, iQP );
    775        }
     770      if(pcPic->getLayerId() > 0)
     771      {
     772        for(Int refLayer = 0; refLayer < pcSlice->getActiveNumILRRefIdx(); refLayer++)
     773        { 
     774           xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer));
     775           rpcTempCU->initEstData( uiDepth, iQP );
     776        }
     777      }
    776778#endif
    777779
     
    18121814}
    18131815#endif
    1814 
    18151816#if (ENCODER_FAST_MODE)
    1816 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU)
     1817Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId)
    18171818{
    18181819  UChar uhDepth = rpcTempCU->getDepth( 0 );
    1819 
    18201820  rpcTempCU->setDepthSubParts( uhDepth, 0 );
    1821 
    18221821#if SKIP_FLAG
    18231822  rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
    18241823#endif
    1825 
    18261824  rpcTempCU->setPartSizeSubParts  ( SIZE_2Nx2N,  0, uhDepth );  //2Nx2N
    18271825  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    18281826  rpcTempCU->setCUTransquantBypassSubParts  ( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );
    1829 
    1830   Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
    1831 
     1827  Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], refLayerId );
    18321828  if(!exitILR)
    18331829  {
    1834     return;
    1835   }
    1836 
     1830     return;
     1831  }
    18371832  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
    1838 
    18391833  rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    1840 
    18411834  xCheckDQP( rpcTempCU );
    18421835  xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
    1843 
    18441836  return;
    18451837}
    18461838#endif
    1847 
    1848 
    18491839//! \}
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCu.h

    r191 r282  
    158158#endif
    159159#if ENCODER_FAST_MODE
    160   Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU );
     160  Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);
    161161#endif
    162162  Void  xCheckDQP           ( TComDataCU*  pcCU );
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r251 r282  
    535535    if (m_layerId > 0)
    536536    {
     537      for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     538      {
     539        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
    537540#if VPS_EXTN_DIRECT_REF_LAYERS
    538       TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(m_layerId-1)->getListPic();
    539 #else
    540       TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
    541 #endif
    542       pcSlice->setBaseColPic (*cListPic, m_layerId );
    543      
     541        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(refLayerIdc)->getListPic();
     542#else
     543        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
     544#endif
     545        pcSlice->setBaseColPic( *cListPic, refLayerIdc );
     546
    544547#if SIMPLIFIED_MV_POS_SCALING
    545548#if SCALED_REF_LAYER_OFFSETS
    546       const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow();
    547 
    548       Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
    549       Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
    550 
    551       Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    552       Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    553 #else
    554       const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
    555       const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
    556 
    557       Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
    558       Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
    559 
    560       Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
    561       Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    562 #endif
    563       g_mvScalingFactor[m_layerId][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    564       g_mvScalingFactor[m_layerId][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
    565 
    566       g_posScalingFactor[m_layerId][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
    567       g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
    568 #endif
    569 
    570 #if ZERO_NUM_DIRECT_LAYERS
    571       if( pcSlice->getActiveNumILRRefIdx() )
    572 #endif
    573       {
     549        const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow();
     550
     551        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
     552        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
     553
     554        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     555        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     556#else
     557        const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getConformanceWindow();
     558        const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     559
     560        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     561        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     562
     563        Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     564        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     565#endif
     566        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     567        g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     568
     569        g_posScalingFactor[refLayerIdc][0] = ((widthBL  << 16) + (widthEL  >> 1)) / widthEL;
     570        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
     571#endif
     572
    574573#if SVC_UPSAMPLING
    575         if ( pcPic->isSpatialEnhLayer())
     574        if( pcPic->isSpatialEnhLayer(refLayerIdc))
    576575        {
    577576#if SCALED_REF_LAYER_OFFSETS
    578           m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
    579 #else
    580           m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     577          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     578#else
     579          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec() );
    581580#endif
    582581        }
    583582        else
    584583        {
    585           pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );
    586         }
    587         pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );
     584          pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
     585        }
     586        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
    588587#endif
    589588      }
     
    595594    {
    596595#if IDR_ALIGNMENT
    597       if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    598       {
    599         pcSlice->setNalUnitType(pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType());
     596      TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic();
     597      TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() );
     598      if( picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     599      {
     600        pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType());
    600601      }
    601602      else
     
    935936    {
    936937      pcSlice->getSPS()->setTMVPFlagsPresent(1);
     938#if SVC_EXTENSION
     939      if( pcSlice->getIdrPicFlag() )
     940      {
     941        pcSlice->setEnableTMVPFlag(0);
     942      }
     943      else
     944#endif
    937945      pcSlice->setEnableTMVPFlag(1);
    938946    }
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r212 r282  
    32873287#endif
    32883288
    3289 #if (ENCODER_FAST_MODE)
    3290     Bool          testILR;
    3291 #endif
    3292 
    32933289    xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
    32943290   
     
    33123308      RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    33133309     
    3314 #if (ENCODER_FAST_MODE)
    3315       if (pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1)
    3316       {
    3317         testILR = false;
    3318       }
    3319       else
    3320       {
    3321         testILR = true;
    3322       }
    3323 #endif
    3324 
    33253310      for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
    33263311      {
    33273312#if (ENCODER_FAST_MODE)
    33283313        TComPic* pcPic    = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
    3329         if( !testILR && pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )
     3314        if( pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )
    33303315        {
    33313316          continue;
     
    63056290
    63066291#if ENCODER_FAST_MODE
    6307 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv )
     6292Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId )
    63086293{
    6309   rpcPredYuv->clear();
    6310   rpcRecoYuv->clear();
    6311 
    6312   Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
    6313 
    6314   TComMv        cMv[2];
    6315   TComMv        cMvPred[2][33];
    6316   TComMv        cMvTemp[2][33];
    6317   TComMv        TempMv;
    6318 
    6319   Int           iRefIdx[2]={0,0};
    6320 
    6321   Int           aaiMvpIdx[2][33];
    6322   Int           aaiMvpNum[2][33];
    6323 
    6324   UInt          uiMbBits[3] = {1, 1, 0};
    6325   UInt          uiLastMode = 0;
    6326 
    6327   UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
    6328   UInt          uiCostTemp;
    6329   UInt          biPDistTemp = MAX_INT;
    6330   UInt          uiBitsTemp;
    6331 
    6332   PartSize      ePartSize = pcCU->getPartitionSize( 0 );  //2Nx2N
    6333   Int           iPartIdx  = 0;                            //one PU in CU
    6334   UInt          uiPartAddr;
    6335   Int           iRoiWidth, iRoiHeight;
    6336 
    6337   xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
    6338   pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    6339 
    6340   for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++)  //list
    6341   {
    6342     RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    6343 
    6344     Int  iRefIdxTemp = -1;
    6345     Bool foundILR    = false;
    6346     for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
    6347     {
    6348       if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) )
    6349       {
    6350         iRefIdxTemp = refIdx;
    6351         foundILR    = true;
    6352         break;
    6353       }
    6354     }
    6355 
    6356     if(!foundILR)  //no ILR in eRefPiclist
    6357     {
    6358       continue; 
    6359     }
    6360 
    6361     uiBitsTemp = uiMbBits[iRefList];
    6362     if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
    6363     {
    6364       uiBitsTemp += iRefIdxTemp+1;
    6365       if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
    6366     }
    6367 
    6368     xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
    6369     aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
    6370     aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
    6371 
    6372     uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    6373 
    6374     xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
    6375     xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    6376 
    6377     if( uiCostTemp < uiCost[iRefList] )
    6378     {
    6379       uiCost[iRefList] = uiCostTemp;
    6380 
    6381       cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
    6382       iRefIdx[iRefList] = iRefIdxTemp;
    6383 
    6384       pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    6385       pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    6386     }
    6387   }
    6388 
    6389   if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT )  //no ILR in both list0 and list1
    6390   {
    6391     return false;
    6392   }
    6393 
    6394   //  Clear Motion Field
    6395   pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
    6396   pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
    6397   pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
    6398   pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
    6399 
    6400   pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6401   pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6402   pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6403   pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6404 
    6405   if( uiCost[0] <= uiCost[1] )  //list0 ILR
    6406   {
    6407     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv    ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
    6408     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
    6409 
    6410     TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
    6411     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
    6412 
    6413     pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    6414 
    6415     pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6416     pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6417   }
    6418   else if( uiCost[1] < uiCost[0] )  //list1 ILR
    6419   {
    6420     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv    ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
    6421     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
    6422 
    6423     TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
    6424     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
    6425 
    6426     pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    6427 
    6428     pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6429     pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6430   }
    6431   else
    6432   {
    6433     assert(0);
    6434   }
    6435 
    6436   pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    6437 
    6438   motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
    6439 
    6440   setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
    6441 
    6442   return true;
     6294    rpcPredYuv->clear();
     6295    rpcRecoYuv->clear();
     6296
     6297    Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
     6298
     6299    TComMv        cMv[2];
     6300    TComMv        cMvPred[2][33];
     6301    TComMv        cMvTemp[2][33];
     6302    TComMv        TempMv;
     6303
     6304    Int           iRefIdx[2]={0,0};
     6305
     6306    Int           aaiMvpIdx[2][33];
     6307    Int           aaiMvpNum[2][33];
     6308
     6309    UInt          uiMbBits[3] = {1, 1, 0};
     6310    UInt          uiLastMode = 0;
     6311
     6312    UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
     6313    UInt          uiCostTemp;
     6314    UInt          biPDistTemp = MAX_INT;
     6315    UInt          uiBitsTemp;
     6316
     6317    PartSize      ePartSize = pcCU->getPartitionSize( 0 );  //2Nx2N
     6318    Int           iPartIdx  = 0;                            //one PU in CU
     6319    UInt          uiPartAddr;
     6320    Int           iRoiWidth, iRoiHeight;
     6321    Bool          bILRSearched = false;
     6322
     6323    xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
     6324    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
     6325
     6326    for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++)  //list
     6327    {
     6328        if(bILRSearched)
     6329           continue;
     6330
     6331        RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     6332
     6333        Int  iRefIdxTemp = -1;
     6334        Bool foundILR    = false;
     6335
     6336        for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
     6337        {
     6338            if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) && pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getLayerId() == refLayerId )
     6339            {
     6340                iRefIdxTemp = refIdx;
     6341                foundILR    = true;
     6342                bILRSearched = true;
     6343                break;
     6344            }
     6345        }
     6346
     6347        if(!foundILR)  //no ILR in eRefPiclist
     6348        {
     6349            continue; 
     6350        }
     6351
     6352        uiBitsTemp = uiMbBits[iRefList];
     6353        if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
     6354        {
     6355            uiBitsTemp += iRefIdxTemp+1;
     6356            if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
     6357        }
     6358
     6359        xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
     6360        aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
     6361        aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
     6362
     6363        uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
     6364
     6365        xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     6366        xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
     6367
     6368        if( uiCostTemp < uiCost[iRefList] )
     6369        {
     6370            uiCost[iRefList] = uiCostTemp;
     6371
     6372            cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
     6373            iRefIdx[iRefList] = iRefIdxTemp;
     6374
     6375            pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6376            pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6377        }
     6378    }
     6379
     6380    if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT )  //no ILR in both list0 and list1
     6381    {
     6382        return false;
     6383    }
     6384
     6385    //  Clear Motion Field
     6386    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6387    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6388    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6389    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6390
     6391    pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6392    pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6393    pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6394    pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6395
     6396    if( uiCost[0] <= uiCost[1] )  //list0 ILR
     6397    {
     6398        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv    ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6399        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6400
     6401        TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
     6402        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6403
     6404        pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6405
     6406        pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6407        pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6408    }
     6409    else if( uiCost[1] < uiCost[0] )  //list1 ILR
     6410    {
     6411        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv    ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6412        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6413
     6414        TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
     6415        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6416
     6417        pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6418
     6419        pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6420        pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6421    }
     6422    else
     6423    {
     6424        assert(0);
     6425    }
     6426
     6427    pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
     6428
     6429    motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
     6430    setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
     6431
     6432    return true;
    64436433}
    6444 
    6445 
    64466434#endif
    64476435
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSearch.h

    r191 r282  
    216216 
    217217#if (ENCODER_FAST_MODE)
    218   Bool predInterSearchILRUni    ( TComDataCU* pcCU,
    219                                   TComYuv*    pcOrgYuv,
    220                                   TComYuv*&   rpcPredYuv,
    221                                   TComYuv*&   rpcResiYuv,
    222                                   TComYuv*&   rpcRecoYuv
    223                                 );
    224 
     218  Bool predInterSearchILRUni    ( TComDataCU* pcCU, TComYuv*    pcOrgYuv, TComYuv*&   rpcPredYuv, TComYuv*&   rpcResiYuv, TComYuv*&   rpcRecoYuv, UInt        refLayerId );
    225219#endif
    226220 
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r258 r282  
    493493    if( rpcSlice->getNumILRRefIdx() > 0 )
    494494    {
    495       rpcSlice->setActiveNumILRRefIdx( rpcSlice->getNumILRRefIdx() );
     495      rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[layerId]->getNumActiveRefLayers() );
    496496      for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    497497      {
    498         rpcSlice->setInterLayerPredLayerIdc(i, i);
     498        rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[layerId]->getPredLayerId(i), i );
    499499      }
    500500      rpcSlice->setInterLayerPredEnabledFlag(1);
     
    995995    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
    996996    pcCU->initCU( rpcPic, uiCUAddr );
    997 #if SVC_EXTENSION
    998     pcCU->setLayerId(m_pcCfg->getLayerId());
    999 #endif
    1000997
    1001998#if !RATE_CONTROL_LAMBDA_DOMAIN
  • branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r250 r282  
    507507      if(m_layerId > 0)
    508508      {
     509        for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ )
     510        {
     511          const Window scalEL = getSPS()->getScaledRefLayerWindow();
     512          Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
     513
    509514#if VPS_EXTN_DIRECT_REF_LAYERS
    510         TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId - 1 );
    511 #else
    512         TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
    513 #endif
    514         if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
    515         {
    516           pcEPic->setSpatialEnhLayerFlag( true );
    517 
    518           //only for scalable extension
    519           assert( m_cVPS.getScalabilityMask(1) == true );
     515          TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i );
     516#else
     517          TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     518#endif
     519          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     520          {
     521            pcEPic->setSpatialEnhLayerFlag( i, true );
     522
     523            //only for scalable extension
     524            assert( m_cVPS.getScalabilityMask(1) == true );
     525          }
    520526        }
    521527      }
     
    538544      if(m_layerId > 0)
    539545      {
     546        for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ )
     547        {
     548          const Window scalEL = getSPS()->getScaledRefLayerWindow();
     549          Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
     550
    540551#if VPS_EXTN_DIRECT_REF_LAYERS
    541         TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId - 1 );
    542 #else
    543         TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
    544 #endif
    545         if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() )
    546         {
    547           rpcPic->setSpatialEnhLayerFlag( true );
    548 
    549           //only for scalable extension
    550           assert( m_cVPS.getScalabilityMask(1) == true );
     552          TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i );
     553#else
     554          TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 );
     555#endif
     556          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     557          {
     558            rpcPic->setSpatialEnhLayerFlag( i, true );
     559
     560            //only for scalable extension
     561            assert( m_cVPS.getScalabilityMask(1) == true );
     562          }
    551563        }
    552564      }
     
    12101222  }
    12111223
    1212   // currently only one reference layer is supported
    1213   assert( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() == 1 );
    1214 
    1215   return (TEncTop *)getLayerEnc( getVPS()->getRefLayerId( m_layerId, refLayerIdc ) );
     1224  return (TEncTop *)getLayerEnc( m_cVPS.getRefLayerId( m_layerId, refLayerIdc ) );
    12161225}
    12171226#endif
     
    12351244    if (m_cIlpPic[0] == NULL)
    12361245    {
    1237       for (Int j=0; j<1/*MAX_NUM_REF*/; j++)
     1246      for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
    12381247      {
    12391248        m_cIlpPic[j] = new  TComPic;
     
    12541263Void TEncTop::setILRPic(TComPic *pcPic)
    12551264{
    1256   if(m_cIlpPic[0])
    1257   {
    1258     m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    1259     m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
    1260     m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId
    1261     m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    1262     m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     1265  for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ )
     1266  {
     1267    Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i);
     1268
     1269    if(m_cIlpPic[refLayerIdc])
     1270    {
     1271      m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(refLayerIdc), m_cIlpPic[refLayerIdc]->getPicYuvRec());
     1272      m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC());
     1273      m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(refLayerIdc)->getLayerId()); //set reference layerId
     1274      m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false);
     1275      m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder();
     1276    }
    12631277  }
    12641278}
Note: See TracChangeset for help on using the changeset viewer.