Changeset 175 in SHVCSoftware for branches/SHM-2.0-dev/source/Lib


Ignore:
Timestamp:
9 May 2013, 22:48:02 (12 years ago)
Author:
qualcomm
Message:

Scaled reference layer offsets in SPS (MACRO: SCALED_REF_LAYER_OFFSETS)

M0309: Signal scaled reference layer offsets in the SPS and use it for upsampling and MV prediction.

From: Adarsh K. Ramasubramonian <aramasub@…>

Location:
branches/SHM-2.0-dev/source/Lib
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComDataCU.cpp

    r150 r175  
    42004200
    42014201#if SIMPLIFIED_MV_POS_SCALING
     4202#if SCALED_REF_LAYER_OFFSETS
     4203  Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowLeftOffset();
     4204  Int topStartL  = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowTopOffset();
     4205  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
     4206  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
     4207#else
    42024208  Int iBX = (uiPelX*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
    42034209  Int iBY = (uiPelY*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
     4210#endif
    42044211#else
    42054212  Int iBX = (uiPelX*widthBL + widthEL/2)/widthEL;
     
    42074214#endif
    42084215
     4216#if SCALED_REF_LAYER_OFFSETS
     4217  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() ||
     4218       iBX < 0                                        || iBY < 0                                           )
     4219#else
    42094220  if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight())
     4221#endif
    42104222  {
    42114223    return NULL;
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.cpp

    r134 r175  
    773773
    774774#if SVC_UPSAMPLING
     775#if SCALED_REF_LAYER_OFFSETS
     776Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
     777{
     778  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic, window);
     779}
     780#else
    775781Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
    776782{
    777783  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic);
    778784}
     785#endif
    779786#endif
    780787//! \}
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComPrediction.h

    r125 r175  
    122122
    123123#if SVC_UPSAMPLING
     124#if SCALED_REF_LAYER_OFFSETS
     125  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     126#else
    124127  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     128#endif
    125129#endif
    126130};
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h

    r174 r175  
    10201020#if REF_IDX_MFM
    10211021  Bool m_bMFMEnabledFlag;
     1022#endif
     1023#if SCALED_REF_LAYER_OFFSETS
     1024  Window      m_scaledRefLayerWindow;
    10221025#endif
    10231026public:
     
    11601163  Bool     getMFMEnabledFlag()          {return m_bMFMEnabledFlag;}
    11611164#endif
     1165#if SCALED_REF_LAYER_OFFSETS
     1166  Window&  getScaledRefLayerWindow(     )   { return m_scaledRefLayerWindow; }
     1167#endif
    11621168};
    11631169
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r166 r175  
    128128}
    129129
     130#if SCALED_REF_LAYER_OFFSETS
     131Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
     132#else
    130133Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
     134#endif
    131135{
    132136  assert ( NTAPS_US_LUMA == 8 );
     
    136140
    137141  //========== Y component upsampling ===========
     142#if SCALED_REF_LAYER_OFFSETS
     143  const Window &scalEL = window;
     144
     145  Int widthBL   = pcBasePic->getWidth ();
     146  Int heightBL  = pcBasePic->getHeight();
     147  Int strideBL  = pcBasePic->getStride();
     148
     149  Int widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     150  Int heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     151  Int strideEL  = pcUsPic->getStride();
     152#else
    138153  const Window &confBL = pcBasePic->getConformanceWindow();
    139154  const Window &confEL = pcUsPic->getConformanceWindow();
     
    146161  Int heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    147162  Int strideEL  = pcUsPic->getStride();
    148  
     163#endif
    149164  Pel* piTempBufY = pcTempPic->getLumaAddr();
    150165  Pel* piSrcBufY  = pcBasePic->getLumaAddr();
     
    329344  const Double sFactor12 = sFactor * 12;
    330345#endif
    331 
    332346#if ILP_DECODED_PICTURE
    333347  widthBL   = pcBasePic->getWidth ();
     
    337351  heightEL  = pcUsPic->getHeight();
    338352#endif
     353#if SCALED_REF_LAYER_OFFSETS
     354  Int leftStartL = scalEL.getWindowLeftOffset();
     355  Int rightEndL  = pcUsPic->getWidth() - scalEL.getWindowRightOffset();
     356  Int topStartL  = scalEL.getWindowTopOffset();
     357  Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
     358#endif
    339359
    340360  //========== horizontal upsampling ===========
    341361  for( i = 0; i < widthEL; i++ )
    342362  {
     363#if SCALED_REF_LAYER_OFFSETS
     364    Int x = Clip3( leftStartL, rightEndL - 1, i );
     365#endif
    343366#if PHASE_DERIVATION_IN_INTEGER
     367#if SCALED_REF_LAYER_OFFSETS
     368    refPos16 = (((x - leftStartL)*scaleX + addX) >> shiftXM4) - deltaX;
     369#else
    344370    refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
     371#endif
    345372    phase    = refPos16 & 15;
    346373    refPos   = refPos16 >> 4;
     
    374401  Int iOffset = 1 << (nShift - 1);
    375402
     403#if SCALED_REF_LAYER_OFFSETS
     404  for( j = 0; j < pcTempPic->getHeight(); j++ )
     405#else
    376406  for( j = 0; j < heightEL; j++ )
    377   {
     407#endif
     408  {
     409#if SCALED_REF_LAYER_OFFSETS
     410    Int y = Clip3(topStartL, bottomEndL - 1, j);
     411#endif
    378412#if PHASE_DERIVATION_IN_INTEGER
     413#if SCALED_REF_LAYER_OFFSETS
     414    refPos16 = ((( y - topStartL )*scaleY + addY) >> shiftYM4) - deltaY;
     415#else
    379416    refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
     417#endif
    380418    phase    = refPos16 & 15;
    381419    refPos   = refPos16 >> 4;
     
    390428    piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
    391429    piDstY = piDstBufY + j * strideEL;
    392 
     430#if SCALED_REF_LAYER_OFFSETS
     431    for( i = 0; i < pcTempPic->getWidth(); i++ )
     432#else
    393433    for( i = 0; i < widthEL; i++ )
     434#endif
    394435    {
    395436      *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
     437#if SCALED_REF_LAYER_OFFSETS
     438      // Only increase the x position of reference upsample picture when within the window
     439      // "-2" to ensure that pointer doesn't go beyond the boundeary rightEndL-1
     440      if( (i >= leftStartL) && (i <= rightEndL-2) )
     441      {
     442        piSrcY++;
     443      }
     444#else
    396445      piSrcY++;
     446#endif
    397447      piDstY++;
    398448    }
     
    400450
    401451#if ILP_DECODED_PICTURE
     452#if SCALED_REF_LAYER_OFFSETS
     453  widthBL   = pcBasePic->getWidth ();
     454  heightBL  = pcBasePic->getHeight();
     455
     456  widthEL   = pcUsPic->getWidth () - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     457  heightEL  = pcUsPic->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     458#else
    402459  widthBL   = pcBasePic->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
    403460  heightBL  = pcBasePic->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     
    406463  heightEL  = pcUsPic->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    407464#endif
     465#endif
    408466
    409467  //========== UV component upsampling ===========
     
    417475  strideBL  = pcBasePic->getCStride();
    418476  strideEL  = pcUsPic->getCStride();
     477#if SCALED_REF_LAYER_OFFSETS
     478  Int leftStartC = scalEL.getWindowLeftOffset() >> 1;
     479  Int rightEndC  = (pcUsPic->getWidth() >> 1) - (scalEL.getWindowRightOffset() >> 1);
     480  Int topStartC  = scalEL.getWindowTopOffset() >> 1;
     481  Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
     482#endif
    419483
    420484#if PHASE_DERIVATION_IN_INTEGER
     
    449513  for( i = 0; i < widthEL; i++ )
    450514  {
     515#if SCALED_REF_LAYER_OFFSETS
     516    Int x = Clip3(leftStartC, rightEndC - 1, i);
     517#endif
    451518#if PHASE_DERIVATION_IN_INTEGER
     519#if SCALED_REF_LAYER_OFFSETS
     520    refPos16 = (((x - leftStartC)*scaleX + addX) >> shiftXM4) - deltaX;
     521#else
    452522    refPos16 = ((i*scaleX + addX) >> shiftXM4) - deltaX;
     523#endif
    453524    phase    = refPos16 & 15;
    454525    refPos   = refPos16 >> 4;
     
    484555  pcTempPic->setHeight(heightEL << 1);
    485556
    486   for( j = 0; j < heightEL; j++ )
    487   {
     557#if SCALED_REF_LAYER_OFFSETS
     558  for( j = 0; j < pcTempPic->getHeight() >> 1; j++ )
     559#else
     560    for( j = 0; j < heightEL; j++ )
     561#endif
     562  {
     563#if SCALED_REF_LAYER_OFFSETS
     564    Int y = Clip3(topStartC, bottomEndC - 1, j);
     565#endif
    488566#if PHASE_DERIVATION_IN_INTEGER
     567#if SCALED_REF_LAYER_OFFSETS
     568    refPos16 = (((y - topStartC)*scaleY + addY) >> shiftYM4) - deltaY;
     569#else
    489570    refPos16 = ((j*scaleY + addY) >> shiftYM4) - deltaY;
     571#endif
    490572    phase    = refPos16 & 15;
    491573    refPos   = refPos16 >> 4;
     
    512594    piDstV = piDstBufV + j*strideEL;
    513595
     596#if SCALED_REF_LAYER_OFFSETS
     597    for( i = 0; i < pcTempPic->getWidth() >> 1; i++ )
     598#else
    514599    for( i = 0; i < widthEL; i++ )
     600#endif
    515601    {
    516602      *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
    517603      *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
    518604
     605#if SCALED_REF_LAYER_OFFSETS
     606      // Only increase the x position of reference upsample picture when within the window
     607      // "-2" to ensure that pointer doesn't go beyond the boundeary rightEndC-1
     608      if( (i >= leftStartC) && (i <= rightEndC-2) )
     609      {
     610        piSrcU++;
     611        piSrcV++;
     612      }
     613#else
    519614      piSrcU++;
    520615      piSrcV++;
     616#endif
    521617      piDstU++;
    522618      piDstV++;
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TComUpsampleFilter.h

    r2 r175  
    5252  ~TComUpsampleFilter(void);
    5353
     54#if SCALED_REF_LAYER_OFFSETS
     55  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     56#else
    5457 Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     58#endif
    5559};
    5660
  • branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h

    r174 r175  
    4444
    4545#if SVC_EXTENSION
     46#define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
    4647#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
    4748
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r174 r175  
    712712  }
    713713
     714#if SCALED_REF_LAYER_OFFSETS
     715  if( pcSPS->getLayerId() > 0 )
     716  {
     717    Int iCode;
     718    Window& scaledWindow = pcSPS->getScaledRefLayerWindow();
     719    READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
     720    READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
     721    READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
     722    READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
     723  }
     724#endif
     725
    714726  READ_FLAG( uiCode, "sps_extension_flag");
    715727  if (uiCode)
  • branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r174 r175  
    836836      if ( pcPic->isSpatialEnhLayer())
    837837      {   
     838#if SCALED_REF_LAYER_OFFSETS
     839        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     840#else
    838841        m_cPrediction.upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     842#endif
    839843      }
    840844      else
     
    948952  if (m_layerId > 0)
    949953  {
     954#if SCALED_REF_LAYER_OFFSETS
     955    const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow();
     956
     957    Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
     958    Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
     959
     960    Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     961    Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     962#else
    950963    const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
    951964    const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     
    956969    Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
    957970    Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    958 
     971#endif
    959972    g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    960973    g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r174 r175  
    553553      codeVUI(pcSPS->getVuiParameters(), pcSPS);
    554554  }
     555#if SCALED_REF_LAYER_OFFSETS
     556  if( pcSPS->getLayerId() > 0 )
     557  {
     558    Window scaledWindow = pcSPS->getScaledRefLayerWindow();
     559    WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
     560    WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
     561    WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
     562    WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
     563  }
     564#endif
    555565
    556566  WRITE_FLAG( 0, "sps_extension_flag" );
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r174 r175  
    690690#if SVC_UPSAMPLING
    691691      if ( pcPic->isSpatialEnhLayer())
    692       {   
     692      {
     693#if SCALED_REF_LAYER_OFFSETS
     694        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );
     695#else
    693696        m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );
     697#endif
    694698      }
    695699      else
     
    976980    if (m_layerId > 0)
    977981    {
     982#if SCALED_REF_LAYER_OFFSETS
     983      const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow();
     984
     985      Int widthBL   = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();
     986      Int heightBL  = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();
     987
     988      Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
     989      Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     990#else
    978991      const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
    979992      const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     
    984997      Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
    985998      Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
    986 
     999#endif
    9871000      g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    9881001      g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r164 r175  
    576576  m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag);
    577577#endif
     578#if SCALED_REF_LAYER_OFFSETS
     579  m_cSPS.getScaledRefLayerWindow() = m_scaledRefLayerWindow;
     580#endif
    578581  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
    579582  profileTierLevel.setLevelIdc(m_level);
  • branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncTop.h

    r134 r175  
    139139  Bool                    m_bMFMEnabledFlag;
    140140#endif
     141#if SCALED_REF_LAYER_OFFSETS
     142  Window                  m_scaledRefLayerWindow;
     143#endif
    141144protected:
    142145  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    203206  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
    204207#endif
     208#if SCALED_REF_LAYER_OFFSETS
     209  Window&  getScaledRefLayerWindow()            { return m_scaledRefLayerWindow; }
     210#endif
    205211
    206212  // -------------------------------------------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.