Ignore:
Timestamp:
4 May 2015, 18:38:08 (9 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/TComInterpolationFilter.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. 
    5  *
    6 * Copyright (c) 2010-2015, ITU/ISO/IEC
     4 * granted under this license.
     5 *
     6 * Copyright (c) 2010-2015, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4545#include <assert.h>
    4646
     47#include "TComChromaFormat.h"
     48
    4749
    4850//! \ingroup TLibCommon
     
    5355// ====================================================================================================================
    5456
    55 const Short TComInterpolationFilter::m_lumaFilter[4][NTAPS_LUMA] =
     57const TFilterCoeff TComInterpolationFilter::m_lumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA] =
    5658{
    5759  {  0, 0,   0, 64,  0,   0, 0,  0 },
     
    6163};
    6264
    63 const Short TComInterpolationFilter::m_chromaFilter[8][NTAPS_CHROMA] =
     65const TFilterCoeff TComInterpolationFilter::m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA] =
    6466{
    6567  {  0, 64,  0,  0 },
     
    111113 * \param isLast     Flag indicating whether it is the last filtering operation
    112114 */
    113 Void TComInterpolationFilter::filterCopy(Int bitDepth, const Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast)
     115Void TComInterpolationFilter::filterCopy(Int bitDepth, const Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast)
    114116{
    115117  Int row, col;
    116  
     118
    117119  if ( isFirst == isLast )
    118120  {
     
    123125        dst[col] = src[col];
    124126      }
    125      
     127
    126128      src += srcStride;
    127129      dst += dstStride;
    128     }             
     130    }
    129131  }
    130132  else if ( isFirst )
    131133  {
    132     Int shift = IF_INTERNAL_PREC - bitDepth;
    133    
     134    const Int shift = std::max<Int>(2, (IF_INTERNAL_PREC - bitDepth));
     135
    134136    for (row = 0; row < height; row++)
    135137    {
    136138      for (col = 0; col < width; col++)
    137139      {
    138         Short val = src[col] << shift;
    139         dst[col] = val - (Short)IF_INTERNAL_OFFS;
    140       }
    141      
     140        Pel val = leftShift_round(src[col], shift);
     141        dst[col] = val - (Pel)IF_INTERNAL_OFFS;
     142      }
     143
    142144      src += srcStride;
    143145      dst += dstStride;
    144     }         
    145   }
    146   else
    147   {
    148     Int shift = IF_INTERNAL_PREC - bitDepth;
    149     Short offset = IF_INTERNAL_OFFS;
    150     offset += shift?(1 << (shift - 1)):0;
    151     Short maxVal = (1 << bitDepth) - 1;
    152     Short minVal = 0;
     146    }
     147  }
     148  else
     149  {
     150    const Int shift = std::max<Int>(2, (IF_INTERNAL_PREC - bitDepth));
     151
     152    Pel maxVal = (1 << bitDepth) - 1;
     153    Pel minVal = 0;
    153154    for (row = 0; row < height; row++)
    154155    {
    155156      for (col = 0; col < width; col++)
    156157      {
    157         Short val = src[ col ];
    158         val = ( val + offset ) >> shift;
    159         if (val < minVal) val = minVal;
    160         if (val > maxVal) val = maxVal;
     158        Pel val = src[ col ];
     159        val = rightShift_round((val + IF_INTERNAL_OFFS), shift);
     160        if (val < minVal)
     161        {
     162          val = minVal;
     163        }
     164        if (val > maxVal)
     165        {
     166          val = maxVal;
     167        }
    161168        dst[col] = val;
    162169      }
    163      
     170
    164171      src += srcStride;
    165172      dst += dstStride;
    166     }             
     173    }
    167174  }
    168175}
     
    185192 */
    186193template<Int N, Bool isVertical, Bool isFirst, Bool isLast>
    187 Void TComInterpolationFilter::filter(Int bitDepth, Short const *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Short const *coeff)
     194Void TComInterpolationFilter::filter(Int bitDepth, Pel const *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, TFilterCoeff const *coeff)
    188195{
    189196  Int row, col;
    190  
    191   Short c[8];
     197
     198  Pel c[8];
    192199  c[0] = coeff[0];
    193200  c[1] = coeff[1];
     
    207214    c[7] = coeff[7];
    208215  }
    209  
     216
    210217  Int cStride = ( isVertical ) ? srcStride : 1;
    211218  src -= ( N/2 - 1 ) * cStride;
    212219
    213220  Int offset;
    214   Short maxVal;
    215   Int headRoom = IF_INTERNAL_PREC - bitDepth;
    216   Int shift = IF_FILTER_PREC;
     221  Pel maxVal;
     222  Int headRoom = std::max<Int>(2, (IF_INTERNAL_PREC - bitDepth));
     223  Int shift    = IF_FILTER_PREC;
     224  // with the current settings (IF_INTERNAL_PREC = 14 and IF_FILTER_PREC = 6), though headroom can be
     225  // negative for bit depths greater than 14, shift will remain non-negative for bit depths of 8->20
     226  assert(shift >= 0);
     227
    217228  if ( isLast )
    218229  {
     
    228239    maxVal = 0;
    229240  }
    230  
     241
    231242  for (row = 0; row < height; row++)
    232243  {
     
    234245    {
    235246      Int sum;
    236      
     247
    237248      sum  = src[ col + 0 * cStride] * c[0];
    238249      sum += src[ col + 1 * cStride] * c[1];
     
    250261      {
    251262        sum += src[ col + 6 * cStride] * c[6];
    252         sum += src[ col + 7 * cStride] * c[7];       
    253       }
    254      
    255       Short val = ( sum + offset ) >> shift;
     263        sum += src[ col + 7 * cStride] * c[7];
     264      }
     265
     266      Pel val = ( sum + offset ) >> shift;
    256267      if ( isLast )
    257268      {
    258269        val = ( val < 0 ) ? 0 : val;
    259         val = ( val > maxVal ) ? maxVal : val;       
     270        val = ( val > maxVal ) ? maxVal : val;
    260271      }
    261272      dst[col] = val;
    262273    }
    263    
     274
    264275    src += srcStride;
    265276    dst += dstStride;
    266   }   
     277  }
    267278}
    268279
     
    282293 */
    283294template<Int N>
    284 Void TComInterpolationFilter::filterHor(Int bitDepth, Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Bool isLast, Short const *coeff)
     295Void TComInterpolationFilter::filterHor(Int bitDepth, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isLast, TFilterCoeff const *coeff)
    285296{
    286297  if ( isLast )
     
    298309 *
    299310 * \tparam N          Number of taps
    300  * \param  bitDpeth   Sample bit depth
     311 * \param  bitDepth   Bit depth
    301312 * \param  src        Pointer to source samples
    302313 * \param  srcStride  Stride of source samples
     
    310321 */
    311322template<Int N>
    312 Void TComInterpolationFilter::filterVer(Int bitDepth, Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast, Short const *coeff)
     323Void TComInterpolationFilter::filterVer(Int bitDepth, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Bool isFirst, Bool isLast, TFilterCoeff const *coeff)
    313324{
    314325  if ( isFirst && isLast )
     
    327338  {
    328339    filter<N, true, false, false>(bitDepth, src, srcStride, dst, dstStride, width, height, coeff);
    329   }     
     340  }
    330341}
    331342
     
    335346
    336347/**
    337  * \brief Filter a block of luma samples (horizontal)
    338  *
     348 * \brief Filter a block of Luma/Chroma samples (horizontal)
     349 *
     350 * \param  compID     Chroma component ID
    339351 * \param  src        Pointer to source samples
    340352 * \param  srcStride  Stride of source samples
     
    345357 * \param  frac       Fractional sample offset
    346358 * \param  isLast     Flag indicating whether it is the last filtering operation
    347  */
    348 Void TComInterpolationFilter::filterHorLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast
     359 * \param  fmt        Chroma format
     360 * \param  bitDepth   Bit depth
     361 */
     362Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt, const Int bitDepth
    349363#if H_3D_ARP
    350364    , Bool filterType
    351365#endif
    352   )
    353 {
    354   assert(frac >= 0 && frac < 4);
    355  
     366)
     367{
    356368  if ( frac == 0 )
    357369  {
    358     filterCopy(g_bitDepthY, src, srcStride, dst, dstStride, width, height, true, isLast );
    359   }
    360   else
     370    filterCopy(bitDepth, src, srcStride, dst, dstStride, width, height, true, isLast );
     371  }
     372  else if (isLuma(compID))
    361373  {
    362374#if H_3D_ARP
     
    368380    {
    369381#endif
    370     filterHor<NTAPS_LUMA>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
    371 #if H_3D_ARP
    372     }
    373 #endif
    374   }
    375 }
    376 
    377 /**
    378  * \brief Filter a block of luma samples (vertical)
    379  *
     382
     383    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     384    filterHor<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
     385#if H_3D_ARP
     386    }
     387#endif
     388
     389  }
     390  else
     391  {
     392    const UInt csx = getComponentScaleX(compID, fmt);
     393    assert(frac >=0 && csx<2 && (frac<<(1-csx)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     394    filterHor<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
     395  }
     396}
     397
     398
     399/**
     400 * \brief Filter a block of Luma/Chroma samples (vertical)
     401 *
     402 * \param  compID     Colour component ID
    380403 * \param  src        Pointer to source samples
    381404 * \param  srcStride  Stride of source samples
     
    387410 * \param  isFirst    Flag indicating whether it is the first filtering operation
    388411 * \param  isLast     Flag indicating whether it is the last filtering operation
    389  */
    390 Void TComInterpolationFilter::filterVerLuma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
     412 * \param  fmt        Chroma format
     413 * \param  bitDepth   Bit depth
     414 */
     415Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth
    391416#if H_3D_ARP
    392417    , Bool filterType
    393418#endif
    394   )
    395 {
    396   assert(frac >= 0 && frac < 4);
    397  
     419)
     420{
    398421  if ( frac == 0 )
    399422  {
    400     filterCopy(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isFirst, isLast );
    401   }
    402   else
     423    filterCopy(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast );
     424  }
     425  else if (isLuma(compID))
    403426  {
    404427#if H_3D_ARP
     
    410433    {
    411434#endif
    412     filterVer<NTAPS_LUMA>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
    413 #if H_3D_ARP
    414     }
    415 #endif
    416   }
    417 }
    418 
    419 /**
    420  * \brief Filter a block of chroma samples (horizontal)
    421  *
    422  * \param  src        Pointer to source samples
    423  * \param  srcStride  Stride of source samples
    424  * \param  dst        Pointer to destination samples
    425  * \param  dstStride  Stride of destination samples
    426  * \param  width      Width of block
    427  * \param  height     Height of block
    428  * \param  frac       Fractional sample offset
    429  * \param  isLast     Flag indicating whether it is the last filtering operation
    430  */
    431 Void TComInterpolationFilter::filterHorChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast
     435    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     436    filterVer<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
     437#if H_3D_ARP
     438    }
     439#endif
     440
     441  }
     442  else
     443  {
     444    const UInt csy = getComponentScaleY(compID, fmt);
     445    assert(frac >=0 && csy<2 && (frac<<(1-csy)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     446    filterVer<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac<<(1-csy)]);
     447  }
     448}
     449
    432450#if H_3D_ARP
    433451    , Bool filterType
    434452#endif
    435   )
    436 {
    437   assert(frac >= 0 && frac < 8);
    438  
    439   if ( frac == 0 )
    440   {
    441     filterCopy(g_bitDepthC, src, srcStride, dst, dstStride, width, height, true, isLast );
    442   }
    443   else
    444   {
     453
    445454#if H_3D_ARP
    446455    if(filterType)
     
    451460    {
    452461#endif
    453     filterHor<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac]);
    454 #if H_3D_ARP
    455     }
    456 #endif
    457   }
    458 }
    459 
    460 /**
    461  * \brief Filter a block of chroma samples (vertical)
    462  *
    463  * \param  src        Pointer to source samples
    464  * \param  srcStride  Stride of source samples
    465  * \param  dst        Pointer to destination samples
    466  * \param  dstStride  Stride of destination samples
    467  * \param  width      Width of block
    468  * \param  height     Height of block
    469  * \param  frac       Fractional sample offset
    470  * \param  isFirst    Flag indicating whether it is the first filtering operation
    471  * \param  isLast     Flag indicating whether it is the last filtering operation
    472  */
    473 Void TComInterpolationFilter::filterVerChroma(Pel *src, Int srcStride, Short *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast
     462#if H_3D_ARP
     463    }
     464#endif
    474465#if H_3D_ARP
    475466    , Bool filterType
    476467#endif
    477   )
    478 {
    479   assert(frac >= 0 && frac < 8);
    480  
    481   if ( frac == 0 )
    482   {
    483     filterCopy(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast );
    484   }
    485   else
    486   {
    487468#if H_3D_ARP
    488469    if(filterType)
     
    493474    {
    494475#endif
    495     filterVer<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac]);
    496 #if H_3D_ARP
    497     }
    498 #endif
    499   }
    500 }
     476#if H_3D_ARP
     477    }
     478#endif
     479
     480
    501481
    502482//! \}
Note: See TracChangeset for help on using the changeset viewer.