Ignore:
Timestamp:
11 Dec 2015, 00:05:48 (8 years ago)
Author:
seregin
Message:

infer parameters in SPS after activation, fixing chroma scaling for non 4:2:0

File:
1 edited

Legend:

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

    r1500 r1502  
    6464  const Window &windowRL = currSlice->getPPS()->getRefLayerWindowForLayer(refLayerId);
    6565
    66   Int bitDepthLuma = currSlice->getBitDepth(CHANNEL_TYPE_LUMA);
    67   Int bitDepthChroma = currSlice->getBitDepth(CHANNEL_TYPE_CHROMA);
     66  Int bitDepthLuma = currSlice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
     67  Int bitDepthChroma = currSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA);
    6868
    6969  //========== Y component upsampling ===========
     
    7676  Int strideEL  = pcUsPic->getStride(COMPONENT_Y);
    7777
    78   ChromaFormat chromaFormatIdc = currSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
     78  ChromaFormat chromaFormatIdc = currSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getSPS()->getChromaFormatIdc();
     79#if SCALABLE_REXT
     80  Int chromaHorScalingEL = TComSPS::getWinUnitX( currSlice->getSPS()->getChromaFormatIdc() );
     81  Int chromaVerScalingEL = TComSPS::getWinUnitY( currSlice->getSPS()->getChromaFormatIdc() );
     82
     83  Int chromaHorScalingBL = TComSPS::getWinUnitX( chromaFormatIdc );
     84  Int chromaVerScalingBL = TComSPS::getWinUnitY( chromaFormatIdc );
     85#else
    7986  Int xScal = TComSPS::getWinUnitX( chromaFormatIdc );
    8087  Int yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     88#endif
    8189
    8290  const ResamplingPhase &resamplingPhase = currSlice->getPPS()->getResamplingPhase( refLayerId );
     
    151159
    152160#if SCALABLE_REXT
    153   if(chromaFormatIdc != 0)
     161  if( chromaFormatIdc != CHROMA_400 )
    154162  {
    155 #endif
     163    widthEL  /= chromaHorScalingEL;
     164    heightEL /= chromaVerScalingEL;
     165    widthBL  /= chromaHorScalingBL;
     166    heightBL /= chromaVerScalingBL;
     167#else
    156168    widthEL  >>= 1;
    157169    heightEL >>= 1;
     
    159171    widthBL  >>= 1;
    160172    heightBL >>= 1;
     173#endif
    161174
    162175    strideBL = pcBasePic->getStride( COMPONENT_Cb );
     
    166179    piSrcV = piSrcBufV;
    167180
     181#if SCALABLE_REXT
     182    piDstU = piDstBufU + ( scalEL.getWindowLeftOffset() / chromaHorScalingEL ) + ( scalEL.getWindowTopOffset() / chromaVerScalingEL ) * strideEL;
     183    piDstV = piDstBufV + ( scalEL.getWindowLeftOffset() / chromaHorScalingEL ) + ( scalEL.getWindowTopOffset() / chromaVerScalingEL ) * strideEL;
     184#else
    168185    piDstU = piDstBufU + ( scalEL.getWindowLeftOffset() >> 1 ) + ( scalEL.getWindowTopOffset() >> 1 ) * strideEL;
    169186    piDstV = piDstBufV + ( scalEL.getWindowLeftOffset() >> 1 ) + ( scalEL.getWindowTopOffset() >> 1 ) * strideEL;
     187#endif
    170188
    171189    shift = bitDepthChroma - refBitDepthChroma;
     
    309327
    310328#if SCALABLE_REXT
    311   if(chromaFormatIdc != 0)
     329  if( chromaFormatIdc != CHROMA_400 )
    312330  {
    313 #endif
     331    widthEL  /= chromaHorScalingEL;
     332    heightEL /= chromaVerScalingEL;
     333    widthBL  /= chromaHorScalingBL;
     334    heightBL /= chromaVerScalingBL;
     335#else
    314336    widthEL  >>= 1;
    315337    heightEL >>= 1;
    316338    widthBL  >>= 1;
    317339    heightBL >>= 1;
     340#endif
    318341
    319342    strideBL  = pcBasePic->getStride( COMPONENT_Cb );
    320343    strideEL  = pcUsPic->getStride( COMPONENT_Cb );
    321344
     345#if SCALABLE_REXT
     346    Int srlLOffsetC = scalEL.getWindowLeftOffset() / chromaHorScalingEL;
     347    Int srlTOffsetC = scalEL.getWindowTopOffset() / chromaVerScalingEL;
     348#else
    322349    Int srlLOffsetC = scalEL.getWindowLeftOffset() >> 1;
    323350    Int srlTOffsetC = scalEL.getWindowTopOffset() >> 1;
     351#endif
     352
    324353    rlClipL = -(NTAPS_US_CHROMA>>1);
    325354    rlClipR = widthBL -1 + (NTAPS_US_CHROMA>>1);
     
    331360    addX = ( ( resamplingPhase.phaseHorChroma * scaleX + 8 ) >> 4 ) -  (1 << ( shiftX - 5 ));
    332361    addY = ( ( phaseVerChroma * scaleY + 8 ) >> 4 ) -  (1 << ( shiftX - 5 ));
     362
     363#if SCALABLE_REXT
     364    Int refOffsetXC = (windowRL.getWindowLeftOffset() / chromaHorScalingBL) << 4;
     365    Int refOffsetYC = (windowRL.getWindowTopOffset()  / chromaVerScalingBL) << 4;
     366#else
    333367    Int refOffsetXC = (windowRL.getWindowLeftOffset() / xScal) << 4;
    334368    Int refOffsetYC = (windowRL.getWindowTopOffset()  / yScal) << 4;
     369#endif
    335370
    336371    shiftXM4 = shiftX - 4;
    337372    shiftYM4 = shiftY - 4;
    338373
     374#if SCALABLE_REXT
     375    widthEL   = pcUsPic->getWidth (COMPONENT_Y) / chromaHorScalingEL;
     376    heightEL  = pcUsPic->getHeight(COMPONENT_Y) / chromaVerScalingEL;
     377
     378    widthBL   = pcBasePic->getWidth (COMPONENT_Y) / chromaHorScalingBL;
     379    heightBL  = min<Int>( pcBasePic->getHeight(COMPONENT_Y) / chromaVerScalingBL, heightEL );
     380#else
    339381    widthEL   = pcUsPic->getWidth (COMPONENT_Y) >> 1;
    340382    heightEL  = pcUsPic->getHeight(COMPONENT_Y) >> 1;
     
    342384    widthBL   = pcBasePic->getWidth (COMPONENT_Y) >> 1;
    343385    heightBL  = min<Int>( pcBasePic->getHeight(COMPONENT_Y) >> 1, heightEL );
     386#endif
    344387
    345388    // shift1 should be calculated using BL bit-depth
     
    382425    //========== vertical upsampling ===========
    383426    pcTempPic->setBorderExtension(false);
     427#if SCALABLE_REXT
     428    pcTempPic->setHeight(heightBL * chromaVerScalingBL);
     429#else
    384430    pcTempPic->setHeight(heightBL << 1);
     431#endif
    385432    pcTempPic->extendPicBorder   (); // extend the border.
     433#if SCALABLE_REXT
     434    pcTempPic->setHeight(heightEL * chromaVerScalingEL);
     435#else
    386436    pcTempPic->setHeight(heightEL << 1);
     437#endif
    387438
    388439    nShift = 20 - bitDepthChroma;
     
    390441    iOffset = 1 << (nShift - 1);
    391442
     443#if SCALABLE_REXT
     444    for( j = 0; j < pcTempPic->getHeight(COMPONENT_Y) / chromaVerScalingEL; j++ )
     445#else
    392446    for( j = 0; j < pcTempPic->getHeight(COMPONENT_Y) >> 1; j++ )
     447#endif
    393448    {
    394449      Int y = j;
     
    408463      piDstV = piDstV0;
    409464
     465#if SCALABLE_REXT
     466      for( i = pcTempPic->getWidth(COMPONENT_Y) / chromaHorScalingEL; i > 0; i-- )
     467#else
    410468      for( i = pcTempPic->getWidth(COMPONENT_Y) >> 1; i > 0; i-- )
     469#endif
    411470      {
    412471        *piDstU = ClipBD( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift), bitDepthChroma );
Note: See TracChangeset for help on using the changeset viewer.