Ignore:
Timestamp:
4 May 2015, 18:38:08 (10 years ago)
Author:
tech
Message:

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

  • remaining 3D-HEVC tools.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-14.1-update-dev0/source/Lib/TLibCommon/TComYuv.cpp

    r1179 r1200  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5151TComYuv::TComYuv()
    5252{
    53   m_apiBufY = NULL;
    54   m_apiBufU = NULL;
    55   m_apiBufV = NULL;
     53  for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++)
     54  {
     55    m_apiBuf[comp] = NULL;
     56  }
    5657}
    5758
     
    6061}
    6162
    62 Void TComYuv::create( UInt iWidth, UInt iHeight )
    63 {
    64   // memory allocation
    65   m_apiBufY  = (Pel*)xMalloc( Pel, iWidth*iHeight    );
    66   m_apiBufU  = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 );
    67   m_apiBufV  = (Pel*)xMalloc( Pel, iWidth*iHeight >> 2 );
    68  
     63Void TComYuv::create( UInt iWidth, UInt iHeight, ChromaFormat chromaFormatIDC )
     64{
    6965  // set width and height
    7066  m_iWidth   = iWidth;
    7167  m_iHeight  = iHeight;
    72   m_iCWidth  = iWidth  >> 1;
    73   m_iCHeight = iHeight >> 1;
     68  m_chromaFormatIDC = chromaFormatIDC;
     69
     70  for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++)
     71  {
     72    // memory allocation
     73    m_apiBuf[comp]  = (Pel*)xMalloc( Pel, getWidth(ComponentID(comp))*getHeight(ComponentID(comp)) );
     74  }
    7475}
    7576
     
    7778{
    7879  // memory free
    79   xFree( m_apiBufY ); m_apiBufY = NULL;
    80   xFree( m_apiBufU ); m_apiBufU = NULL;
    81   xFree( m_apiBufV ); m_apiBufV = NULL;
     80  for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++)
     81  {
     82    if (m_apiBuf[comp]!=NULL)
     83    {
     84      xFree( m_apiBuf[comp] );
     85      m_apiBuf[comp] = NULL;
     86    }
     87  }
    8288}
    8389
    8490Void TComYuv::clear()
    8591{
    86   ::memset( m_apiBufY, 0, ( m_iWidth  * m_iHeight  )*sizeof(Pel) );
    87   ::memset( m_apiBufU, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) );
    88   ::memset( m_apiBufV, 0, ( m_iCWidth * m_iCHeight )*sizeof(Pel) );
    89 }
    90 
    91 Void TComYuv::copyToPicYuv   ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx )
    92 {
    93   copyToPicLuma  ( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx );
    94   copyToPicChroma( pcPicYuvDst, iCuAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx );
    95 }
    96 
    97 Void TComYuv::copyToPicLuma  ( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx )
    98 {
    99   Int  y, iWidth, iHeight;
    100   iWidth  = m_iWidth >>uiPartDepth;
    101   iHeight = m_iHeight>>uiPartDepth;
    102  
    103   Pel* pSrc     = getLumaAddr(uiPartIdx, iWidth);
    104   Pel* pDst     = pcPicYuvDst->getLumaAddr ( iCuAddr, uiAbsZorderIdx );
    105  
    106   UInt  iSrcStride  = getStride();
    107   UInt  iDstStride  = pcPicYuvDst->getStride();
    108  
    109   for ( y = iHeight; y != 0; y-- )
     92  for(Int comp=0; comp<MAX_NUM_COMPONENT; comp++)
     93  {
     94    if (m_apiBuf[comp]!=NULL)
     95    {
     96      ::memset( m_apiBuf[comp], 0, ( getWidth(ComponentID(comp)) * getHeight(ComponentID(comp))  )*sizeof(Pel) );
     97    }
     98  }
     99}
     100
     101
     102
     103
     104Void TComYuv::copyToPicYuv   ( TComPicYuv* pcPicYuvDst, const UInt ctuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth, const UInt uiPartIdx ) const
     105{
     106  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     107  {
     108    copyToPicComponent  ( ComponentID(comp), pcPicYuvDst, ctuRsAddr, uiAbsZorderIdx, uiPartDepth, uiPartIdx );
     109  }
     110}
     111
     112Void TComYuv::copyToPicComponent  ( const ComponentID compID, TComPicYuv* pcPicYuvDst, const UInt ctuRsAddr, const UInt uiAbsZorderIdx, const UInt uiPartDepth, const UInt uiPartIdx ) const
     113{
     114  const Int iWidth  = getWidth(compID) >>uiPartDepth;
     115  const Int iHeight = getHeight(compID)>>uiPartDepth;
     116
     117  const Pel* pSrc     = getAddr(compID, uiPartIdx, iWidth);
     118        Pel* pDst     = pcPicYuvDst->getAddr ( compID, ctuRsAddr, uiAbsZorderIdx );
     119
     120  const UInt  iSrcStride  = getStride(compID);
     121  const UInt  iDstStride  = pcPicYuvDst->getStride(compID);
     122
     123  for ( Int y = iHeight; y != 0; y-- )
    110124  {
    111125    ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth);
     
    125139}
    126140
    127 Void TComYuv::copyToPicChroma( TComPicYuv* pcPicYuvDst, UInt iCuAddr, UInt uiAbsZorderIdx, UInt uiPartDepth, UInt uiPartIdx )
    128 {
    129   Int  y, iWidth, iHeight;
    130   iWidth  = m_iCWidth >>uiPartDepth;
    131   iHeight = m_iCHeight>>uiPartDepth;
    132  
    133   Pel* pSrcU      = getCbAddr(uiPartIdx, iWidth);
    134   Pel* pSrcV      = getCrAddr(uiPartIdx, iWidth);
    135   Pel* pDstU      = pcPicYuvDst->getCbAddr( iCuAddr, uiAbsZorderIdx );
    136   Pel* pDstV      = pcPicYuvDst->getCrAddr( iCuAddr, uiAbsZorderIdx );
    137  
    138   UInt  iSrcStride = getCStride();
    139   UInt  iDstStride = pcPicYuvDst->getCStride();
    140   for ( y = iHeight; y != 0; y-- )
    141   {
    142     ::memcpy( pDstU, pSrcU, sizeof(Pel)*(iWidth) );
    143     ::memcpy( pDstV, pSrcV, sizeof(Pel)*(iWidth) );
    144     pSrcU += iSrcStride;
    145     pSrcV += iSrcStride;
    146     pDstU += iDstStride;
    147     pDstV += iDstStride;
    148   }
    149 }
    150 
    151 Void TComYuv::copyFromPicYuv   ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx )
    152 {
    153   copyFromPicLuma  ( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx );
    154   copyFromPicChroma( pcPicYuvSrc, iCuAddr, uiAbsZorderIdx );
    155 }
    156 
    157 Void TComYuv::copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx )
    158 {
    159   Int  y;
    160  
    161   Pel* pDst     = m_apiBufY;
    162   Pel* pSrc     = pcPicYuvSrc->getLumaAddr ( iCuAddr, uiAbsZorderIdx );
    163  
    164   UInt  iDstStride  = getStride();
    165   UInt  iSrcStride  = pcPicYuvSrc->getStride();
    166   for ( y = m_iHeight; y != 0; y-- )
    167   {
    168     ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth);
     141
     142
     143
     144Void TComYuv::copyFromPicYuv   ( const TComPicYuv* pcPicYuvSrc, const UInt ctuRsAddr, const UInt uiAbsZorderIdx )
     145{
     146  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     147  {
     148    copyFromPicComponent  ( ComponentID(comp), pcPicYuvSrc, ctuRsAddr, uiAbsZorderIdx );
     149  }
     150}
     151
     152Void TComYuv::copyFromPicComponent  ( const ComponentID compID, const TComPicYuv* pcPicYuvSrc, const UInt ctuRsAddr, const UInt uiAbsZorderIdx )
     153{
     154        Pel* pDst     = getAddr(compID);
     155  const Pel* pSrc     = pcPicYuvSrc->getAddr ( compID, ctuRsAddr, uiAbsZorderIdx );
     156
     157  const UInt iDstStride  = getStride(compID);
     158  const UInt iSrcStride  = pcPicYuvSrc->getStride(compID);
     159  const Int  iWidth=getWidth(compID);
     160  const Int  iHeight=getHeight(compID);
     161
     162  for (Int y = iHeight; y != 0; y-- )
     163  {
     164    ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth);
    169165    pDst += iDstStride;
    170166    pSrc += iSrcStride;
     
    172168}
    173169
    174 Void TComYuv::copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx )
    175 {
    176   Int  y;
    177  
    178   Pel* pDstU      = m_apiBufU;
    179   Pel* pDstV      = m_apiBufV;
    180   Pel* pSrcU      = pcPicYuvSrc->getCbAddr( iCuAddr, uiAbsZorderIdx );
    181   Pel* pSrcV      = pcPicYuvSrc->getCrAddr( iCuAddr, uiAbsZorderIdx );
    182  
    183   UInt  iDstStride = getCStride();
    184   UInt  iSrcStride = pcPicYuvSrc->getCStride();
    185   for ( y = m_iCHeight; y != 0; y-- )
    186   {
    187     ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) );
    188     ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) );
    189     pSrcU += iSrcStride;
    190     pSrcV += iSrcStride;
    191     pDstU += iDstStride;
    192     pDstV += iDstStride;
    193   }
    194 }
    195 
    196 Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx )
    197 {
    198   copyToPartLuma  ( pcYuvDst, uiDstPartIdx );
    199   copyToPartChroma( pcYuvDst, uiDstPartIdx );
    200 }
    201 
    202 Void TComYuv::copyToPartLuma( TComYuv* pcYuvDst, UInt uiDstPartIdx )
    203 {
    204   Int  y;
    205  
    206   Pel* pSrc     = m_apiBufY;
    207   Pel* pDst     = pcYuvDst->getLumaAddr( uiDstPartIdx );
    208  
    209   UInt  iSrcStride  = getStride();
    210   UInt  iDstStride  = pcYuvDst->getStride();
    211   for ( y = m_iHeight; y != 0; y-- )
    212   {
    213     ::memcpy( pDst, pSrc, sizeof(Pel)*m_iWidth);
     170
     171
     172
     173Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const
     174{
     175  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     176  {
     177    copyToPartComponent  ( ComponentID(comp), pcYuvDst, uiDstPartIdx );
     178  }
     179}
     180
     181Void TComYuv::copyToPartComponent( const ComponentID compID, TComYuv* pcYuvDst, const UInt uiDstPartIdx ) const
     182{
     183  const Pel* pSrc     = getAddr(compID);
     184        Pel* pDst     = pcYuvDst->getAddr( compID, uiDstPartIdx );
     185
     186  const UInt iSrcStride  = getStride(compID);
     187  const UInt iDstStride  = pcYuvDst->getStride(compID);
     188  const Int  iWidth=getWidth(compID);
     189  const Int  iHeight=getHeight(compID);
     190
     191  for (Int y = iHeight; y != 0; y-- )
     192  {
     193    ::memcpy( pDst, pSrc, sizeof(Pel)*iWidth);
    214194    pDst += iDstStride;
    215195    pSrc += iSrcStride;
     
    217197}
    218198
    219 Void TComYuv::copyToPartChroma( TComYuv* pcYuvDst, UInt uiDstPartIdx )
    220 {
    221   Int  y;
    222  
    223   Pel* pSrcU      = m_apiBufU;
    224   Pel* pSrcV      = m_apiBufV;
    225   Pel* pDstU      = pcYuvDst->getCbAddr( uiDstPartIdx );
    226   Pel* pDstV      = pcYuvDst->getCrAddr( uiDstPartIdx );
    227  
    228   UInt  iSrcStride = getCStride();
    229   UInt  iDstStride = pcYuvDst->getCStride();
    230   for ( y = m_iCHeight; y != 0; y-- )
    231   {
    232     ::memcpy( pDstU, pSrcU, sizeof(Pel)*(m_iCWidth) );
    233     ::memcpy( pDstV, pSrcV, sizeof(Pel)*(m_iCWidth) );
    234     pSrcU += iSrcStride;
    235     pSrcV += iSrcStride;
    236     pDstU += iDstStride;
    237     pDstV += iDstStride;
    238   }
    239 }
    240 
    241 Void TComYuv::copyPartToYuv( TComYuv* pcYuvDst, UInt uiSrcPartIdx )
    242 {
    243   copyPartToLuma  ( pcYuvDst, uiSrcPartIdx );
    244   copyPartToChroma( pcYuvDst, uiSrcPartIdx );
    245 }
    246 
    247 Void TComYuv::copyPartToLuma( TComYuv* pcYuvDst, UInt uiSrcPartIdx )
    248 {
    249   Int  y;
    250  
    251   Pel* pSrc     = getLumaAddr(uiSrcPartIdx);
    252   Pel* pDst     = pcYuvDst->getLumaAddr( 0 );
    253  
    254   UInt  iSrcStride  = getStride();
    255   UInt  iDstStride  = pcYuvDst->getStride();
    256  
    257   UInt uiHeight = pcYuvDst->getHeight();
    258   UInt uiWidth = pcYuvDst->getWidth();
    259  
    260   for ( y = uiHeight; y != 0; y-- )
     199
     200
     201
     202Void TComYuv::copyPartToYuv( TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const
     203{
     204  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     205  {
     206    copyPartToComponent  ( ComponentID(comp), pcYuvDst, uiSrcPartIdx );
     207  }
     208}
     209
     210Void TComYuv::copyPartToComponent( const ComponentID compID, TComYuv* pcYuvDst, const UInt uiSrcPartIdx ) const
     211{
     212  const Pel* pSrc     = getAddr(compID, uiSrcPartIdx);
     213        Pel* pDst     = pcYuvDst->getAddr(compID, 0 );
     214
     215  const UInt  iSrcStride  = getStride(compID);
     216  const UInt  iDstStride  = pcYuvDst->getStride(compID);
     217
     218  const UInt uiHeight = pcYuvDst->getHeight(compID);
     219  const UInt uiWidth = pcYuvDst->getWidth(compID);
     220
     221  for ( UInt y = uiHeight; y != 0; y-- )
    261222  {
    262223    ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth);
     
    266227}
    267228
    268 Void TComYuv::copyPartToChroma( TComYuv* pcYuvDst, UInt uiSrcPartIdx )
    269 {
    270   Int  y;
    271  
    272   Pel* pSrcU      = getCbAddr( uiSrcPartIdx );
    273   Pel* pSrcV      = getCrAddr( uiSrcPartIdx );
    274   Pel* pDstU      = pcYuvDst->getCbAddr( 0 );
    275   Pel* pDstV      = pcYuvDst->getCrAddr( 0 );
    276  
    277   UInt  iSrcStride = getCStride();
    278   UInt  iDstStride = pcYuvDst->getCStride();
    279  
    280   UInt uiCHeight = pcYuvDst->getCHeight();
    281   UInt uiCWidth = pcYuvDst->getCWidth();
    282  
    283   for ( y = uiCHeight; y != 0; y-- )
    284   {
    285     ::memcpy( pDstU, pSrcU, sizeof(Pel)*(uiCWidth) );
    286     ::memcpy( pDstV, pSrcV, sizeof(Pel)*(uiCWidth) );
    287     pSrcU += iSrcStride;
    288     pSrcV += iSrcStride;
    289     pDstU += iDstStride;
    290     pDstV += iDstStride;
    291   }
    292 }
    293 
    294 Void TComYuv::copyPartToPartYuv   ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight )
    295 {
    296   copyPartToPartLuma   (pcYuvDst, uiPartIdx, iWidth, iHeight );
    297   copyPartToPartChroma (pcYuvDst, uiPartIdx, iWidth>>1, iHeight>>1 );
    298 }
    299 
    300 Void TComYuv::copyPartToPartLuma  ( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight )
    301 {
    302   Pel* pSrc =           getLumaAddr(uiPartIdx);
    303   Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx);
     229
     230
     231
     232Void TComYuv::copyPartToPartYuv   ( TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt iWidth, const UInt iHeight ) const
     233{
     234  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     235  {
     236    copyPartToPartComponent   (ComponentID(comp), pcYuvDst, uiPartIdx, iWidth>>getComponentScaleX(ComponentID(comp)), iHeight>>getComponentScaleY(ComponentID(comp)) );
     237  }
     238}
     239
     240Void TComYuv::copyPartToPartComponent  ( const ComponentID compID, TComYuv* pcYuvDst, const UInt uiPartIdx, const UInt iWidthComponent, const UInt iHeightComponent ) const
     241{
     242  const Pel* pSrc =           getAddr(compID, uiPartIdx);
     243        Pel* pDst = pcYuvDst->getAddr(compID, uiPartIdx);
    304244  if( pSrc == pDst )
    305245  {
    306246    //th not a good idea
    307     //th best would be to fix the caller 
     247    //th best would be to fix the caller
    308248    return ;
    309249  }
    310  
    311   UInt  iSrcStride = getStride();
    312   UInt  iDstStride = pcYuvDst->getStride();
    313   for ( UInt y = iHeight; y != 0; y-- )
    314   {
    315     ::memcpy( pDst, pSrc, iWidth * sizeof(Pel) );
     250
     251  const UInt  iSrcStride = getStride(compID);
     252  const UInt  iDstStride = pcYuvDst->getStride(compID);
     253  for ( UInt y = iHeightComponent; y != 0; y-- )
     254  {
     255    ::memcpy( pDst, pSrc, iWidthComponent * sizeof(Pel) );
    316256    pSrc += iSrcStride;
    317257    pDst += iDstStride;
     
    319259}
    320260
    321 Void TComYuv::copyPartToPartChroma( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight )
    322 {
    323   Pel*  pSrcU =           getCbAddr(uiPartIdx);
    324   Pel*  pSrcV =           getCrAddr(uiPartIdx);
    325   Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
    326   Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
    327  
    328   if( pSrcU == pDstU && pSrcV == pDstV)
     261
     262
     263
     264Void TComYuv::copyPartToPartComponentMxN  ( const ComponentID compID, TComYuv* pcYuvDst, const TComRectangle &rect) const
     265{
     266  const Pel* pSrc =           getAddrPix( compID, rect.x0, rect.y0 );
     267        Pel* pDst = pcYuvDst->getAddrPix( compID, rect.x0, rect.y0 );
     268  if( pSrc == pDst )
    329269  {
    330270    //th not a good idea
    331     //th best would be to fix the caller 
     271    //th best would be to fix the caller
    332272    return ;
    333273  }
    334  
    335   UInt   iSrcStride = getCStride();
    336   UInt   iDstStride = pcYuvDst->getCStride();
    337   for ( UInt y = iHeight; y != 0; y-- )
    338   {
    339     ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) );
    340     ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) );
    341     pSrcU += iSrcStride;
    342     pSrcV += iSrcStride;
    343     pDstU += iDstStride;
    344     pDstV += iDstStride;
    345   }
    346 }
    347 
    348 Void TComYuv::copyPartToPartChroma( TComYuv* pcYuvDst, UInt uiPartIdx, UInt iWidth, UInt iHeight, UInt chromaId)
    349 {
    350   if(chromaId == 0)
    351   {
    352     Pel*  pSrcU =           getCbAddr(uiPartIdx);
    353     Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
    354     if( pSrcU == pDstU)
    355     {
    356       return ;
    357     }
    358     UInt   iSrcStride = getCStride();
    359     UInt   iDstStride = pcYuvDst->getCStride();
    360     for ( UInt y = iHeight; y != 0; y-- )
    361     {
    362       ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) );
    363       pSrcU += iSrcStride;
    364       pDstU += iDstStride;
    365     }
    366   }
    367   else if (chromaId == 1)
    368   {
    369     Pel*  pSrcV =           getCrAddr(uiPartIdx);
    370     Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
    371     if( pSrcV == pDstV)
    372     {
    373       return;
    374     }
    375     UInt   iSrcStride = getCStride();
    376     UInt   iDstStride = pcYuvDst->getCStride();
    377     for ( UInt y = iHeight; y != 0; y-- )
    378     {
    379       ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) );
    380       pSrcV += iSrcStride;
    381       pDstV += iDstStride;
    382     }
    383   }
    384   else
    385   {
    386     Pel*  pSrcU =           getCbAddr(uiPartIdx);
    387     Pel*  pSrcV =           getCrAddr(uiPartIdx);
    388     Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
    389     Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
    390    
    391     if( pSrcU == pDstU && pSrcV == pDstV)
    392     {
    393       //th not a good idea
    394       //th best would be to fix the caller
    395       return ;
    396     }
    397     UInt   iSrcStride = getCStride();
    398     UInt   iDstStride = pcYuvDst->getCStride();
    399     for ( UInt y = iHeight; y != 0; y-- )
    400     {
    401       ::memcpy( pDstU, pSrcU, iWidth * sizeof(Pel) );
    402       ::memcpy( pDstV, pSrcV, iWidth * sizeof(Pel) );
    403       pSrcU += iSrcStride;
    404       pSrcV += iSrcStride;
    405       pDstU += iDstStride;
    406       pDstV += iDstStride;
    407     }
    408   }
    409 }
    410 
    411 Void TComYuv::addClip( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
    412 {
    413   addClipLuma   ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize     );
    414   addClipChroma ( pcYuvSrc0, pcYuvSrc1, uiTrUnitIdx, uiPartSize>>1  );
    415 }
    416 
    417 Void TComYuv::addClipLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
     274
     275  const UInt  iSrcStride = getStride(compID);
     276  const UInt  iDstStride = pcYuvDst->getStride(compID);
     277  const UInt uiHeightComponent=rect.height;
     278  const UInt uiWidthComponent=rect.width;
     279  for ( UInt y = uiHeightComponent; y != 0; y-- )
     280  {
     281    ::memcpy( pDst, pSrc, uiWidthComponent * sizeof( Pel ) );
     282    pSrc += iSrcStride;
     283    pDst += iDstStride;
     284  }
     285}
     286
     287
     288
     289
     290Void TComYuv::addClip( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize, const BitDepths &clipBitDepths )
     291{
     292  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     293  {
     294    const ComponentID compID=ComponentID(comp);
     295    const Int uiPartWidth =uiPartSize>>getComponentScaleX(compID);
     296    const Int uiPartHeight=uiPartSize>>getComponentScaleY(compID);
     297
     298    const Pel* pSrc0 = pcYuvSrc0->getAddr(compID, uiTrUnitIdx, uiPartWidth );
     299    const Pel* pSrc1 = pcYuvSrc1->getAddr(compID, uiTrUnitIdx, uiPartWidth );
     300          Pel* pDst  = getAddr(compID, uiTrUnitIdx, uiPartWidth );
     301
     302    const UInt iSrc0Stride = pcYuvSrc0->getStride(compID);
     303    const UInt iSrc1Stride = pcYuvSrc1->getStride(compID);
     304    const UInt iDstStride  = getStride(compID);
     305    const Int clipbd = clipBitDepths.recon[toChannelType(compID)];
     306#if O0043_BEST_EFFORT_DECODING
     307    const Int bitDepthDelta = clipBitDepths.stream[toChannelType(compID)] - clipbd;
     308#endif
     309
     310    for ( Int y = uiPartHeight-1; y >= 0; y-- )
     311    {
     312      for ( Int x = uiPartWidth-1; x >= 0; x-- )
     313      {
     314#if O0043_BEST_EFFORT_DECODING
     315        pDst[x] = Pel(ClipBD<Int>( Int(pSrc0[x]) + rightShiftEvenRounding<Pel>(pSrc1[x], bitDepthDelta), clipbd));
     316#else
     317        pDst[x] = Pel(ClipBD<Int>( Int(pSrc0[x]) + Int(pSrc1[x]), clipbd));
     318#endif
     319      }
     320      pSrc0 += iSrc0Stride;
     321      pSrc1 += iSrc1Stride;
     322      pDst  += iDstStride;
     323    }
     324  }
     325}
     326
     327
     328
     329
     330Void TComYuv::subtract( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize )
     331{
     332  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     333  {
     334    const ComponentID compID=ComponentID(comp);
     335    const Int uiPartWidth =uiPartSize>>getComponentScaleX(compID);
     336    const Int uiPartHeight=uiPartSize>>getComponentScaleY(compID);
     337
     338    const Pel* pSrc0 = pcYuvSrc0->getAddr( compID, uiTrUnitIdx, uiPartWidth );
     339    const Pel* pSrc1 = pcYuvSrc1->getAddr( compID, uiTrUnitIdx, uiPartWidth );
     340          Pel* pDst  = getAddr( compID, uiTrUnitIdx, uiPartWidth );
     341
     342    const Int  iSrc0Stride = pcYuvSrc0->getStride(compID);
     343    const Int  iSrc1Stride = pcYuvSrc1->getStride(compID);
     344    const Int  iDstStride  = getStride(compID);
     345
     346    for (Int y = uiPartHeight-1; y >= 0; y-- )
     347    {
     348      for (Int x = uiPartWidth-1; x >= 0; x-- )
     349      {
     350        pDst[x] = pSrc0[x] - pSrc1[x];
     351      }
     352      pSrc0 += iSrc0Stride;
     353      pSrc1 += iSrc1Stride;
     354      pDst  += iDstStride;
     355    }
     356  }
     357}
     358
     359
     360
     361
     362Void TComYuv::addAvg( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt uiWidth, const UInt uiHeight, const BitDepths &clipBitDepths )
     363{
     364  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     365  {
     366    const ComponentID compID=ComponentID(comp);
     367    const Pel* pSrc0  = pcYuvSrc0->getAddr( compID, iPartUnitIdx );
     368    const Pel* pSrc1  = pcYuvSrc1->getAddr( compID, iPartUnitIdx );
     369    Pel* pDst   = getAddr( compID, iPartUnitIdx );
     370
     371    const UInt  iSrc0Stride = pcYuvSrc0->getStride(compID);
     372    const UInt  iSrc1Stride = pcYuvSrc1->getStride(compID);
     373    const UInt  iDstStride  = getStride(compID);
     374    const Int   clipbd      = clipBitDepths.recon[toChannelType(compID)];
     375    const Int   shiftNum    = std::max<Int>(2, (IF_INTERNAL_PREC - clipbd)) + 1;
     376    const Int   offset      = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS;
     377
     378    const Int   iWidth      = uiWidth  >> getComponentScaleX(compID);
     379    const Int   iHeight     = uiHeight >> getComponentScaleY(compID);
     380
     381    if (iWidth&1)
     382    {
     383      assert(0);
     384      exit(-1);
     385    }
     386    else if (iWidth&2)
     387    {
     388      for ( Int y = 0; y < iHeight; y++ )
     389      {
     390        for (Int x=0 ; x < iWidth; x+=2 )
     391        {
     392          pDst[ x + 0 ] = ClipBD( rightShift(( pSrc0[ x + 0 ] + pSrc1[ x + 0 ] + offset ), shiftNum), clipbd );
     393          pDst[ x + 1 ] = ClipBD( rightShift(( pSrc0[ x + 1 ] + pSrc1[ x + 1 ] + offset ), shiftNum), clipbd );
     394        }
     395        pSrc0 += iSrc0Stride;
     396        pSrc1 += iSrc1Stride;
     397        pDst  += iDstStride;
     398      }
     399    }
     400    else
     401    {
     402      for ( Int y = 0; y < iHeight; y++ )
     403      {
     404        for (Int x=0 ; x < iWidth; x+=4 )
     405        {
     406          pDst[ x + 0 ] = ClipBD( rightShift(( pSrc0[ x + 0 ] + pSrc1[ x + 0 ] + offset ), shiftNum), clipbd );
     407          pDst[ x + 1 ] = ClipBD( rightShift(( pSrc0[ x + 1 ] + pSrc1[ x + 1 ] + offset ), shiftNum), clipbd );
     408          pDst[ x + 2 ] = ClipBD( rightShift(( pSrc0[ x + 2 ] + pSrc1[ x + 2 ] + offset ), shiftNum), clipbd );
     409          pDst[ x + 3 ] = ClipBD( rightShift(( pSrc0[ x + 3 ] + pSrc1[ x + 3 ] + offset ), shiftNum), clipbd );
     410        }
     411        pSrc0 += iSrc0Stride;
     412        pSrc1 += iSrc1Stride;
     413        pDst  += iDstStride;
     414      }
     415    }
     416  }
     417}
     418
     419Void TComYuv::removeHighFreq( const TComYuv* pcYuvSrc,
     420                              const UInt uiPartIdx,
     421                              const UInt uiWidth,
     422                              const UInt uiHeight,
     423                              const Int bitDepths[MAX_NUM_CHANNEL_TYPE],
     424                              const Bool bClipToBitDepths
     425                              )
     426{
     427  for(Int comp=0; comp<getNumberValidComponents(); comp++)
     428  {
     429    const ComponentID compID=ComponentID(comp);
     430    const Pel* pSrc  = pcYuvSrc->getAddr(compID, uiPartIdx);
     431    Pel* pDst  = getAddr(compID, uiPartIdx);
     432
     433    const Int iSrcStride = pcYuvSrc->getStride(compID);
     434    const Int iDstStride = getStride(compID);
     435    const Int iWidth  = uiWidth >>getComponentScaleX(compID);
     436    const Int iHeight = uiHeight>>getComponentScaleY(compID);
     437    if (bClipToBitDepths)
     438    {
     439      const Int clipBd=bitDepths[toChannelType(compID)];
     440      for ( Int y = iHeight-1; y >= 0; y-- )
     441      {
     442        for ( Int x = iWidth-1; x >= 0; x-- )
     443        {
     444          pDst[x ] = ClipBD((2 * pDst[x]) - pSrc[x], clipBd);
     445        }
     446        pSrc += iSrcStride;
     447        pDst += iDstStride;
     448      }
     449    }
     450    else
     451    {
     452      for ( Int y = iHeight-1; y >= 0; y-- )
     453      {
     454        for ( Int x = iWidth-1; x >= 0; x-- )
     455        {
     456          pDst[x ] = (2 * pDst[x]) - pSrc[x];
     457        }
     458        pSrc += iSrcStride;
     459        pDst += iDstStride;
     460      }
     461    }
     462  }
     463}
     464
     465#if NH_3D_VSO
     466Void TComYuv::addClipPartLuma( Int bitDepth, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
    418467{
    419468  Int x, y;
    420  
    421   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize );
    422   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize );
    423   Pel* pDst  = getLumaAddr( uiTrUnitIdx, uiPartSize );
    424  
     469
     470  Pel* pSrc0 = pcYuvSrc0->getAddr( COMPONENT_Y, uiTrUnitIdx);
     471  Pel* pSrc1 = pcYuvSrc1->getAddr( COMPONENT_Y, uiTrUnitIdx);
     472  Pel* pDst  =            getAddr( COMPONENT_Y, uiTrUnitIdx);
     473
     474  UInt iSrc0Stride = pcYuvSrc0->getStride( COMPONENT_Y );
     475  UInt iSrc1Stride = pcYuvSrc1->getStride( COMPONENT_Y );
     476  UInt iDstStride  =            getStride( COMPONENT_Y );
     477  for ( y = uiPartSize-1; y >= 0; y-- )
     478  {
     479    for ( x = uiPartSize-1; x >= 0; x-- )
     480    {
     481      pDst[x] = ClipBD( pSrc0[x] + pSrc1[x], bitDepth );     
     482    }
     483    pSrc0 += iSrc0Stride;
     484    pSrc1 += iSrc1Stride;
     485    pDst  += iDstStride;
     486  }
     487}
     488
     489#if H_3D_ARP
     490Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
     491{
     492  addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip );
     493  addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip );
     494}
     495
     496Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
     497{
     498  Int x, y;
     499
     500  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
     501  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
     502  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
     503
    425504  UInt iSrc0Stride = pcYuvSrc0->getStride();
    426505  UInt iSrc1Stride = pcYuvSrc1->getStride();
    427506  UInt iDstStride  = getStride();
    428   for ( y = uiPartSize-1; y >= 0; y-- )
    429   {
    430     for ( x = uiPartSize-1; x >= 0; x-- )
    431     {
    432       pDst[x] = ClipY( pSrc0[x] + pSrc1[x] );
     507  Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY;
     508  Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
     509  for ( y = uiHeight-1; y >= 0; y-- )
     510  {
     511    for ( x = uiWidth-1; x >= 0; x-- )
     512    {
     513      pDst[x] = pSrc0[x] + pSrc1[x];
     514      if( bClip )
     515      {
     516        pDst[x] = ClipY( ( pDst[x] + iOffSet ) >> iIFshift );
     517      }
    433518    }
    434519    pSrc0 += iSrc0Stride;
     
    438523}
    439524
    440 Void TComYuv::addClipChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
     525Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
    441526{
    442527  Int x, y;
    443  
    444   Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize );
    445   Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize );
    446   Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize );
    447   Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize );
    448   Pel* pDstU = getCbAddr( uiTrUnitIdx, uiPartSize );
    449   Pel* pDstV = getCrAddr( uiTrUnitIdx, uiPartSize );
    450  
     528
     529  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
     530  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
     531  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
     532  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
     533  Pel* pDstU = getCbAddr( uiAbsPartIdx );
     534  Pel* pDstV = getCrAddr( uiAbsPartIdx );
     535
    451536  UInt  iSrc0Stride = pcYuvSrc0->getCStride();
    452537  UInt  iSrc1Stride = pcYuvSrc1->getCStride();
    453538  UInt  iDstStride  = getCStride();
    454   for ( y = uiPartSize-1; y >= 0; y-- )
    455   {
    456     for ( x = uiPartSize-1; x >= 0; x-- )
    457     {
    458       pDstU[x] = ClipC( pSrcU0[x] + pSrcU1[x] );
    459       pDstV[x] = ClipC( pSrcV0[x] + pSrcV1[x] );
    460     }
    461    
     539
     540  Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
     541  Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
     542
     543  for ( y = uiHeight-1; y >= 0; y-- )
     544  {
     545    for ( x = uiWidth-1; x >= 0; x-- )
     546    {
     547      pDstU[x] = pSrcU0[x] + pSrcU1[x];
     548      pDstV[x] = pSrcV0[x] + pSrcV1[x];
     549      if( bClip )
     550      {
     551        pDstU[x] = ClipC( ( pDstU[x] + iOffSet ) >> iIFshift );
     552        pDstV[x] = ClipC( ( pDstV[x] + iOffSet ) >> iIFshift );
     553      }
     554    }
     555
    462556    pSrcU0 += iSrc0Stride;
    463557    pSrcU1 += iSrc1Stride;
     
    469563}
    470564
    471 Void TComYuv::subtract( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
    472 {
    473   subtractLuma  ( pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize    );
    474   subtractChroma( pcYuvSrc0, pcYuvSrc1,  uiTrUnitIdx, uiPartSize>>1 );
    475 }
    476 
    477 Void TComYuv::subtractLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
     565Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
     566{
     567  subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
     568
     569  if (uiWidth > 8)
     570    subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
     571}
     572
     573Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    478574{
    479575  Int x, y;
    480  
    481   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx, uiPartSize );
    482   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx, uiPartSize );
    483   Pel* pDst  = getLumaAddr( uiTrUnitIdx, uiPartSize );
    484  
     576
     577  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
     578  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
     579  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
     580
    485581  Int  iSrc0Stride = pcYuvSrc0->getStride();
    486582  Int  iSrc1Stride = pcYuvSrc1->getStride();
    487583  Int  iDstStride  = getStride();
    488   for ( y = uiPartSize-1; y >= 0; y-- )
    489   {
    490     for ( x = uiPartSize-1; x >= 0; x-- )
     584  for ( y = uiHeight-1; y >= 0; y-- )
     585  {
     586    for ( x = uiWidth-1; x >= 0; x-- )
    491587    {
    492588      pDst[x] = pSrc0[x] - pSrc1[x];
     
    498594}
    499595
    500 Void TComYuv::subtractChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
     596Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    501597{
    502598  Int x, y;
    503  
    504   Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiTrUnitIdx, uiPartSize );
    505   Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiTrUnitIdx, uiPartSize );
    506   Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiTrUnitIdx, uiPartSize );
    507   Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiTrUnitIdx, uiPartSize );
    508   Pel* pDstU  = getCbAddr( uiTrUnitIdx, uiPartSize );
    509   Pel* pDstV  = getCrAddr( uiTrUnitIdx, uiPartSize );
    510  
     599
     600  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
     601  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
     602  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
     603  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
     604  Pel* pDstU  = getCbAddr( uiAbsPartIdx );
     605  Pel* pDstV  = getCrAddr( uiAbsPartIdx );
     606
    511607  Int  iSrc0Stride = pcYuvSrc0->getCStride();
    512608  Int  iSrc1Stride = pcYuvSrc1->getCStride();
    513609  Int  iDstStride  = getCStride();
    514   for ( y = uiPartSize-1; y >= 0; y-- )
    515   {
    516     for ( x = uiPartSize-1; x >= 0; x-- )
     610  for ( y = uiHeight-1; y >= 0; y-- )
     611  {
     612    for ( x = uiWidth-1; x >= 0; x-- )
    517613    {
    518614      pDstU[x] = pSrcU0[x] - pSrcU1[x];
     
    528624}
    529625
    530 Void TComYuv::addAvg( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight )
    531 {
    532   Int x, y;
    533  
    534   Pel* pSrcY0  = pcYuvSrc0->getLumaAddr( iPartUnitIdx );
    535   Pel* pSrcU0  = pcYuvSrc0->getCbAddr  ( iPartUnitIdx );
    536   Pel* pSrcV0  = pcYuvSrc0->getCrAddr  ( iPartUnitIdx );
    537  
    538   Pel* pSrcY1  = pcYuvSrc1->getLumaAddr( iPartUnitIdx );
    539   Pel* pSrcU1  = pcYuvSrc1->getCbAddr  ( iPartUnitIdx );
    540   Pel* pSrcV1  = pcYuvSrc1->getCrAddr  ( iPartUnitIdx );
    541  
    542   Pel* pDstY   = getLumaAddr( iPartUnitIdx );
    543   Pel* pDstU   = getCbAddr  ( iPartUnitIdx );
    544   Pel* pDstV   = getCrAddr  ( iPartUnitIdx );
    545  
    546   UInt  iSrc0Stride = pcYuvSrc0->getStride();
    547   UInt  iSrc1Stride = pcYuvSrc1->getStride();
    548   UInt  iDstStride  = getStride();
    549   Int shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthY;
    550   Int offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS;
    551  
    552   for ( y = 0; y < iHeight; y++ )
    553   {
    554     for ( x = 0; x < iWidth; x += 4 )
    555     {
    556       pDstY[ x + 0 ] = ClipY( ( pSrcY0[ x + 0 ] + pSrcY1[ x + 0 ] + offset ) >> shiftNum );
    557       pDstY[ x + 1 ] = ClipY( ( pSrcY0[ x + 1 ] + pSrcY1[ x + 1 ] + offset ) >> shiftNum );
    558       pDstY[ x + 2 ] = ClipY( ( pSrcY0[ x + 2 ] + pSrcY1[ x + 2 ] + offset ) >> shiftNum );
    559       pDstY[ x + 3 ] = ClipY( ( pSrcY0[ x + 3 ] + pSrcY1[ x + 3 ] + offset ) >> shiftNum );
    560     }
    561     pSrcY0 += iSrc0Stride;
    562     pSrcY1 += iSrc1Stride;
    563     pDstY  += iDstStride;
    564   }
    565  
    566   shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthC;
    567   offset = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS;
    568 
    569   iSrc0Stride = pcYuvSrc0->getCStride();
    570   iSrc1Stride = pcYuvSrc1->getCStride();
    571   iDstStride  = getCStride();
    572  
    573   iWidth  >>=1;
    574   iHeight >>=1;
    575  
    576   for ( y = iHeight-1; y >= 0; y-- )
    577   {
    578     for ( x = iWidth-1; x >= 0; )
    579     {
    580       // note: chroma min width is 2
    581       pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);
    582       pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--;
    583       pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);
    584       pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum); x--;
    585     }
    586    
    587     pSrcU0 += iSrc0Stride;
    588     pSrcU1 += iSrc1Stride;
    589     pSrcV0 += iSrc0Stride;
    590     pSrcV1 += iSrc1Stride;
    591     pDstU  += iDstStride;
    592     pDstV  += iDstStride;
    593   }
    594 }
    595 
    596 Void TComYuv::removeHighFreq( TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight )
    597 {
    598   Int x, y;
    599  
    600   Pel* pSrc  = pcYuvSrc->getLumaAddr(uiPartIdx);
    601   Pel* pSrcU = pcYuvSrc->getCbAddr(uiPartIdx);
    602   Pel* pSrcV = pcYuvSrc->getCrAddr(uiPartIdx);
    603  
    604   Pel* pDst  = getLumaAddr(uiPartIdx);
    605   Pel* pDstU = getCbAddr(uiPartIdx);
    606   Pel* pDstV = getCrAddr(uiPartIdx);
    607  
    608   Int  iSrcStride = pcYuvSrc->getStride();
    609   Int  iDstStride = getStride();
    610  
    611   for ( y = uiHeight-1; y >= 0; y-- )
    612   {
    613     for ( x = uiWidht-1; x >= 0; x-- )
    614     {
    615 #if DISABLING_CLIP_FOR_BIPREDME
    616       pDst[x ] = 2 * pDst[x] - pSrc[x];
    617 #else
    618       pDst[x ] = ClipY(2 * pDst[x] - pSrc[x]);
    619 #endif
    620     }
    621     pSrc += iSrcStride;
    622     pDst += iDstStride;
    623   }
    624  
    625   iSrcStride = pcYuvSrc->getCStride();
    626   iDstStride = getCStride();
    627  
    628   uiHeight >>= 1;
    629   uiWidht  >>= 1;
    630  
    631   for ( y = uiHeight-1; y >= 0; y-- )
    632   {
    633     for ( x = uiWidht-1; x >= 0; x-- )
    634     {
    635 #if DISABLING_CLIP_FOR_BIPREDME
    636       pDstU[x ] = 2 * pDstU[x] - pSrcU[x];
    637       pDstV[x ] = 2 * pDstV[x] - pSrcV[x];
    638 #else
    639       pDstU[x ] = ClipC(2 * pDstU[x] - pSrcU[x]);
    640       pDstV[x ] = ClipC(2 * pDstV[x] - pSrcV[x]);
    641 #endif
    642     }
    643     pSrcU += iSrcStride;
    644     pSrcV += iSrcStride;
    645     pDstU += iDstStride;
    646     pDstV += iDstStride;
    647   }
    648 }
    649 #if H_3D
    650 Void TComYuv::addClipPartLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize )
    651 {
    652   Int x, y;
    653 
    654   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiTrUnitIdx);
    655   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiTrUnitIdx);
    656   Pel* pDst  = getLumaAddr( uiTrUnitIdx);
    657 
    658   UInt iSrc0Stride = pcYuvSrc0->getStride();
    659   UInt iSrc1Stride = pcYuvSrc1->getStride();
    660   UInt iDstStride  = getStride();
    661   for ( y = uiPartSize-1; y >= 0; y-- )
    662   {
    663     for ( x = uiPartSize-1; x >= 0; x-- )
    664     {
    665       pDst[x] = ClipY( pSrc0[x] + pSrc1[x] );     
    666     }
    667     pSrc0 += iSrc0Stride;
    668     pSrc1 += iSrc1Stride;
    669     pDst  += iDstStride;
    670   }
    671 }
    672 
    673 #if H_3D_ARP
    674 Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
    675 {
    676   addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip );
    677   addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip );
    678 }
    679 
    680 Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
    681 {
    682   Int x, y;
    683 
    684   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
    685   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
    686   Pel* pDst  = getLumaAddr( uiAbsPartIdx );
    687 
    688   UInt iSrc0Stride = pcYuvSrc0->getStride();
    689   UInt iSrc1Stride = pcYuvSrc1->getStride();
    690   UInt iDstStride  = getStride();
    691   Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY;
    692   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
    693   for ( y = uiHeight-1; y >= 0; y-- )
    694   {
    695     for ( x = uiWidth-1; x >= 0; x-- )
    696     {
    697       pDst[x] = pSrc0[x] + pSrc1[x];
    698       if( bClip )
    699       {
    700         pDst[x] = ClipY( ( pDst[x] + iOffSet ) >> iIFshift );
    701       }
    702     }
    703     pSrc0 += iSrc0Stride;
    704     pSrc1 += iSrc1Stride;
    705     pDst  += iDstStride;
    706   }
    707 }
    708 
    709 Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
    710 {
    711   Int x, y;
    712 
    713   Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
    714   Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
    715   Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
    716   Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
    717   Pel* pDstU = getCbAddr( uiAbsPartIdx );
    718   Pel* pDstV = getCrAddr( uiAbsPartIdx );
    719 
    720   UInt  iSrc0Stride = pcYuvSrc0->getCStride();
    721   UInt  iSrc1Stride = pcYuvSrc1->getCStride();
    722   UInt  iDstStride  = getCStride();
    723 
    724   Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
    725   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
    726 
    727   for ( y = uiHeight-1; y >= 0; y-- )
    728   {
    729     for ( x = uiWidth-1; x >= 0; x-- )
    730     {
    731       pDstU[x] = pSrcU0[x] + pSrcU1[x];
    732       pDstV[x] = pSrcV0[x] + pSrcV1[x];
    733       if( bClip )
    734       {
    735         pDstU[x] = ClipC( ( pDstU[x] + iOffSet ) >> iIFshift );
    736         pDstV[x] = ClipC( ( pDstV[x] + iOffSet ) >> iIFshift );
    737       }
    738     }
    739 
    740     pSrcU0 += iSrc0Stride;
    741     pSrcU1 += iSrc1Stride;
    742     pSrcV0 += iSrc0Stride;
    743     pSrcV1 += iSrc1Stride;
    744     pDstU  += iDstStride;
    745     pDstV  += iDstStride;
    746   }
    747 }
    748 
    749 Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    750 {
    751   subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
    752 
    753   if (uiWidth > 8)
    754     subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
    755 }
    756 
    757 Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    758 {
    759   Int x, y;
    760 
    761   Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
    762   Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
    763   Pel* pDst  = getLumaAddr( uiAbsPartIdx );
    764 
    765   Int  iSrc0Stride = pcYuvSrc0->getStride();
    766   Int  iSrc1Stride = pcYuvSrc1->getStride();
    767   Int  iDstStride  = getStride();
    768   for ( y = uiHeight-1; y >= 0; y-- )
    769   {
    770     for ( x = uiWidth-1; x >= 0; x-- )
    771     {
    772       pDst[x] = pSrc0[x] - pSrc1[x];
    773     }
    774     pSrc0 += iSrc0Stride;
    775     pSrc1 += iSrc1Stride;
    776     pDst  += iDstStride;
    777   }
    778 }
    779 
    780 Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
    781 {
    782   Int x, y;
    783 
    784   Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
    785   Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
    786   Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
    787   Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
    788   Pel* pDstU  = getCbAddr( uiAbsPartIdx );
    789   Pel* pDstV  = getCrAddr( uiAbsPartIdx );
    790 
    791   Int  iSrc0Stride = pcYuvSrc0->getCStride();
    792   Int  iSrc1Stride = pcYuvSrc1->getCStride();
    793   Int  iDstStride  = getCStride();
    794   for ( y = uiHeight-1; y >= 0; y-- )
    795   {
    796     for ( x = uiWidth-1; x >= 0; x-- )
    797     {
    798       pDstU[x] = pSrcU0[x] - pSrcU1[x];
    799       pDstV[x] = pSrcV0[x] - pSrcV1[x];
    800     }
    801     pSrcU0 += iSrc0Stride;
    802     pSrcU1 += iSrc1Stride;
    803     pSrcV0 += iSrc0Stride;
    804     pSrcV1 += iSrc1Stride;
    805     pDstU  += iDstStride;
    806     pDstV  += iDstStride;
    807   }
    808 }
    809 
    810626Void TComYuv::multiplyARP( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
    811627{
Note: See TracChangeset for help on using the changeset viewer.