Changeset 608 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPicYuv.cpp


Ignore:
Timestamp:
1 Sep 2013, 22:47:26 (11 years ago)
Author:
tech
Message:

Merged DEV-2.0-dev0@604.

File:
1 edited

Legend:

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

    r443 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6060  m_piPicOrgU       = NULL;
    6161  m_piPicOrgV       = NULL;
    62 
    63 #if FIX_APPENCTOP_T_ONLY
    64   m_cuOffsetY       = NULL;
    65   m_cuOffsetC       = NULL;
    66   m_buOffsetY       = NULL;
    67   m_buOffsetC       = NULL;
    68 #endif 
    69 
     62 
    7063  m_bIsBorderExtended = false;
    7164}
     
    8477  m_iCuHeight       = uiMaxCUHeight;
    8578
     79#if H_3D_IV_MERGE
    8680  m_iNumCuInWidth   = m_iPicWidth / m_iCuWidth;
    8781  m_iNumCuInWidth  += ( m_iPicWidth % m_iCuWidth ) ? 1 : 0;
    8882
    89   m_uiMaxCuDepth = uiMaxCUDepth;
    90 
    9183  m_iBaseUnitWidth  = uiMaxCUWidth  >> uiMaxCUDepth;
    9284  m_iBaseUnitHeight = uiMaxCUHeight >> uiMaxCUDepth;
    93 
     85#endif
    9486  Int numCuInWidth  = m_iPicWidth  / m_iCuWidth  + (m_iPicWidth  % m_iCuWidth  != 0);
    9587  Int numCuInHeight = m_iPicHeight / m_iCuHeight + (m_iPicHeight % m_iCuHeight != 0);
    9688 
    97   m_iLumaMarginX    = g_uiMaxCUWidth  + PICYUV_PAD; // for 16-byte alignment
    98   m_iLumaMarginY    = g_uiMaxCUHeight + PICYUV_PAD;  // margin for 8-tap filter and infinite padding
     89  m_iLumaMarginX    = g_uiMaxCUWidth  + 16; // for 16-byte alignment
     90  m_iLumaMarginY    = g_uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
    9991 
    10092  m_iChromaMarginX  = m_iLumaMarginX>>1;
     
    144136  if( m_apiPicBufU ){ xFree( m_apiPicBufU );    m_apiPicBufU = NULL; }
    145137  if( m_apiPicBufV ){ xFree( m_apiPicBufV );    m_apiPicBufV = NULL; }
    146 #if FIX_APPENCTOP_T_ONLY
    147   if( m_cuOffsetY )
    148   {
    149 #endif
     138
    150139  delete[] m_cuOffsetY;
    151140  delete[] m_cuOffsetC;
    152141  delete[] m_buOffsetY;
    153142  delete[] m_buOffsetC;
    154 #if FIX_APPENCTOP_T_ONLY
    155   }
    156 #endif
    157143}
    158144
     
    165151  m_iCuWidth        = uiMaxCUWidth;
    166152  m_iCuHeight       = uiMaxCUHeight;
    167   m_uiMaxCuDepth    = uiMaxCUDepth;
    168 
    169   m_iNumCuInWidth   = m_iPicWidth / m_iCuWidth;
    170   m_iNumCuInWidth  += ( m_iPicWidth % m_iCuWidth ) ? 1 : 0;
    171 
    172   m_iBaseUnitWidth  = uiMaxCUWidth  >> uiMaxCUDepth;
    173   m_iBaseUnitHeight = uiMaxCUHeight >> uiMaxCUDepth;
    174 
    175153 
    176154  Int numCuInWidth  = m_iPicWidth  / m_iCuWidth  + (m_iPicWidth  % m_iCuWidth  != 0);
    177155  Int numCuInHeight = m_iPicHeight / m_iCuHeight + (m_iPicHeight % m_iCuHeight != 0);
    178156 
    179   m_iLumaMarginX    = g_uiMaxCUWidth  + PICYUV_PAD; // for 16-byte alignment
    180   m_iLumaMarginY    = g_uiMaxCUHeight + PICYUV_PAD;  // margin for 8-tap filter and infinite padding
     157  m_iLumaMarginX    = g_uiMaxCUWidth  + 16; // for 16-byte alignment
     158  m_iLumaMarginY    = g_uiMaxCUHeight + 16;  // margin for 8-tap filter and infinite padding
    181159 
    182160  m_apiPicBufY      = (Pel*)xMalloc( Pel, ( m_iPicWidth       + (m_iLumaMarginX  <<1)) * ( m_iPicHeight       + (m_iLumaMarginY  <<1)));
     
    253231}
    254232
    255 
    256 Void TComPicYuv::getLumaMinMax( Int *pMin, Int *pMax )
    257 {
    258   Pel*  piY   = getLumaAddr();
    259   Int   iMin  = (1<<(g_uiBitDepth))-1;
    260   Int   iMax  = 0;
    261   Int   x, y;
    262  
    263   for ( y = 0; y < m_iPicHeight; y++ )
    264   {
    265     for ( x = 0; x < m_iPicWidth; x++ )
    266     {
    267       if ( piY[x] < iMin ) iMin = piY[x];
    268       if ( piY[x] > iMax ) iMax = piY[x];
    269     }
    270     piY += getStride();
    271   }
    272  
    273   *pMin = iMin;
    274   *pMax = iMax;
    275 }
    276 
    277233Void TComPicYuv::extendPicBorder ()
    278234{
     
    316272
    317273
    318 Void TComPicYuv::dump (char* pFileName, Bool bAdd)
     274Void TComPicYuv::dump (Char* pFileName, Bool bAdd)
    319275{
    320276  FILE* pFile;
     
    328284  }
    329285 
    330   Int     shift = g_uiBitIncrement;
     286  Int     shift = g_bitDepthY-8;
    331287  Int     offset = (shift>0)?(1<<(shift-1)):0;
    332288 
     
    338294  Pel*  piCr  = getCrAddr();
    339295 
    340   Pel  iMax = ((1<<(g_uiBitDepth))-1);
    341  
    342296  for ( y = 0; y < m_iPicHeight; y++ )
    343297  {
    344298    for ( x = 0; x < m_iPicWidth; x++ )
    345299    {
    346       uc = (UChar)Clip3<Pel>(0, iMax, (piY[x]+offset)>>shift);
     300      uc = (UChar)Clip3<Pel>(0, 255, (piY[x]+offset)>>shift);
    347301     
    348302      fwrite( &uc, sizeof(UChar), 1, pFile );
     
    351305  }
    352306 
     307  shift = g_bitDepthC-8;
     308  offset = (shift>0)?(1<<(shift-1)):0;
     309
    353310  for ( y = 0; y < m_iPicHeight >> 1; y++ )
    354311  {
    355312    for ( x = 0; x < m_iPicWidth >> 1; x++ )
    356313    {
    357       uc = (UChar)Clip3<Pel>(0, iMax, (piCb[x]+offset)>>shift);
     314      uc = (UChar)Clip3<Pel>(0, 255, (piCb[x]+offset)>>shift);
    358315      fwrite( &uc, sizeof(UChar), 1, pFile );
    359316    }
     
    365322    for ( x = 0; x < m_iPicWidth >> 1; x++ )
    366323    {
    367       uc = (UChar)Clip3<Pel>(0, iMax, (piCr[x]+offset)>>shift);
     324      uc = (UChar)Clip3<Pel>(0, 255, (piCr[x]+offset)>>shift);
    368325      fwrite( &uc, sizeof(UChar), 1, pFile );
    369326    }
     
    374331}
    375332
    376 #if FIXED_ROUNDING_FRAME_MEMORY
    377 Void TComPicYuv::xFixedRoundingPic()
    378 {
    379   Int   x, y;
    380   Pel*  pRec    = getLumaAddr();
    381   Int   iStride = getStride();
    382   Int   iWidth  = getWidth();
    383   Int   iHeight = getHeight();
    384 #if FULL_NBIT
    385   Int   iOffset  = ((g_uiBitDepth-8)>0)?(1<<(g_uiBitDepth-8-1)):0;
    386   Int   iMask   = (~0<<(g_uiBitDepth-8));
    387   Int   iMaxBdi = g_uiBASE_MAX<<(g_uiBitDepth-8);
    388 #else
    389   Int   iOffset  = (g_uiBitIncrement>0)?(1<<(g_uiBitIncrement-1)):0;
    390   Int   iMask   = (~0<<g_uiBitIncrement);
    391   Int   iMaxBdi = g_uiBASE_MAX<<g_uiBitIncrement;
    392 #endif
    393 
    394   for( y = 0; y < iHeight; y++ )
    395   {
    396     for( x = 0; x < iWidth; x++ )
    397     {
    398 #if IBDI_NOCLIP_RANGE
    399       pRec[x] = ( pRec[x] + iOffset ) & iMask;
    400 #else
    401       pRec[x] = ( pRec[x]+iOffset>iMaxBdi)? iMaxBdi : ((pRec[x]+iOffset) & iMask);
    402 #endif
    403     }
    404     pRec += iStride;
    405   }
    406 
    407   iHeight >>= 1;
    408   iWidth  >>= 1;
    409   iStride >>= 1;
    410   pRec  = getCbAddr();
    411 
    412   for( y = 0; y < iHeight; y++ )
    413   {
    414     for( x = 0; x < iWidth; x++ )
    415     {
    416 #if IBDI_NOCLIP_RANGE
    417       pRec[x] = ( pRec[x] + iOffset ) & iMask;
    418 #else
    419       pRec[x] = ( pRec[x]+iOffset>iMaxBdi)? iMaxBdi : ((pRec[x]+iOffset) & iMask);
    420 #endif
    421     }
    422     pRec += iStride;
    423   }
    424 
    425   pRec  = getCrAddr();
    426 
    427   for( y = 0; y < iHeight; y++ )
    428   {
    429     for( x = 0; x < iWidth; x++ )
    430     {
    431 #if IBDI_NOCLIP_RANGE
    432       pRec[x] = ( pRec[x] + iOffset ) & iMask;
    433 #else
    434       pRec[x] = ( pRec[x]+iOffset>iMaxBdi)? iMaxBdi : ((pRec[x]+iOffset) & iMask);
    435 #endif
    436     }
    437     pRec += iStride;
    438   }
    439 }
    440 #endif
    441 
     333#if H_3D
     334#if H_3D_IV_MERGE
    442335Void
    443336TComPicYuv::getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY )
     
    465358  riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
    466359}
    467 
     360#endif
    468361Void TComPicYuv::setLumaTo( Pel pVal )
    469362{
     
    488381  }
    489382}
    490 #if QC_ARP_D0177
    491 Void  TComPicYuv::clearPic()
    492 {
    493   ::memset ( m_apiPicBufY, 0 , sizeof (Pel) * ( m_iPicWidth       + (m_iLumaMarginX   << 1)) * ( m_iPicHeight       + (m_iLumaMarginY   << 1)) );
    494   ::memset ( m_apiPicBufU, 0 , sizeof (Pel) * ((m_iPicWidth >> 1) + (m_iChromaMarginX << 1)) * ((m_iPicHeight >> 1) + (m_iChromaMarginY << 1)) );
    495   ::memset ( m_apiPicBufV, 0 , sizeof (Pel) * ((m_iPicWidth >> 1) + (m_iChromaMarginX << 1)) * ((m_iPicHeight >> 1) + (m_iChromaMarginY << 1)) );
    496 }
    497383#endif
     384
    498385//! \}
Note: See TracChangeset for help on using the changeset viewer.