Ticket #1378: slice_bugfix.diff

File slice_bugfix.diff, 6.2 KB (added by cgisquet, 9 years ago)

Slice-only fix to test T0048/T0055

  • ../source/Lib/TLibCommon/TypeDef.h

     
    4141#include <vector>
    4242#include <cstdlib>
    4343
     44#define IBC_SLICE_BUGFIX                    1 // Don't let IBC use pixels outside of slice:  1=MTK  2=Canon
     45#define IBC_VALIDATE_SLICES                 1 // Print at decoder when IBC reaches outside of current slice
     46
    4447//! \ingroup TLibCommon
    4548//! \{
    4649
  • ../source/Lib/TLibDecoder/TDecSbac.cpp

     
    12411241  mvy = MvPred[uiMvpIdx].getVer() + pcCU->getCUMvField(REF_PIC_LIST_INTRABC)->getMvd(uiAbsPartIdx).getVer();
    12421242
    12431243  const TComMv cMv(mvx, mvy );
     1244#if IBC_VALIDATE_SLICES
     1245  UInt raster = g_auiZscanToRaster[uiAbsPartIdx];
     1246  TComPicSym *pcSym = pcCU->getPic()->getPicSym();
     1247  Int ctuX = (pcCU->getCUPelX() + g_auiRasterToPelX[raster] + mvx) / g_uiMaxCUWidth;
     1248  Int ctuY = (pcCU->getCUPelY() + g_auiRasterToPelY[raster] + mvy) / g_uiMaxCUHeight;
     1249  UInt ctuAddr = ctuX + ctuY*pcSym->getFrameWidthInCtus();
     1250  if (pcSym->getCtu(ctuAddr)->getSlice()->getSliceIdx() != pcCU->getSlice()->getSliceIdx())
     1251  {
     1252    printf("BV (%i,%i) for PU%u in CU %u,%u+%u, slice %u points to CTU %u, slice %u\n",
     1253           mvx, mvy, uiPartIdx, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu(), uiAbsPartIdx,
     1254           pcCU->getSlice()->getSliceIdx(), ctuAddr, pcSym->getCtu(ctuAddr)->getSlice()->getSliceIdx());
     1255  }
     1256#endif
    12441257
    12451258  pcCU->getCUMvField( REF_PIC_LIST_INTRABC )->setAllMv( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiDepth, uiPartIdx );
    12461259  if( pcCU->getLastIntraBCMv() != cMv)
  • ../source/Lib/TLibEncoder/TEncSearch.cpp

     
    69236923  const UInt uiNonHashSearchWidth = pcCU->getIntraBCSearchAreaWidth( m_pcEncCfg->getIntraBCNonHashSearchWidthInCTUs() );
    69246924  const UInt uiCtuPelX            = (cuPelX / uiMaxCuWidth) * uiMaxCuWidth;
    69256925  const UInt uiCtuPelY            = (cuPelY / uiMaxCuHeight) * uiMaxCuHeight;
     6926#if IBC_SLICE_BUGFIX
     6927  const ChromaFormat format = pcCU->getPic()->getChromaFormat();
     6928  const Int        iRelCUPelX = cuPelX % uiMaxCuWidth;
     6929  const Int        iRelCUPelY = cuPelY % uiMaxCuHeight;
     6930  const Int chromaROIWidthInPixels = (((format == CHROMA_420) || (format == CHROMA_422)) && (iRoiWidth == 4) && ((iRelCUPelX & 0x4) != 0)) ? (iRoiWidth * 2) : iRoiWidth;
     6931  const Int chromaROIHeightInPixels = (((format == CHROMA_420)) && (iRoiHeight == 4) && ((iRelCUPelY & 0x4) != 0)) ? (iRoiHeight * 2) : iRoiHeight;
     6932  const Int chromaROIStartXInPixels = iRelCUPelX + iRoiWidth - chromaROIWidthInPixels;
     6933  const Int chromaROIStartYInPixels = iRelCUPelY + iRoiHeight - chromaROIHeightInPixels;
     6934#endif
    69266935
    69276936  Distortion  uiSad;
    69286937
     
    69516960        continue;
    69526961      }
    69536962    }
     6963#if IBC_SLICE_BUGFIX
     6964    if (!isValidIntraBCSearchArea(pcCU, 0, iTempX - cuPelX, chromaROIStartXInPixels, iTempY - cuPelY, chromaROIStartYInPixels, chromaROIWidthInPixels, chromaROIHeightInPixels, 0))
     6965    {
     6966      HashLinklist = HashLinklist->next;
     6967      continue;
     6968    }
     6969#endif
    69546970
    69556971#if SCM_S0220_IBC_PRED_CONSTRAINT
    69566972     Int uiRefCuX   = (iTempX + iRoiWidth  - 1)/uiMaxCuWidth;
  • ../source/Lib/TLibEncoder/TEncSearch.h

     
    380380      return false;
    381381    }
    382382
     383#if IBC_SLICE_BUGFIX == 1
     384    const Int uiPicWidthinCtu = pcCU->getPic()->getFrameWidthInCtus();
     385    Int refPelX = cuPelX + predX;
     386    Int refPelY = cuPelY + predY;
     387    Int uiRefCtuX = refPelX / uiMaxCuWidth;
     388    Int uiRefCtuY = refPelY / uiMaxCuHeight;
     389    Int refCtuAddr = uiPicWidthinCtu * uiRefCtuY + uiRefCtuX;
     390   
     391    if (refCtuAddr < 0 || refCtuAddr >= pcCU->getPic()->getFrameWidthInCtus() || pcCU->getPic()->getCtu(refCtuAddr)->getSlice() == NULL || !pcCU->CUIsFromSameSliceAndTile(pcCU->getPic()->getCtu(refCtuAddr)))
     392    {
     393      return false;
     394    }
     395   
     396    Int refPelBRX        = cuPelX + predX + roiWidth  - 1;
     397    Int refPelBRY        = cuPelY + predY + roiHeight - 1;
     398    Int uiRefCtuBRX      = refPelBRX / uiMaxCuWidth;
     399    Int uiRefCtuBRY      = refPelBRY / uiMaxCuHeight;
     400    Int refCtuBRAddr     = uiPicWidthinCtu * uiRefCtuBRY + uiRefCtuBRX;
     401
     402    if( refCtuBRAddr < 0 || refCtuBRAddr >= pcCU->getPic()->getFrameWidthInCtus() || pcCU->getPic()->getCtu( refCtuBRAddr )->getSlice() == NULL || !pcCU->CUIsFromSameSliceAndTile(  pcCU->getPic()->getCtu( refCtuBRAddr ) ) )
     403    {
     404      return false;
     405    }
     406#endif
     407#if IBC_SLICE_BUGFIX == 2
     408    TComSlice *pcSlice = pcCU->getSlice();
     409    if (pcSlice->getSliceMode())
     410    {
     411      TComPicSym *pcSym = pcCU->getPic()->getPicSym();
     412      Int      ctuX = (cuPelX + predX) / uiMaxCuWidth;
     413      Int      ctuY = (cuPelY + predY) / uiMaxCuHeight;
     414      UInt   refCtu = ctuX + pcSym->getFrameWidthInCtus()*ctuY;
     415      UInt startCtu = pcSym->getCtuTsToRsAddrMap(pcCU->getSlice()->getSliceSegmentCurStartCtuTsAddr());
     416      if (refCtu < startCtu) return false;
     417    }
     418#endif
     419
    383420#if SCM_420_IBC_BUGFIX
    384421    // check boundary
    385422    if ( pcCU->getWidth( 0 ) == 8 && pcCU->getPartitionSize( 0 ) != SIZE_2Nx2N && pcCU->getSlice()->getPic()->getPicYuvOrg()->getChromaFormat() != CHROMA_444 )
  • ../source/Lib/TLibEncoder/TEncSlice.cpp

     
    794794    pcPic->getPicYuvResi()->DefaultConvertPix( pcPic->getPicYuvOrg() );
    795795  }
    796796
     797#if IBC_SLICE_BUGFIX
     798  if (m_pcCfg->getUseHashBasedIntraBCSearch())
     799  {
     800    m_pcPredSearch->xClearIntraBCHashTable();
     801  }
     802#endif
     803
    797804  // for every CTU in slice
    798805  for( UInt ctuTsAddr = startCtuTsAddr; ctuTsAddr < boundingCtuTsAddr; ++ctuTsAddr)
    799806  {