Changeset 5 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp


Ignore:
Timestamp:
12 Dec 2011, 18:35:44 (13 years ago)
Author:
hhi
Message:

Clean version with cfg-files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r2 r5  
     1/* The copyright in this software is being made available under the BSD
     2 * License, included below. This software may be subject to other third party
     3 * and contributor rights, including patent rights, and no such rights are
     4 * granted under this license.
     5 *
     6 * Copyright (c) 2010-2011, ISO/IEC
     7 * All rights reserved.
     8 *
     9 * Redistribution and use in source and binary forms, with or without
     10 * modification, are permitted provided that the following conditions are met:
     11 *
     12 *  * Redistributions of source code must retain the above copyright notice,
     13 *    this list of conditions and the following disclaimer.
     14 *  * Redistributions in binary form must reproduce the above copyright notice,
     15 *    this list of conditions and the following disclaimer in the documentation
     16 *    and/or other materials provided with the distribution.
     17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
     18 *    be used to endorse or promote products derived from this software without
     19 *    specific prior written permission.
     20 *
     21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
     25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31 * THE POSSIBILITY OF SUCH DAMAGE.
     32 */
     33
    134
    235
     
    268301
    269302#if QC_MDIS
    270 #if HHI_DISABLE_INTRA_SMOOTHING_DEPTH
    271   ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 1, iWidth, iHeight, m_piYuvExt, pcCU->getSlice()->getSPS()->isDepth() );
    272 #else
    273303  ptrSrc = pcTComPattern->getPredictorPtr( uiDirMode, g_aucConvertToBit[ iWidth ] + 1, iWidth, iHeight, m_piYuvExt );
    274 #endif
    275304#else
    276305  ptrSrc = pcTComPattern->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
     
    433462}
    434463
    435 #if HHI_DMM_INTRA
     464#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    436465Void TComPrediction::predIntraLumaDMM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder )
    437466{
     467#if HHI_DMM_WEDGE_INTRA
    438468  if( uiMode == DMM_WEDGE_FULL_IDX          ) { xPredIntraWedgeFull      ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgeFullTabIdx ( uiAbsPartIdx ) ); }
    439469  if( uiMode == DMM_WEDGE_FULL_D_IDX        ) { xPredIntraWedgeFull      ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true,  pcCU->getWedgeFullTabIdx( uiAbsPartIdx ), pcCU->getWedgeFullDeltaDC1( uiAbsPartIdx ), pcCU->getWedgeFullDeltaDC2( uiAbsPartIdx ) ); }
    440470  if( uiMode == DMM_WEDGE_PREDDIR_IDX     ) { xPredIntraWedgeDir       ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false, pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ) ); }
    441471  if( uiMode == DMM_WEDGE_PREDDIR_D_IDX   ) { xPredIntraWedgeDir       ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true,  pcCU->getWedgePredDirDeltaEnd( uiAbsPartIdx ), pcCU->getWedgePredDirDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredDirDeltaDC2( uiAbsPartIdx ) ); }
     472#endif
     473#if HHI_DMM_PRED_TEX
    442474  if( uiMode == DMM_WEDGE_PREDTEX_IDX       ) { xPredIntraWedgeTex       ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); }
    443475  if( uiMode == DMM_WEDGE_PREDTEX_D_IDX     ) { xPredIntraWedgeTex       ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getWedgePredTexDeltaDC1( uiAbsPartIdx ), pcCU->getWedgePredTexDeltaDC2( uiAbsPartIdx ) ); }
    444476  if( uiMode == DMM_CONTOUR_PREDTEX_IDX     ) { xPredIntraContourTex     ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, false ); }
    445477  if( uiMode == DMM_CONTOUR_PREDTEX_D_IDX   ) { xPredIntraContourTex     ( pcCU, uiAbsPartIdx, piPred, uiStride, iWidth, iHeight, bAbove, bLeft, bEncoder, true, pcCU->getContourPredTexDeltaDC1( uiAbsPartIdx ), pcCU->getContourPredTexDeltaDC2( uiAbsPartIdx ) ); }
    446   }
     478#endif
     479}
    447480
    448481Void TComPrediction::xDeltaDCQuantScaleUp( TComDataCU* pcCU, Int& riDeltaDC )
     
    459492}
    460493
    461 Void TComPrediction::xPredIntraWedgeFull( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1, Int iDeltaDC2 )
    462 {
    463   assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );
    464   WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];
    465   TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTabIdx));
    466 
    467   // get wedge pred DCs
    468   Int iPredDC1 = 0;
    469   Int iPredDC2 = 0;
    470 
    471   Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
    472   Int iMaskStride = ( iWidth<<1 ) + 1;
    473   piMask += iMaskStride+1;
    474   getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    475 
    476   if( bDelta )
    477   {
    478     xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
    479     xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    480   }
    481 
    482   // assign wedge pred DCs to prediction
    483   if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    484   else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1,           iPredDC2           ); }
    485 }
    486 
    487 Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft )
    488 {
    489   riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); //pred val, if no neighbors are available
    490   riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) );
    491 
    492   if( !bAbove && !bLeft ) { return; }
    493 
    494   UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0;
    495   Int iPredDC1 = 0, iPredDC2 = 0;
    496 
    497   Bool* pabWedgePattern = pcWedgelet->getPattern();
    498   UInt  uiWedgeStride   = pcWedgelet->getStride();
    499 
    500   if( bAbove )
    501   {
    502     for( Int k = 0; k < pcWedgelet->getWidth(); k++ )
    503     {
    504       if( true == pabWedgePattern[k] )
    505       {
    506         iPredDC2 += piMask[k-iMaskStride];
    507         uiNumSmpDC2++;
    508       }
    509       else
    510       {
    511         iPredDC1 += piMask[k-iMaskStride];
    512         uiNumSmpDC1++;
    513       }
    514     }
    515   }
    516   if( bLeft )
    517   {
    518     for( Int k = 0; k < pcWedgelet->getHeight(); k++ )
    519     {
    520       if( true == pabWedgePattern[k*uiWedgeStride] )
    521       {
    522         iPredDC2 += piMask[k*iMaskStride-1];
    523         uiNumSmpDC2++;
    524       }
    525       else
    526       {
    527         iPredDC1 += piMask[k*iMaskStride-1];
    528         uiNumSmpDC1++;
    529       }
    530     }
    531   }
    532 
    533   if( uiNumSmpDC1 > 0 )
    534   {
    535     iPredDC1 /= uiNumSmpDC1;
    536     riPredDC1 = iPredDC1;
    537   }
    538   if( uiNumSmpDC2 > 0 )
    539   {
    540     iPredDC2 /= uiNumSmpDC2;
    541     riPredDC2 = iPredDC2;
    542   }
    543 }
    544 
    545 Void TComPrediction::getBestContourFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge )
    546 {
    547   pcContourWedge->clear();
    548   Bool* pabContourPattern = pcContourWedge->getPattern();
    549 
    550   // get copy of according texture luma block
    551   UInt uiPartAddr = 0;
    552   Int  iBlockWidth, iBlockHeight;
    553 
    554   pcCU->getPartIndexAndSize( uiAbsPartIdx, uiPartAddr, iBlockWidth, iBlockHeight );
    555 
    556   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec();
    557   Int     iRefStride = pcPicYuvRef->getStride();
    558   Pel*    piRefY     = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr );
    559 
    560   TComYuv cTempYuv; cTempYuv.create( pcCU->getWidth(0), pcCU->getHeight(0) ); cTempYuv.clear();
    561   UInt uiTempStride = cTempYuv.getStride();
    562   Pel* piTempY      = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth );
    563 
    564   for ( Int y = 0; y < iBlockHeight; y++ )
    565   {
    566     ::memcpy(piTempY, piRefY, sizeof(Pel)*iBlockWidth);
    567     piTempY += uiTempStride;
    568     piRefY += iRefStride;
    569   }
    570   piTempY = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth );
    571 
    572   // find contour for texture luma block
    573   UInt iDC = 0;
    574   for( UInt k = 0; k < (iBlockWidth*iBlockHeight); k++ ) { iDC += piTempY[k]; }
    575   iDC /= (iBlockWidth*iBlockHeight);
    576 
    577   for( UInt k = 0; k < (iBlockWidth*iBlockHeight); k++ )
    578   {
    579     pabContourPattern[k] = (piTempY[k] > iDC) ? true : false;
    580   }
    581 
    582   cTempYuv.destroy();
    583 }
    584 
    585 UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd )
    586 {
    587   UInt uiThisBlockSize = uiWidth;
    588   assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE );
    589   WedgeList*    pacContDWedgeList    = &g_aacWedgeLists   [(g_aucConvertToBit[uiThisBlockSize])];
    590   WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])];
    591 
    592   UInt uiPredDirWedgeTabIdx = 0;
    593   TComDataCU* pcTempCU;
    594   UInt        uiTempPartIdx;
    595   // 1st: try continue above wedgelet
    596   pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
    597   if( pcTempCU )
    598   {
    599     UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx );
    600     if( DMM_WEDGE_FULL_IDX      == uhLumaIntraDir ||
    601         DMM_WEDGE_FULL_D_IDX    == uhLumaIntraDir ||
    602         DMM_WEDGE_PREDDIR_IDX   == uhLumaIntraDir ||
    603         DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir ||
    604         DMM_WEDGE_PREDTEX_IDX   == uhLumaIntraDir ||
    605         DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir    )
    606     {
    607       UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )];
    608       WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])];
    609 
    610       // get offset between current and reference block
    611       UInt uiOffsetX = 0;
    612       UInt uiOffsetY = 0;
    613       xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
    614 
    615       // get reference wedgelet
    616   UInt uiRefWedgeTabIdx = 0;
    617       switch( uhLumaIntraDir )
    618       {
    619       case( DMM_WEDGE_FULL_IDX      ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
    620       case( DMM_WEDGE_FULL_D_IDX    ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
    621       case( DMM_WEDGE_PREDDIR_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
    622       case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
    623       case( DMM_WEDGE_PREDTEX_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
    624       case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
    625       default: { assert( 0 ); return uiPredDirWedgeTabIdx; }
    626       }
    627       TComWedgelet* pcRefWedgelet;
    628       pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx ));
    629      
    630       // find reference wedgelet, if direction is suitable for continue wedge
    631       if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) )
    632       {
    633         UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    634         pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd );
    635         getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    636         return uiPredDirWedgeTabIdx;
    637       }
    638     }
    639   }
    640 
    641   // 2nd: try continue left wedglelet
    642   pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
    643   if( pcTempCU )
    644   {
    645   UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx );
    646   if( DMM_WEDGE_FULL_IDX          == uhLumaIntraDir ||
    647       DMM_WEDGE_FULL_D_IDX        == uhLumaIntraDir ||
    648         DMM_WEDGE_PREDDIR_IDX   == uhLumaIntraDir ||
    649         DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir ||
    650       DMM_WEDGE_PREDTEX_IDX       == uhLumaIntraDir ||
    651       DMM_WEDGE_PREDTEX_D_IDX     == uhLumaIntraDir    )
    652   {
    653       UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )];
    654       WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])];
    655 
    656       // get offset between current and reference block
    657       UInt uiOffsetX = 0;
    658       UInt uiOffsetY = 0;
    659       xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
    660 
    661       // get reference wedgelet
    662       UInt uiRefWedgeTabIdx = 0;
    663       switch( uhLumaIntraDir )
    664       {
    665       case( DMM_WEDGE_FULL_IDX      ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
    666       case( DMM_WEDGE_FULL_D_IDX    ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
    667       case( DMM_WEDGE_PREDDIR_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
    668       case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
    669       case( DMM_WEDGE_PREDTEX_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
    670       case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
    671       default: { assert( 0 ); return uiPredDirWedgeTabIdx; }
    672       }
    673       TComWedgelet* pcRefWedgelet;
    674       pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx ));
    675 
    676       // find reference wedgelet, if direction is suitable for continue wedge
    677       if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) )
    678       {
    679         UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    680         pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd );
    681         getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    682         return uiPredDirWedgeTabIdx;
    683       }
    684     }
    685   }
    686 
    687   // 3rd: (default) make wedglet from intra dir and max slope point
    688   Int iSlopeX = 0;
    689   Int iSlopeY = 0;
    690   UInt uiStartPosX = 0;
    691   UInt uiStartPosY = 0;
    692   if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) )
    693   {
    694     UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
    695     xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd );
    696     getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
    697     return uiPredDirWedgeTabIdx;
    698   }
    699 
    700   return uiPredDirWedgeTabIdx;
    701 }
    702 
    703 Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY )
    704 {
    705   ruiOffsetX = 0;
    706   ruiOffsetY = 0;
    707 
    708     // get offset between current and above/left block
    709     UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    710   UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
    711 
    712   UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart();
    713     UInt uiMaxDepthRefCU = 0;
    714     while( uiNumPartInRefCU > 1 )
    715     {
    716       uiNumPartInRefCU >>= 2;
    717       uiMaxDepthRefCU++;
    718     }
    719 
    720   UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1);
    721     UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2;
    722   UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts;
    723 
    724   UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
    725   UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
    726 
    727   if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); }
    728   if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); }
    729 }
    730 
    731 Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY )
    732 {
    733   riSlopeX     = 0;
    734   riSlopeY     = 0;
    735   ruiStartPosX = 0;
    736   ruiStartPosY = 0;
    737 
    738   // 1st step: get wedge start point (max. slope)
    739   Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt );
    740   Int iSourceStride = ( uiBlockSize<<1 ) + 1;
    741 
    742   UInt uiSlopeMaxAbove = 0;
    743   UInt uiPosSlopeMaxAbove = 0;
    744   for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ )
    745   {
    746     if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove )
    747     {
    748       uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] );
    749       uiPosSlopeMaxAbove = uiPosHor;
    750     }
    751   }
    752 
    753   UInt uiSlopeMaxLeft = 0;
    754   UInt uiPosSlopeMaxLeft = 0;
    755   for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ )
    756   {
    757     if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft )
    758     {
    759       uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] );
    760       uiPosSlopeMaxLeft = uiPosVer;
    761     }
    762   }
    763 
    764   if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 )
    765   {
    766     return false;
    767   }
    768 
    769   if( uiSlopeMaxAbove > uiSlopeMaxLeft )
    770   {
    771     ruiStartPosX = uiPosSlopeMaxAbove;
    772     ruiStartPosY = 0;
    773   }
    774   else
    775   {
    776     ruiStartPosX = 0;
    777     ruiStartPosY = uiPosSlopeMaxLeft;
    778   }
    779 
    780   // 2nd step: derive wedge direction
    781   Int angTable[9] = {0,2,5,9,13,17,21,26,32};
    782 
    783   Int uiPreds[2] = {-1, -1};
    784   Int uiPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds );
    785 
    786   UInt uiDirMode = 0;
    787   if( uiPredNum == 1 )
    788   {
    789     uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]];
    790   }
    791   else if( uiPredNum == 2 )
    792   {
    793     uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]];
    794   }
    795 
    796   if( uiDirMode == 0 )
    797   {
    798     return false;
    799   }
    800 
    801   Bool modeVer       = (uiDirMode < 18);
    802   Bool modeHor       = !modeVer;
    803   Int intraPredAngle = modeVer ? uiDirMode - 9 : modeHor ? uiDirMode - 25 : 0;
    804   Int absAng         = abs(intraPredAngle);
    805   Int signAng        = intraPredAngle < 0 ? -1 : 1;
    806   absAng             = angTable[absAng];
    807   intraPredAngle     = signAng * absAng;
    808 
    809   // 3rd step: set slope for direction
    810   if( modeHor )
    811     {
    812     if( intraPredAngle > 0 )
    813     {
    814       riSlopeX = -32;
    815       riSlopeY = intraPredAngle;
    816     }
    817     else
    818     {
    819       riSlopeX = 32;
    820       riSlopeY = -intraPredAngle;
    821     }
    822     }
    823   else if( modeVer )
    824   {
    825     if( intraPredAngle > 0 )
    826     {
    827       riSlopeX = intraPredAngle;
    828       riSlopeY = -32;
    829   }
    830   else
    831   {
    832       riSlopeX = -intraPredAngle;
    833       riSlopeY = 32;
    834     }
    835   }
    836 
    837     return true;
    838 }
    839 
    840 Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd )
    841 {
    842   ruhXs = 0;
    843   ruhYs = 0;
    844   ruhXe = 0;
    845   ruhYe = 0;
    846   UInt uiOri;
    847 
    848   // scaling of start pos and block size to wedge resolution
    849   UInt uiScaledStartPosX = 0;
    850   UInt uiScaledStartPosY = 0;
    851   UInt uiScaledBlockSize = 0;
    852   WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]];
    853   switch( eWedgeRes )
    854   {
    855   case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; }
    856   case(   FULL_PEL ): { uiScaledStartPosX =  uiPMSPosX;     uiScaledStartPosY =  uiPMSPosY;     uiScaledBlockSize =  uiBlockSize;     break; }
    857   case(   HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; }
    858 }
    859 
    860   // case above
    861   if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 )
    862   {
    863     ruhXs = (UChar)uiScaledStartPosX;
    864     ruhYs = 0;
    865 
    866     if( iDeltaY == 0 )
    867 {
    868       if( iDeltaX < 0 )
    869       {
    870         uiOri = 0;
    871         ruhXe = 0;
    872         ruhYe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
    873         return;
    874       }
    875       else
    876       {
    877         uiOri = 1;
    878         ruhXe = (UChar)(uiScaledBlockSize-1); ;
    879         ruhYe = (UChar)Min( Max( -iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
    880         std::swap( ruhXs, ruhXe );
    881         std::swap( ruhYs, ruhYe );
    882         return;
    883       }
    884     }
    885 
    886     // regular case
    887     Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaX / (Double)iDeltaY) );
    888 
    889     if( iVirtualEndX < 0 )
    890     {
    891       Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd;
    892       if( iYe < (Int)uiScaledBlockSize )
    893       {
    894         uiOri = 0;
    895         ruhXe = 0;
    896         ruhYe = (UChar)Max( iYe, 0 );
    897         return;
    898       }
    899       else
    900       {
    901         uiOri = 4;
    902         ruhXe = (UChar)Min( (iYe - (uiScaledBlockSize-1)), (uiScaledBlockSize-1) );
    903         ruhYe = (UChar)(uiScaledBlockSize-1);
    904         return;
    905       }
    906     }
    907     else if( iVirtualEndX > (uiScaledBlockSize-1) )
    908     {
    909       Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
    910       if( iYe < (Int)uiScaledBlockSize )
    911       {
    912         uiOri = 1;
    913         ruhXe = (UChar)(uiScaledBlockSize-1);
    914         ruhYe = (UChar)Max( iYe, 0 );
    915         std::swap( ruhXs, ruhXe );
    916         std::swap( ruhYs, ruhYe );
    917         return;
    918       }
    919       else
    920       {
    921         uiOri = 4;
    922         ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 );
    923         ruhYe = (UChar)(uiScaledBlockSize-1);
    924         return;
    925       }
    926     }
    927     else
    928     {
    929       Int iXe = iVirtualEndX + iDeltaEnd;
    930       if( iXe < 0 )
    931       {
    932         uiOri = 0;
    933         ruhXe = 0;
    934         ruhYe = (UChar)Max( ((uiScaledBlockSize-1) + iXe), 0 );
    935         return;
    936       }
    937       else if( iXe > (uiScaledBlockSize-1) )
    938       {
    939         uiOri = 1;
    940         ruhXe = (UChar)(uiScaledBlockSize-1);
    941         ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 );
    942         std::swap( ruhXs, ruhXe );
    943         std::swap( ruhYs, ruhYe );
    944         return;
    945       }
    946       else
    947       {
    948         uiOri = 4;
    949         ruhXe = (UChar)iXe;
    950         ruhYe = (UChar)(uiScaledBlockSize-1);
    951         return;
    952       }
    953     }
    954   }
    955 
    956   // case left
    957   if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 )
    958   {
    959     ruhXs = 0;
    960     ruhYs = (UChar)uiScaledStartPosY;
    961 
    962     if( iDeltaX == 0 )
    963     {
    964       if( iDeltaY < 0 )
    965       {
    966         uiOri = 0;
    967         ruhXe = (UChar)Min( Max( -iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
    968         ruhYe = 0;
    969         std::swap( ruhXs, ruhXe );
    970         std::swap( ruhYs, ruhYe );
    971         return;
    972       }
    973       else
    974       {
    975         uiOri = 3;
    976         ruhXe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
    977         ruhYe = (UChar)(uiScaledBlockSize-1);
    978         return;
    979       }
    980     }
    981 
    982     // regular case
    983     Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaY / (Double)iDeltaX) );
    984 
    985     if( iVirtualEndY < 0 )
    986     {
    987       Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd;
    988       if( iXe < (Int)uiScaledBlockSize )
    989       {
    990         uiOri = 0;
    991         ruhXe = (UChar)Max( iXe, 0 );
    992         ruhYe = 0;
    993         std::swap( ruhXs, ruhXe );
    994         std::swap( ruhYs, ruhYe );
    995         return;
    996       }
    997       else
    998       {
    999         uiOri = 5;
    1000         ruhXe = (UChar)(uiScaledBlockSize-1);
    1001         ruhYe = (UChar)Min( (iXe - (uiScaledBlockSize-1)), (uiScaledBlockSize-1) );
    1002         std::swap( ruhXs, ruhXe );
    1003         std::swap( ruhYs, ruhYe );
    1004         return;
    1005       }
    1006     }
    1007     else if( iVirtualEndY > (uiScaledBlockSize-1) )
    1008     {
    1009       Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd;
    1010       if( iXe < (Int)uiScaledBlockSize )
    1011       {
    1012         uiOri = 3;
    1013         ruhXe = (UChar)Max( iXe, 0 );
    1014         ruhYe = (UChar)(uiScaledBlockSize-1);
    1015         return;
    1016       }
    1017       else
    1018       {
    1019         uiOri = 5;
    1020         ruhXe = (UChar)(uiScaledBlockSize-1);
    1021         ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 );
    1022         std::swap( ruhXs, ruhXe );
    1023         std::swap( ruhYs, ruhYe );
    1024         return;
    1025       }
    1026     }
    1027     else
    1028     {
    1029       Int iYe = iVirtualEndY - iDeltaEnd;
    1030       if( iYe < 0 )
    1031       {
    1032         uiOri = 0;
    1033         ruhXe = (UChar)Max( ((uiScaledBlockSize-1) + iYe), 0 );
    1034         ruhYe = 0;
    1035         std::swap( ruhXs, ruhXe );
    1036         std::swap( ruhYs, ruhYe );
    1037         return;
    1038       }
    1039       else if( iYe > (uiScaledBlockSize-1) )
    1040       {
    1041         uiOri = 3;
    1042         ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 );
    1043         ruhYe = (UChar)(uiScaledBlockSize-1);
    1044         return;
    1045       }
    1046       else
    1047       {
    1048         uiOri = 5;
    1049         ruhXe = (UChar)(uiScaledBlockSize-1);
    1050         ruhYe = (UChar)iYe;
    1051         std::swap( ruhXs, ruhXe );
    1052         std::swap( ruhYs, ruhYe );
    1053         return;
    1054       }
    1055     }
    1056   }
    1057 
    1058   // case origin
    1059   if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 )
    1060   {
    1061     if( iDeltaX*iDeltaY < 0 )
    1062     {
    1063       return;
    1064     }
    1065 
    1066     ruhXs = 0;
    1067     ruhYs = 0;
    1068 
    1069     if( iDeltaY == 0 )
    1070     {
    1071       uiOri = 1;
    1072       ruhXe = (UChar)(uiScaledBlockSize-1);
    1073       ruhYe = 0;
    1074       std::swap( ruhXs, ruhXe );
    1075       std::swap( ruhYs, ruhYe );
    1076       return;
    1077   }
    1078 
    1079     if( iDeltaX == 0 )
    1080     {
    1081       uiOri = 0;
    1082       ruhXe = 0;
    1083       ruhYe = (UChar)(uiScaledBlockSize-1);
    1084       return;
    1085   }
    1086 
    1087     Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaX / (Double)iDeltaY) );
    1088 
    1089     if( iVirtualEndX > (uiScaledBlockSize-1) )
    1090     {
    1091       Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
    1092       if( iYe < (Int)uiScaledBlockSize )
    1093       {
    1094         uiOri = 1;
    1095         ruhXe = (UChar)(uiScaledBlockSize-1);
    1096         ruhYe = (UChar)Max( iYe, 0 );
    1097         std::swap( ruhXs, ruhXe );
    1098         std::swap( ruhYs, ruhYe );
    1099         return;
    1100       }
    1101       else
    1102       {
    1103         uiOri = 3;
    1104         ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 );
    1105         ruhYe = (UChar)(uiScaledBlockSize-1);
    1106         return;
    1107       }
    1108     }
    1109     else
    1110     {
    1111       Int iXe = iVirtualEndX + iDeltaEnd;
    1112       if( iXe < 0 )
    1113       {
    1114         uiOri = 0;
    1115         ruhXe = 0;
    1116         ruhYe = (UChar)Max( ((uiScaledBlockSize-1) + iXe), 0 );
    1117         return;
    1118       }
    1119       else if( iXe > (uiScaledBlockSize-1) )
    1120       {
    1121         uiOri = 1;
    1122         ruhXe = (UChar)(uiScaledBlockSize-1);
    1123         ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 );
    1124         std::swap( ruhXs, ruhXe );
    1125         std::swap( ruhYs, ruhYe );
    1126         return;
    1127       }
    1128       else
    1129       {
    1130         uiOri = 3;
    1131         ruhXe = (UChar)iXe;
    1132         ruhYe = (UChar)(uiScaledBlockSize-1);
    1133         return;
    1134       }
    1135     }
    1136   }
    1137 }
    1138 
    1139 Bool TComPrediction::getWedgeListIdx( WedgeList* pcWedgeList, WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe )
    1140       {
    1141   ruiTabIdx = 0;
    1142 
    1143   for( UInt uiIdx = 0; uiIdx < pcWedgeList->size(); uiIdx++ )
    1144       {
    1145     TComWedgelet* pcTestWedge = &(pcWedgeList->at(uiIdx));
    1146 
    1147     if( pcTestWedge->getStartX() == uhXs &&
    1148         pcTestWedge->getStartY() == uhYs &&
    1149         pcTestWedge->getEndX()   == uhXe &&
    1150         pcTestWedge->getEndY()   == uhYe    )
    1151         {
    1152       ruiTabIdx = uiIdx;
    1153       return true;
    1154         }
    1155       }
    1156 
    1157   // additionally search in WedgeRef lists of duplicated patterns
    1158   for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ )
    1159         {
    1160     TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx));
    1161 
    1162     if( pcTestWedgeRef->getStartX() == uhXs &&
    1163         pcTestWedgeRef->getStartY() == uhYs &&
    1164         pcTestWedgeRef->getEndX()   == uhXe &&
    1165         pcTestWedgeRef->getEndY()   == uhYe    )
    1166           {
    1167       ruiTabIdx = pcTestWedgeRef->getRefIdx();
    1168       return true;
    1169     }
    1170   }
    1171 
    1172   return false;
    1173 }
    1174 
    1175 Void TComPrediction::xPredIntraWedgeDir( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iWedgeDeltaEnd, Int iDeltaDC1, Int iDeltaDC2 )
    1176 {
    1177   assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );
    1178   WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];
    1179 
    1180   // get wedge pattern
    1181   UInt uiDirWedgeTabIdx = 0;
    1182   if( bEncoder )
    1183   {
    1184     // encoder: load stored wedge pattern from CU
    1185     uiDirWedgeTabIdx = pcCU->getWedgePredDirTabIdx( uiAbsPartIdx );
    1186   }
    1187   else
    1188   {
    1189     uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd );
    1190 
    1191     UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1);
    1192     pcCU->setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth );
    1193   }
    1194   TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiDirWedgeTabIdx));
    1195 
    1196   // get wedge pred DCs
    1197   Int iPredDC1 = 0;
    1198   Int iPredDC2 = 0;
    1199 
    1200   Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
    1201   Int iMaskStride = ( iWidth<<1 ) + 1;
    1202   piMask += iMaskStride+1;
    1203   getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    1204 
    1205   if( bDelta )
    1206   {
    1207     xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
    1208     xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    1209   }
    1210 
    1211   // assign wedge pred DCs to prediction
    1212   if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    1213   else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride,        iPredDC1,                   iPredDC2             ); }
    1214 }
    1215 
    1216 Void TComPrediction::xPredIntraWedgeTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 )
    1217 {
    1218   assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );
    1219   WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];
    1220 
    1221   // get wedge pattern
    1222   UInt uiTextureWedgeTabIdx = 0;
    1223   if( bEncoder )
    1224   {
    1225      // encoder: load stored wedge pattern from CU
    1226     uiTextureWedgeTabIdx = pcCU->getWedgePredTexTabIdx( uiAbsPartIdx );
    1227   }
    1228   else
    1229   {
    1230     // decoder: get and store wedge pattern in CU
    1231     uiTextureWedgeTabIdx = getBestWedgeFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight );
    1232     UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1);
    1233     pcCU->setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth );
    1234   }
    1235   TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTextureWedgeTabIdx));
    1236 
    1237   // get wedge pred DCs
    1238   Int iPredDC1 = 0;
    1239   Int iPredDC2 = 0;
    1240   Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
    1241   Int iMaskStride = ( iWidth<<1 ) + 1;
    1242   piMask += iMaskStride+1;
    1243   getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    1244 
    1245   if( bDelta )
    1246   {
    1247     xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
    1248     xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    1249   }
    1250 
    1251   // assign wedge pred DCs to prediction
    1252   if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    1253   else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride,        iPredDC1,                   iPredDC2           ); }
    1254 }
    1255 
    1256 Void TComPrediction::xPredIntraContourTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 )
    1257 {
    1258   // get contour pattern
    1259   TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight );
    1260   getBestContourFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge );
    1261 
    1262   // get wedge pred DCs
    1263   Int iPredDC1 = 0;
    1264   Int iPredDC2 = 0;
    1265   Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
    1266   Int iMaskStride = ( iWidth<<1 ) + 1;
    1267   piMask += iMaskStride+1;
    1268   getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
    1269 
    1270   if( bDelta )
    1271   {
    1272     xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
    1273     xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
    1274   }
    1275 
    1276   // assign wedge pred DCs to prediction
    1277   if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
    1278   else         { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride,        iPredDC1,                   iPredDC2           ); }
    1279 
    1280   pcContourWedge->destroy();
    1281   delete pcContourWedge;
    1282 }
    1283 #endif
    1284 #if HHI_DMM_INTRA
    1285494Void TComPrediction::calcWedgeDCs( TComWedgelet* pcWedgelet, Pel* piOrig, UInt uiStride, Int& riDC1, Int& riDC2 )
    1286495{
     
    1367576        }
    1368577        else
    1369         {
     578  {
    1370579          piTemp[uiX] = iDC1;
    1371580        }
     
    1377586}
    1378587
    1379 UInt TComPrediction::getBestWedgeFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, WedgeDist eWedgeDist )
     588Void TComPrediction::getWedgePredDCs( TComWedgelet* pcWedgelet, Int* piMask, Int iMaskStride, Int& riPredDC1, Int& riPredDC2, Bool bAbove, Bool bLeft )
     589{
     590  riPredDC1 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); //pred val, if no neighbors are available
     591  riPredDC2 = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) );
     592
     593  if( !bAbove && !bLeft ) { return; }
     594
     595  UInt uiNumSmpDC1 = 0, uiNumSmpDC2 = 0;
     596  Int iPredDC1 = 0, iPredDC2 = 0;
     597
     598  Bool* pabWedgePattern = pcWedgelet->getPattern();
     599  UInt  uiWedgeStride   = pcWedgelet->getStride();
     600
     601  if( bAbove )
     602  {
     603    for( Int k = 0; k < pcWedgelet->getWidth(); k++ )
     604    {
     605      if( true == pabWedgePattern[k] )
     606      {
     607        iPredDC2 += piMask[k-iMaskStride];
     608        uiNumSmpDC2++;
     609      }
     610      else
     611      {
     612        iPredDC1 += piMask[k-iMaskStride];
     613        uiNumSmpDC1++;
     614      }
     615    }
     616  }
     617  if( bLeft )
     618  {
     619    for( Int k = 0; k < pcWedgelet->getHeight(); k++ )
     620    {
     621      if( true == pabWedgePattern[k*uiWedgeStride] )
     622      {
     623        iPredDC2 += piMask[k*iMaskStride-1];
     624        uiNumSmpDC2++;
     625      }
     626      else
     627      {
     628        iPredDC1 += piMask[k*iMaskStride-1];
     629        uiNumSmpDC1++;
     630      }
     631    }
     632  }
     633
     634  if( uiNumSmpDC1 > 0 )
     635  {
     636    iPredDC1 /= uiNumSmpDC1;
     637    riPredDC1 = iPredDC1;
     638  }
     639  if( uiNumSmpDC2 > 0 )
     640  {
     641    iPredDC2 /= uiNumSmpDC2;
     642    riPredDC2 = iPredDC2;
     643  }
     644}
     645#endif
     646
     647#if HHI_DMM_WEDGE_INTRA
     648Void TComPrediction::xPredIntraWedgeFull( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, UInt uiTabIdx, Int iDeltaDC1, Int iDeltaDC2 )
     649{
     650  assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );
     651  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];
     652  TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTabIdx));
     653
     654  // get wedge pred DCs
     655  Int iPredDC1 = 0;
     656  Int iPredDC2 = 0;
     657
     658  Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
     659  Int iMaskStride = ( iWidth<<1 ) + 1;
     660  piMask += iMaskStride+1;
     661  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     662
     663  if( bDelta )
     664  {
     665    xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
     666    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
     667  }
     668
     669  // assign wedge pred DCs to prediction
     670  if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
     671  else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, iPredDC1,           iPredDC2           ); }
     672}
     673
     674UInt TComPrediction::getBestContinueWedge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Int iDeltaEnd )
     675{
     676  UInt uiThisBlockSize = uiWidth;
     677  assert( uiThisBlockSize >= DMM_WEDGEMODEL_MIN_SIZE && uiThisBlockSize <= DMM_WEDGEMODEL_MAX_SIZE );
     678  WedgeList*    pacContDWedgeList    = &g_aacWedgeLists   [(g_aucConvertToBit[uiThisBlockSize])];
     679  WedgeRefList* pacContDWedgeRefList = &g_aacWedgeRefLists[(g_aucConvertToBit[uiThisBlockSize])];
     680
     681  UInt uiPredDirWedgeTabIdx = 0;
     682  TComDataCU* pcTempCU;
     683  UInt        uiTempPartIdx;
     684  // 1st: try continue above wedgelet
     685  pcTempCU = pcCU->getPUAbove( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
     686  if( pcTempCU )
     687  {
     688    UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx );
     689    if( DMM_WEDGE_FULL_IDX      == uhLumaIntraDir ||
     690        DMM_WEDGE_FULL_D_IDX    == uhLumaIntraDir ||
     691        DMM_WEDGE_PREDDIR_IDX   == uhLumaIntraDir ||
     692        DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir
     693#if HHI_DMM_PRED_TEX
     694                                                  ||
     695        DMM_WEDGE_PREDTEX_IDX   == uhLumaIntraDir ||
     696        DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir   
     697#endif
     698       )
     699    {
     700      UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )];
     701      WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])];
     702
     703      // get offset between current and reference block
     704      UInt uiOffsetX = 0;
     705      UInt uiOffsetY = 0;
     706      xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
     707
     708      // get reference wedgelet
     709  UInt uiRefWedgeTabIdx = 0;
     710      switch( uhLumaIntraDir )
     711      {
     712      case( DMM_WEDGE_FULL_IDX      ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
     713      case( DMM_WEDGE_FULL_D_IDX    ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
     714      case( DMM_WEDGE_PREDDIR_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
     715      case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
     716#if HHI_DMM_PRED_TEX
     717      case( DMM_WEDGE_PREDTEX_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
     718      case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
     719#endif
     720      default: { assert( 0 ); return uiPredDirWedgeTabIdx; }
     721      }
     722      TComWedgelet* pcRefWedgelet;
     723      pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx ));
     724     
     725      // find reference wedgelet, if direction is suitable for continue wedge
     726      if( pcRefWedgelet->checkPredDirAbovePossible( uiThisBlockSize, uiOffsetX ) )
     727      {
     728        UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
     729        pcRefWedgelet->getPredDirStartEndAbove( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetX, iDeltaEnd );
     730        getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
     731        return uiPredDirWedgeTabIdx;
     732      }
     733    }
     734  }
     735
     736  // 2nd: try continue left wedglelet
     737  pcTempCU = pcCU->getPULeft( uiTempPartIdx, pcCU->getZorderIdxInCU() + uiAbsPartIdx );
     738  if( pcTempCU )
     739  {
     740    UChar uhLumaIntraDir = pcTempCU->getLumaIntraDir( uiTempPartIdx );
     741    if( DMM_WEDGE_FULL_IDX      == uhLumaIntraDir ||
     742        DMM_WEDGE_FULL_D_IDX    == uhLumaIntraDir ||
     743        DMM_WEDGE_PREDDIR_IDX   == uhLumaIntraDir ||
     744        DMM_WEDGE_PREDDIR_D_IDX == uhLumaIntraDir
     745#if HHI_DMM_PRED_TEX
     746                                                  ||
     747        DMM_WEDGE_PREDTEX_IDX   == uhLumaIntraDir ||
     748        DMM_WEDGE_PREDTEX_D_IDX == uhLumaIntraDir   
     749#endif
     750      )
     751    {
     752      UInt uiRefWedgeSize = (UInt)g_aucIntraSizeIdxToWedgeSize[pcTempCU->getIntraSizeIdx( uiTempPartIdx )];
     753      WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiRefWedgeSize])];
     754
     755      // get offset between current and reference block
     756      UInt uiOffsetX = 0;
     757      UInt uiOffsetY = 0;
     758      xGetBlockOffset( pcCU, uiAbsPartIdx, pcTempCU, uiTempPartIdx, uiOffsetX, uiOffsetY );
     759
     760      // get reference wedgelet
     761      UInt uiRefWedgeTabIdx = 0;
     762      switch( uhLumaIntraDir )
     763      {
     764      case( DMM_WEDGE_FULL_IDX      ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
     765      case( DMM_WEDGE_FULL_D_IDX    ): { uiRefWedgeTabIdx = pcTempCU->getWedgeFullTabIdx   ( uiTempPartIdx ); } break;
     766      case( DMM_WEDGE_PREDDIR_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
     767      case( DMM_WEDGE_PREDDIR_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredDirTabIdx( uiTempPartIdx ); } break;
     768#if HHI_DMM_PRED_TEX
     769      case( DMM_WEDGE_PREDTEX_IDX   ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
     770      case( DMM_WEDGE_PREDTEX_D_IDX ): { uiRefWedgeTabIdx = pcTempCU->getWedgePredTexTabIdx( uiTempPartIdx ); } break;
     771#endif
     772      default: { assert( 0 ); return uiPredDirWedgeTabIdx; }
     773      }
     774      TComWedgelet* pcRefWedgelet;
     775      pcRefWedgelet = &(pacWedgeList->at( uiRefWedgeTabIdx ));
     776
     777      // find reference wedgelet, if direction is suitable for continue wedge
     778      if( pcRefWedgelet->checkPredDirLeftPossible( uiThisBlockSize, uiOffsetY ) )
     779      {
     780        UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
     781        pcRefWedgelet->getPredDirStartEndLeft( uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, uiThisBlockSize, uiOffsetY, iDeltaEnd );
     782        getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
     783        return uiPredDirWedgeTabIdx;
     784      }
     785    }
     786  }
     787
     788  // 3rd: (default) make wedglet from intra dir and max slope point
     789  Int iSlopeX = 0;
     790  Int iSlopeY = 0;
     791  UInt uiStartPosX = 0;
     792  UInt uiStartPosY = 0;
     793  if( xGetWedgeIntraDirPredData( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY ) )
     794  {
     795    UChar uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye;
     796    xGetWedgeIntraDirStartEnd( pcCU, uiAbsPartIdx, uiThisBlockSize, iSlopeX, iSlopeY, uiStartPosX, uiStartPosY, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye, iDeltaEnd );
     797    getWedgeListIdx( pacContDWedgeList, pacContDWedgeRefList, uiPredDirWedgeTabIdx, uhContD_Xs, uhContD_Ys, uhContD_Xe, uhContD_Ye );
     798    return uiPredDirWedgeTabIdx;
     799  }
     800
     801  return uiPredDirWedgeTabIdx;
     802}
     803
     804Void TComPrediction::xGetBlockOffset( TComDataCU* pcCU, UInt uiAbsPartIdx, TComDataCU* pcRefCU, UInt uiRefAbsPartIdx, UInt& ruiOffsetX, UInt& ruiOffsetY )
     805{
     806  ruiOffsetX = 0;
     807  ruiOffsetY = 0;
     808
     809  // get offset between current and above/left block
     810  UInt uiThisOriginX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
     811  UInt uiThisOriginY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
     812
     813  UInt uiNumPartInRefCU = pcRefCU->getTotalNumPart();
     814  UInt uiMaxDepthRefCU = 0;
     815  while( uiNumPartInRefCU > 1 )
     816  {
     817    uiNumPartInRefCU >>= 2;
     818    uiMaxDepthRefCU++;
     819  }
     820
     821  UInt uiDepthRefPU = (pcRefCU->getDepth(uiRefAbsPartIdx)) + (pcRefCU->getPartitionSize(uiRefAbsPartIdx) == SIZE_2Nx2N ? 0 : 1);
     822  UInt uiShifts = (uiMaxDepthRefCU - uiDepthRefPU)*2;
     823  UInt uiRefBlockOriginPartIdx = (uiRefAbsPartIdx>>uiShifts)<<uiShifts;
     824
     825  UInt uiRefOriginX = pcRefCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
     826  UInt uiRefOriginY = pcRefCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiRefBlockOriginPartIdx] ];
     827
     828  if( (uiThisOriginX - uiRefOriginX) > 0 ) { ruiOffsetX = (UInt)(uiThisOriginX - uiRefOriginX); }
     829  if( (uiThisOriginY - uiRefOriginY) > 0 ) { ruiOffsetY = (UInt)(uiThisOriginY - uiRefOriginY); }
     830}
     831
     832Bool TComPrediction::xGetWedgeIntraDirPredData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int& riSlopeX, Int& riSlopeY, UInt& ruiStartPosX, UInt& ruiStartPosY )
     833{
     834  riSlopeX     = 0;
     835  riSlopeY     = 0;
     836  ruiStartPosX = 0;
     837  ruiStartPosY = 0;
     838
     839  // 1st step: get wedge start point (max. slope)
     840  Int* piSource = pcCU->getPattern()->getAdiOrgBuf( uiBlockSize, uiBlockSize, m_piYuvExt );
     841  Int iSourceStride = ( uiBlockSize<<1 ) + 1;
     842
     843  UInt uiSlopeMaxAbove = 0;
     844  UInt uiPosSlopeMaxAbove = 0;
     845  for( UInt uiPosHor = 0; uiPosHor < (uiBlockSize-1); uiPosHor++ )
     846  {
     847    if( abs( piSource[uiPosHor+1] - piSource[uiPosHor] ) > uiSlopeMaxAbove )
     848    {
     849      uiSlopeMaxAbove = abs( piSource[uiPosHor+1] - piSource[uiPosHor] );
     850      uiPosSlopeMaxAbove = uiPosHor;
     851    }
     852  }
     853
     854  UInt uiSlopeMaxLeft = 0;
     855  UInt uiPosSlopeMaxLeft = 0;
     856  for( UInt uiPosVer = 0; uiPosVer < (uiBlockSize-1); uiPosVer++ )
     857  {
     858    if( abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] ) > uiSlopeMaxLeft )
     859    {
     860      uiSlopeMaxLeft = abs( piSource[(uiPosVer+1)*iSourceStride] - piSource[uiPosVer*iSourceStride] );
     861      uiPosSlopeMaxLeft = uiPosVer;
     862    }
     863  }
     864
     865  if( uiSlopeMaxAbove == 0 && uiSlopeMaxLeft == 0 )
     866  {
     867    return false;
     868  }
     869
     870  if( uiSlopeMaxAbove > uiSlopeMaxLeft )
     871  {
     872    ruiStartPosX = uiPosSlopeMaxAbove;
     873    ruiStartPosY = 0;
     874  }
     875  else
     876  {
     877    ruiStartPosX = 0;
     878    ruiStartPosY = uiPosSlopeMaxLeft;
     879  }
     880
     881  // 2nd step: derive wedge direction
     882  Int angTable[9] = {0,2,5,9,13,17,21,26,32};
     883
     884  Int uiPreds[2] = {-1, -1};
     885  Int uiPredNum = pcCU->getIntraDirLumaPredictor( uiAbsPartIdx, uiPreds );
     886
     887  UInt uiDirMode = 0;
     888  if( uiPredNum == 1 )
     889  {
     890    uiDirMode = g_aucAngIntraModeOrder[uiPreds[0]];
     891  }
     892  else if( uiPredNum == 2 )
     893  {
     894    uiDirMode = g_aucAngIntraModeOrder[uiPreds[1]];
     895  }
     896
     897  if( uiDirMode == 0 )
     898  {
     899    return false;
     900  }
     901
     902  Bool modeVer       = (uiDirMode < 18);
     903  Bool modeHor       = !modeVer;
     904  Int intraPredAngle = modeVer ? uiDirMode - 9 : modeHor ? uiDirMode - 25 : 0;
     905  Int absAng         = abs(intraPredAngle);
     906  Int signAng        = intraPredAngle < 0 ? -1 : 1;
     907  absAng             = angTable[absAng];
     908  intraPredAngle     = signAng * absAng;
     909
     910  // 3rd step: set slope for direction
     911  if( modeHor )
     912    {
     913    if( intraPredAngle > 0 )
     914    {
     915      riSlopeX = -32;
     916      riSlopeY = intraPredAngle;
     917    }
     918    else
     919    {
     920      riSlopeX = 32;
     921      riSlopeY = -intraPredAngle;
     922    }
     923    }
     924  else if( modeVer )
     925  {
     926    if( intraPredAngle > 0 )
     927    {
     928      riSlopeX = intraPredAngle;
     929      riSlopeY = -32;
     930  }
     931  else
     932  {
     933      riSlopeX = -intraPredAngle;
     934      riSlopeY = 32;
     935    }
     936  }
     937
     938    return true;
     939}
     940
     941Void TComPrediction::xGetWedgeIntraDirStartEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiBlockSize, Int iDeltaX, Int iDeltaY, UInt uiPMSPosX, UInt uiPMSPosY, UChar& ruhXs, UChar& ruhYs, UChar& ruhXe, UChar& ruhYe, Int iDeltaEnd )
     942{
     943  ruhXs = 0;
     944  ruhYs = 0;
     945  ruhXe = 0;
     946  ruhYe = 0;
     947  UInt uiOri;
     948
     949  // scaling of start pos and block size to wedge resolution
     950  UInt uiScaledStartPosX = 0;
     951  UInt uiScaledStartPosY = 0;
     952  UInt uiScaledBlockSize = 0;
     953  WedgeResolution eWedgeRes = g_aeWedgeResolutionList[(UInt)g_aucConvertToBit[uiBlockSize]];
     954  switch( eWedgeRes )
     955  {
     956  case( DOUBLE_PEL ): { uiScaledStartPosX = (uiPMSPosX>>1); uiScaledStartPosY = (uiPMSPosY>>1); uiScaledBlockSize = (uiBlockSize>>1); break; }
     957  case(   FULL_PEL ): { uiScaledStartPosX =  uiPMSPosX;     uiScaledStartPosY =  uiPMSPosY;     uiScaledBlockSize =  uiBlockSize;     break; }
     958  case(   HALF_PEL ): { uiScaledStartPosX = (uiPMSPosX<<1); uiScaledStartPosY = (uiPMSPosY<<1); uiScaledBlockSize = (uiBlockSize<<1); break; }
     959}
     960
     961  // case above
     962  if( uiScaledStartPosX > 0 && uiScaledStartPosY == 0 )
     963  {
     964    ruhXs = (UChar)uiScaledStartPosX;
     965    ruhYs = 0;
     966
     967    if( iDeltaY == 0 )
     968{
     969      if( iDeltaX < 0 )
     970      {
     971        uiOri = 0;
     972        ruhXe = 0;
     973        ruhYe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
     974        return;
     975      }
     976      else
     977      {
     978        uiOri = 1;
     979        ruhXe = (UChar)(uiScaledBlockSize-1); ;
     980        ruhYe = (UChar)Min( Max( -iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
     981        std::swap( ruhXs, ruhXe );
     982        std::swap( ruhYs, ruhYe );
     983        return;
     984      }
     985    }
     986
     987    // regular case
     988    Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaX / (Double)iDeltaY) );
     989
     990    if( iVirtualEndX < 0 )
     991    {
     992      Int iYe = roftoi( (Double)(0 - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) + iDeltaEnd;
     993      if( iYe < (Int)uiScaledBlockSize )
     994      {
     995        uiOri = 0;
     996        ruhXe = 0;
     997        ruhYe = (UChar)Max( iYe, 0 );
     998        return;
     999      }
     1000      else
     1001      {
     1002        uiOri = 4;
     1003        ruhXe = (UChar)Min( (iYe - (uiScaledBlockSize-1)), (uiScaledBlockSize-1) );
     1004        ruhYe = (UChar)(uiScaledBlockSize-1);
     1005        return;
     1006      }
     1007    }
     1008    else if( iVirtualEndX > (uiScaledBlockSize-1) )
     1009    {
     1010      Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
     1011      if( iYe < (Int)uiScaledBlockSize )
     1012      {
     1013        uiOri = 1;
     1014        ruhXe = (UChar)(uiScaledBlockSize-1);
     1015        ruhYe = (UChar)Max( iYe, 0 );
     1016        std::swap( ruhXs, ruhXe );
     1017        std::swap( ruhYs, ruhYe );
     1018        return;
     1019      }
     1020      else
     1021      {
     1022        uiOri = 4;
     1023        ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 );
     1024        ruhYe = (UChar)(uiScaledBlockSize-1);
     1025        return;
     1026      }
     1027    }
     1028    else
     1029    {
     1030      Int iXe = iVirtualEndX + iDeltaEnd;
     1031      if( iXe < 0 )
     1032      {
     1033        uiOri = 0;
     1034        ruhXe = 0;
     1035        ruhYe = (UChar)Max( ((uiScaledBlockSize-1) + iXe), 0 );
     1036        return;
     1037      }
     1038      else if( iXe > (uiScaledBlockSize-1) )
     1039      {
     1040        uiOri = 1;
     1041        ruhXe = (UChar)(uiScaledBlockSize-1);
     1042        ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 );
     1043        std::swap( ruhXs, ruhXe );
     1044        std::swap( ruhYs, ruhYe );
     1045        return;
     1046      }
     1047      else
     1048      {
     1049        uiOri = 4;
     1050        ruhXe = (UChar)iXe;
     1051        ruhYe = (UChar)(uiScaledBlockSize-1);
     1052        return;
     1053      }
     1054    }
     1055  }
     1056
     1057  // case left
     1058  if( uiScaledStartPosY > 0 && uiScaledStartPosX == 0 )
     1059  {
     1060    ruhXs = 0;
     1061    ruhYs = (UChar)uiScaledStartPosY;
     1062
     1063    if( iDeltaX == 0 )
     1064    {
     1065      if( iDeltaY < 0 )
     1066      {
     1067        uiOri = 0;
     1068        ruhXe = (UChar)Min( Max( -iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
     1069        ruhYe = 0;
     1070        std::swap( ruhXs, ruhXe );
     1071        std::swap( ruhYs, ruhYe );
     1072        return;
     1073      }
     1074      else
     1075      {
     1076        uiOri = 3;
     1077        ruhXe = (UChar)Min( Max( iDeltaEnd, 0 ), (uiScaledBlockSize-1) );
     1078        ruhYe = (UChar)(uiScaledBlockSize-1);
     1079        return;
     1080      }
     1081    }
     1082
     1083    // regular case
     1084    Int iVirtualEndY = (Int)ruhYs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaY / (Double)iDeltaX) );
     1085
     1086    if( iVirtualEndY < 0 )
     1087    {
     1088      Int iXe = roftoi( (Double)(0 - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) - iDeltaEnd;
     1089      if( iXe < (Int)uiScaledBlockSize )
     1090      {
     1091        uiOri = 0;
     1092        ruhXe = (UChar)Max( iXe, 0 );
     1093        ruhYe = 0;
     1094        std::swap( ruhXs, ruhXe );
     1095        std::swap( ruhYs, ruhYe );
     1096        return;
     1097      }
     1098      else
     1099      {
     1100        uiOri = 5;
     1101        ruhXe = (UChar)(uiScaledBlockSize-1);
     1102        ruhYe = (UChar)Min( (iXe - (uiScaledBlockSize-1)), (uiScaledBlockSize-1) );
     1103        std::swap( ruhXs, ruhXe );
     1104        std::swap( ruhYs, ruhYe );
     1105        return;
     1106      }
     1107    }
     1108    else if( iVirtualEndY > (uiScaledBlockSize-1) )
     1109    {
     1110      Int iXe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhYs ) * ((Double)iDeltaX / (Double)iDeltaY) ) + iDeltaEnd;
     1111      if( iXe < (Int)uiScaledBlockSize )
     1112      {
     1113        uiOri = 3;
     1114        ruhXe = (UChar)Max( iXe, 0 );
     1115        ruhYe = (UChar)(uiScaledBlockSize-1);
     1116        return;
     1117      }
     1118      else
     1119      {
     1120        uiOri = 5;
     1121        ruhXe = (UChar)(uiScaledBlockSize-1);
     1122        ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 );
     1123        std::swap( ruhXs, ruhXe );
     1124        std::swap( ruhYs, ruhYe );
     1125        return;
     1126      }
     1127    }
     1128    else
     1129    {
     1130      Int iYe = iVirtualEndY - iDeltaEnd;
     1131      if( iYe < 0 )
     1132      {
     1133        uiOri = 0;
     1134        ruhXe = (UChar)Max( ((uiScaledBlockSize-1) + iYe), 0 );
     1135        ruhYe = 0;
     1136        std::swap( ruhXs, ruhXe );
     1137        std::swap( ruhYs, ruhYe );
     1138        return;
     1139      }
     1140      else if( iYe > (uiScaledBlockSize-1) )
     1141      {
     1142        uiOri = 3;
     1143        ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 );
     1144        ruhYe = (UChar)(uiScaledBlockSize-1);
     1145        return;
     1146      }
     1147      else
     1148      {
     1149        uiOri = 5;
     1150        ruhXe = (UChar)(uiScaledBlockSize-1);
     1151        ruhYe = (UChar)iYe;
     1152        std::swap( ruhXs, ruhXe );
     1153        std::swap( ruhYs, ruhYe );
     1154        return;
     1155      }
     1156    }
     1157  }
     1158
     1159  // case origin
     1160  if( uiScaledStartPosX == 0 && uiScaledStartPosY == 0 )
     1161  {
     1162    if( iDeltaX*iDeltaY < 0 )
     1163    {
     1164      return;
     1165    }
     1166
     1167    ruhXs = 0;
     1168    ruhYs = 0;
     1169
     1170    if( iDeltaY == 0 )
     1171    {
     1172      uiOri = 1;
     1173      ruhXe = (UChar)(uiScaledBlockSize-1);
     1174      ruhYe = 0;
     1175      std::swap( ruhXs, ruhXe );
     1176      std::swap( ruhYs, ruhYe );
     1177      return;
     1178  }
     1179
     1180    if( iDeltaX == 0 )
     1181    {
     1182      uiOri = 0;
     1183      ruhXe = 0;
     1184      ruhYe = (UChar)(uiScaledBlockSize-1);
     1185      return;
     1186  }
     1187
     1188    Int iVirtualEndX = (Int)ruhXs + roftoi( (Double)(uiScaledBlockSize-1) * ((Double)iDeltaX / (Double)iDeltaY) );
     1189
     1190    if( iVirtualEndX > (uiScaledBlockSize-1) )
     1191    {
     1192      Int iYe = roftoi( (Double)((Int)(uiScaledBlockSize-1) - (Int)ruhXs) * ((Double)iDeltaY / (Double)iDeltaX) ) - iDeltaEnd;
     1193      if( iYe < (Int)uiScaledBlockSize )
     1194      {
     1195        uiOri = 1;
     1196        ruhXe = (UChar)(uiScaledBlockSize-1);
     1197        ruhYe = (UChar)Max( iYe, 0 );
     1198        std::swap( ruhXs, ruhXe );
     1199        std::swap( ruhYs, ruhYe );
     1200        return;
     1201      }
     1202      else
     1203      {
     1204        uiOri = 3;
     1205        ruhXe = (UChar)Max( ((uiScaledBlockSize-1) - (iYe - (uiScaledBlockSize-1))), 0 );
     1206        ruhYe = (UChar)(uiScaledBlockSize-1);
     1207        return;
     1208      }
     1209    }
     1210    else
     1211    {
     1212      Int iXe = iVirtualEndX + iDeltaEnd;
     1213      if( iXe < 0 )
     1214      {
     1215        uiOri = 0;
     1216        ruhXe = 0;
     1217        ruhYe = (UChar)Max( ((uiScaledBlockSize-1) + iXe), 0 );
     1218        return;
     1219      }
     1220      else if( iXe > (uiScaledBlockSize-1) )
     1221      {
     1222        uiOri = 1;
     1223        ruhXe = (UChar)(uiScaledBlockSize-1);
     1224        ruhYe = (UChar)Max( ((uiScaledBlockSize-1) - (iXe - (uiScaledBlockSize-1))), 0 );
     1225        std::swap( ruhXs, ruhXe );
     1226        std::swap( ruhYs, ruhYe );
     1227        return;
     1228      }
     1229      else
     1230      {
     1231        uiOri = 3;
     1232        ruhXe = (UChar)iXe;
     1233        ruhYe = (UChar)(uiScaledBlockSize-1);
     1234        return;
     1235      }
     1236    }
     1237  }
     1238}
     1239
     1240Bool TComPrediction::getWedgeListIdx( WedgeList* pcWedgeList, WedgeRefList* pcWedgeRefList, UInt& ruiTabIdx, UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe )
     1241{
     1242  ruiTabIdx = 0;
     1243
     1244  for( UInt uiIdx = 0; uiIdx < pcWedgeList->size(); uiIdx++ )
     1245  {
     1246    TComWedgelet* pcTestWedge = &(pcWedgeList->at(uiIdx));
     1247
     1248    if( pcTestWedge->getStartX() == uhXs &&
     1249        pcTestWedge->getStartY() == uhYs &&
     1250        pcTestWedge->getEndX()   == uhXe &&
     1251        pcTestWedge->getEndY()   == uhYe    )
     1252    {
     1253      ruiTabIdx = uiIdx;
     1254      return true;
     1255    }
     1256  }
     1257
     1258  // additionally search in WedgeRef lists of duplicated patterns
     1259  for( UInt uiIdx = 0; uiIdx < pcWedgeRefList->size(); uiIdx++ )
     1260  {
     1261    TComWedgeRef* pcTestWedgeRef = &(pcWedgeRefList->at(uiIdx));
     1262
     1263    if( pcTestWedgeRef->getStartX() == uhXs &&
     1264        pcTestWedgeRef->getStartY() == uhYs &&
     1265        pcTestWedgeRef->getEndX()   == uhXe &&
     1266        pcTestWedgeRef->getEndY()   == uhYe    )
     1267    {
     1268      ruiTabIdx = pcTestWedgeRef->getRefIdx();
     1269      return true;
     1270    }
     1271  }
     1272
     1273  return false;
     1274}
     1275
     1276Void TComPrediction::xPredIntraWedgeDir( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iWedgeDeltaEnd, Int iDeltaDC1, Int iDeltaDC2 )
     1277{
     1278  assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );
     1279  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];
     1280
     1281  // get wedge pattern
     1282  UInt uiDirWedgeTabIdx = 0;
     1283  if( bEncoder )
     1284  {
     1285    // encoder: load stored wedge pattern from CU
     1286    uiDirWedgeTabIdx = pcCU->getWedgePredDirTabIdx( uiAbsPartIdx );
     1287  }
     1288  else
     1289  {
     1290    uiDirWedgeTabIdx = getBestContinueWedge( pcCU, uiAbsPartIdx, iWidth, iHeight, iWedgeDeltaEnd );
     1291
     1292    UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1);
     1293    pcCU->setWedgePredDirTabIdxSubParts( uiDirWedgeTabIdx, uiAbsPartIdx, uiDepth );
     1294  }
     1295  TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiDirWedgeTabIdx));
     1296
     1297  // get wedge pred DCs
     1298  Int iPredDC1 = 0;
     1299  Int iPredDC2 = 0;
     1300
     1301  Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
     1302  Int iMaskStride = ( iWidth<<1 ) + 1;
     1303  piMask += iMaskStride+1;
     1304  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     1305
     1306  if( bDelta )
     1307  {
     1308    xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
     1309    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
     1310  }
     1311
     1312  // assign wedge pred DCs to prediction
     1313  if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
     1314  else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride,        iPredDC1,                   iPredDC2             ); }
     1315}
     1316#endif
     1317
     1318#if HHI_DMM_PRED_TEX
     1319Void TComPrediction::xPredIntraWedgeTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 )
     1320{
     1321  assert( iWidth >= DMM_WEDGEMODEL_MIN_SIZE && iWidth <= DMM_WEDGEMODEL_MAX_SIZE );
     1322  WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[iWidth])];
     1323
     1324  // get wedge pattern
     1325  UInt uiTextureWedgeTabIdx = 0;
     1326  if( bEncoder )
     1327  {
     1328     // encoder: load stored wedge pattern from CU
     1329    uiTextureWedgeTabIdx = pcCU->getWedgePredTexTabIdx( uiAbsPartIdx );
     1330  }
     1331  else
     1332  {
     1333    // decoder: get and store wedge pattern in CU
     1334    uiTextureWedgeTabIdx = getBestWedgeFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight );
     1335    UInt uiDepth = (pcCU->getDepth(0)) + (pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1);
     1336    pcCU->setWedgePredTexTabIdxSubParts( uiTextureWedgeTabIdx, uiAbsPartIdx, uiDepth );
     1337  }
     1338  TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiTextureWedgeTabIdx));
     1339
     1340  // get wedge pred DCs
     1341  Int iPredDC1 = 0;
     1342  Int iPredDC2 = 0;
     1343  Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
     1344  Int iMaskStride = ( iWidth<<1 ) + 1;
     1345  piMask += iMaskStride+1;
     1346  getWedgePredDCs( pcWedgelet, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     1347
     1348  if( bDelta )
     1349  {
     1350    xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
     1351    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
     1352  }
     1353
     1354  // assign wedge pred DCs to prediction
     1355  if( bDelta ) { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
     1356  else         { assignWedgeDCs2Pred( pcWedgelet, piPred, uiStride,        iPredDC1,                   iPredDC2           ); }
     1357}
     1358
     1359Void TComPrediction::xPredIntraContourTex( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bAbove, Bool bLeft, Bool bEncoder, Bool bDelta, Int iDeltaDC1, Int iDeltaDC2 )
     1360{
     1361  // get contour pattern
     1362  TComWedgelet* pcContourWedge = new TComWedgelet( iWidth, iHeight );
     1363  getBestContourFromText( pcCU, uiAbsPartIdx, (UInt)iWidth, (UInt)iHeight, pcContourWedge );
     1364
     1365  // get wedge pred DCs
     1366  Int iPredDC1 = 0;
     1367  Int iPredDC2 = 0;
     1368  Int* piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt );
     1369  Int iMaskStride = ( iWidth<<1 ) + 1;
     1370  piMask += iMaskStride+1;
     1371  getWedgePredDCs( pcContourWedge, piMask, iMaskStride, iPredDC1, iPredDC2, bAbove, bLeft );
     1372
     1373  if( bDelta )
     1374  {
     1375    xDeltaDCQuantScaleUp( pcCU, iDeltaDC1 );
     1376    xDeltaDCQuantScaleUp( pcCU, iDeltaDC2 );
     1377  }
     1378
     1379  // assign wedge pred DCs to prediction
     1380  if( bDelta ) { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride, Clip ( iPredDC1+iDeltaDC1 ), Clip( iPredDC2+iDeltaDC2 ) ); }
     1381  else         { assignWedgeDCs2Pred( pcContourWedge, piPred, uiStride,        iPredDC1,                   iPredDC2           ); }
     1382
     1383  pcContourWedge->destroy();
     1384  delete pcContourWedge;
     1385}
     1386
     1387Void TComPrediction::getBestContourFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge, Pel* piTextureBlock )
     1388{
     1389  pcContourWedge->clear();
     1390  Bool* pabContourPattern = pcContourWedge->getPattern();
     1391
     1392  // get copy of according texture luma block
     1393  Pel* piTempY = NULL;
     1394  TComYuv cTempYuv;
     1395
     1396  if ( piTextureBlock )
     1397  {
     1398    piTempY = piTextureBlock;
     1399  }
     1400  else
     1401  {
     1402    cTempYuv.create( uiWidth, uiHeight ); cTempYuv.clear();
     1403    piTempY      = cTempYuv.getLumaAddr();
     1404
     1405    fillTexturePicTempBlock( pcCU, uiAbsPartIdx, piTempY, uiWidth, uiHeight );
     1406
     1407    piTempY = cTempYuv.getLumaAddr();
     1408  }
     1409
     1410  // find contour for texture luma block
     1411  UInt iDC = 0;
     1412  for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) { iDC += piTempY[k]; }
     1413  iDC /= (uiWidth*uiHeight);
     1414
     1415  if ( piTextureBlock )
     1416  {
     1417    piTempY = piTextureBlock;
     1418  }
     1419  else
     1420  {
     1421    piTempY = cTempYuv.getLumaAddr();
     1422  }
     1423
     1424  for( UInt k = 0; k < (uiWidth*uiHeight); k++ )
     1425  {
     1426    pabContourPattern[k] = (piTempY[k] > iDC) ? true : false;
     1427  }
     1428
     1429  cTempYuv.destroy();
     1430}
     1431
     1432UInt TComPrediction::getBestWedgeFromText( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, WedgeDist eWedgeDist, Pel* piTextureBlock )
    13801433{
    13811434  assert( uiWidth >= DMM_WEDGEMODEL_MIN_SIZE && uiWidth <= DMM_WEDGEMODEL_MAX_SIZE );
     
    13831436
    13841437  // get copy of according texture luma block
    1385   UInt uiPartAddr = 0;
    1386   Int  iBlockWidth, iBlockHeight;
     1438  Pel* piTempY = NULL;   
    13871439  TComYuv     cTempYuv;
    1388   UInt        uiTempStride;
    1389   Pel*        piTempY;     
    1390 
    1391   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec();
    1392   Int         iRefStride = pcPicYuvRef->getStride();
    1393   Pel*        piRefY;
    1394 
    1395   pcCU->getPartIndexAndSize( uiAbsPartIdx, uiPartAddr, iBlockWidth, iBlockHeight );
    1396 
    1397   piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr );
    1398 
    1399   cTempYuv.create( pcCU->getWidth(0), pcCU->getHeight(0) ); cTempYuv.clear();
    1400   uiTempStride = cTempYuv.getStride();
    1401   piTempY      = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth );
    1402 
    1403   for ( Int y = 0; y < iBlockHeight; y++ )
    1404   {
    1405     ::memcpy(piTempY, piRefY, sizeof(Pel)*iBlockWidth);
    1406     piTempY += uiTempStride;
    1407     piRefY += iRefStride;
    1408   }
    1409 
    1410   piTempY = cTempYuv.getLumaAddr( uiAbsPartIdx, uiWidth );
    1411 
     1440
     1441  if ( piTextureBlock )
     1442  {
     1443    piTempY = piTextureBlock;
     1444  }
     1445  else
     1446  {
     1447    cTempYuv.create( uiWidth, uiHeight ); cTempYuv.clear();
     1448    piTempY      = cTempYuv.getLumaAddr();
     1449
     1450    fillTexturePicTempBlock( pcCU, uiAbsPartIdx, piTempY, uiWidth, uiHeight );
     1451
     1452    piTempY = cTempYuv.getLumaAddr();
     1453  }
     1454 
    14121455  TComWedgeDist cWedgeDist;
    14131456  UInt uiTextureWedgeTabIdx = 0;
     
    14291472  for( UInt uiIdx = 0; uiIdx < pacWedgeList->size(); uiIdx++ )
    14301473  {
    1431     calcWedgeDCs       ( &(pacWedgeList->at(uiIdx)), piTempY,  uiTempStride,  iDC1, iDC2 );
     1474    calcWedgeDCs       ( &(pacWedgeList->at(uiIdx)), piTempY,  uiWidth,  iDC1, iDC2 );
    14321475    assignWedgeDCs2Pred( &(pacWedgeList->at(uiIdx)), piPred, uiPredStride, iDC1, iDC2 );
    14331476
    1434     UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piTempY, uiTempStride, uiWidth, uiHeight, eWedgeDist );
     1477    UInt uiActDist = cWedgeDist.getDistPart( piPred, uiPredStride, piTempY, uiWidth, uiWidth, uiHeight, eWedgeDist );
    14351478
    14361479    if( uiActDist < uiBestDist || uiBestDist == MAX_UINT )
     
    14461489  return uiTextureWedgeTabIdx;
    14471490}
     1491
     1492Void TComPrediction::fillTexturePicTempBlock( TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* piTempBlockY, UInt uiWidth, UInt uiHeight )
     1493{
     1494  TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getTexturePic()->getPicYuvRec();
     1495  Int         iRefStride = pcPicYuvRef->getStride();
     1496  Pel*        piRefY;
     1497
     1498  piRefY = pcPicYuvRef->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiAbsPartIdx );
     1499
     1500  for ( Int y = 0; y < uiHeight; y++ )
     1501  {
     1502    ::memcpy(piTempBlockY, piRefY, sizeof(Pel)*uiWidth);
     1503    piTempBlockY += uiWidth;
     1504    piRefY += iRefStride;
     1505  }
     1506}
    14481507#endif
    14491508
     
    14981557
    14991558#if HIGH_ACCURACY_BI
     1559#if DEPTH_MAP_GENERATION
    15001560Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap, Bool bi )
    15011561#else
     1562Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bi )
     1563#endif
     1564#else
     1565#if DEPTH_MAP_GENERATION
    15021566Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx, Bool bPrdDepthMap )
     1567#else
     1568Void TComPrediction::xPredInterUni ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iPartIdx )
     1569#endif
    15031570#endif
    15041571{
     
    15071574  pcCU->clipMv(cMv);
    15081575
     1576#if DEPTH_MAP_GENERATION
    15091577  if( bPrdDepthMap )
    15101578  {
     
    15171585    return;
    15181586  }
    1519 
    1520 #if MW_DEPTH_MAP_INTERP_FILTER
     1587#endif
     1588
     1589#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    15211590  if( pcCU->getSlice()->getSPS()->isDepth() )
    15221591  {
     
    15261595    UInt uiRShift = 0;
    15271596#endif
    1528     xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, MW_DEPTH_MAP_INTERP_FILTER );
     1597    xPredInterPrdDepthMap( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, uiRShift, 2 );
    15291598  }
    15301599  else
     
    15431612  xPredInterLumaBlk       ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred );
    15441613#endif
    1545 #if MW_DEPTH_MAP_INTERP_FILTER
     1614#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    15461615  }
    15471616#endif
     
    15811650#if HIGH_ACCURACY_BI
    15821651    if( pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( uiPartAddr ) >= 0 && pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( uiPartAddr ) >= 0 )
     1652#if DEPTH_MAP_GENERATION
    15831653      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap, true );
     1654#else
     1655      xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, true );
     1656#endif
    15841657    else
    1585       xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
     1658#if DEPTH_MAP_GENERATION
     1659     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
    15861660#else
     1661     xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx );
     1662#endif
     1663#else
     1664#if DEPTH_MAP_GENERATION
    15871665    xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx, bPrdDepthMap );
     1666#else
     1667    xPredInterUni ( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, iPartIdx );
     1668#endif
    15881669#endif
    15891670  }
     
    16101691  Int     iHor        = ( uiFilterMode == 2 ? ( pcMv->getHor() + 2 ) & iFPelMask : pcMv->getHor() );
    16111692  Int     iVer        = ( uiFilterMode == 2 ? ( pcMv->getVer() + 2 ) & iFPelMask : pcMv->getVer() );
    1612 #if MW_DEPTH_MAP_INTERP_FILTER == 2 && MW_FULL_PEL_DEPTH_MAP_MV_SIGNALLING
     1693#if HHI_FULL_PEL_DEPTH_MAP_MV_ACC
    16131694  if( pcCU->getSlice()->getSPS()->isDepth() )
    16141695  {
     
    25612642#endif
    25622643
    2563 #if HHI_DMM_INTRA
     2644#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
    25642645TComWedgeDist::TComWedgeDist()
    25652646{
Note: See TracChangeset for help on using the changeset viewer.