Skip to content
Snippets Groups Projects
Commit 9ba02d57 authored by Frank Bossen's avatar Frank Bossen Committed by Xiang Li
Browse files

Clean up SIMD interpolation filter code and add support of horizontal 6-tap filter

parent d73d7881
No related branches found
No related tags found
1 merge request!2259Clean up SIMD interpolation filter code and add support of horizontal 6-tap filter
...@@ -54,27 +54,6 @@ CacheModel* InterpolationFilter::m_cacheModel; ...@@ -54,27 +54,6 @@ CacheModel* InterpolationFilter::m_cacheModel;
// ==================================================================================================================== // ====================================================================================================================
// Tables // Tables
// ==================================================================================================================== // ====================================================================================================================
// TODO: implement 6-tap horizontal filtering in SIMD code such that m_affineLumaFilter can be used instead of m_lumaFilter4x4
const TFilterCoeff InterpolationFilter::m_lumaFilter4x4[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA] =
{
{ 0, 0, 0, 64, 0, 0, 0, 0 },
{ 0, 1, -3, 63, 4, -2, 1, 0 },
{ 0, 1, -5, 62, 8, -3, 1, 0 },
{ 0, 2, -8, 60, 13, -4, 1, 0 },
{ 0, 3, -10, 58, 17, -5, 1, 0 }, //1/4
{ 0, 3, -11, 52, 26, -8, 2, 0 },
{ 0, 2, -9, 47, 31, -10, 3, 0 },
{ 0, 3, -11, 45, 34, -10, 3, 0 },
{ 0, 3, -11, 40, 40, -11, 3, 0 }, //1/2
{ 0, 3, -10, 34, 45, -11, 3, 0 },
{ 0, 3, -10, 31, 47, -9, 2, 0 },
{ 0, 2, -8, 26, 52, -11, 3, 0 },
{ 0, 1, -5, 17, 58, -10, 3, 0 }, //3/4
{ 0, 1, -4, 13, 60, -8, 2, 0 },
{ 0, 1, -3, 8, 62, -5, 1, 0 },
{ 0, 1, -2, 4, 63, -3, 1, 0 }
};
// clang-format off // clang-format off
const TFilterCoeff InterpolationFilter::m_affineLumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA] = const TFilterCoeff InterpolationFilter::m_affineLumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA] =
{ {
...@@ -355,6 +334,11 @@ InterpolationFilter::InterpolationFilter() ...@@ -355,6 +334,11 @@ InterpolationFilter::InterpolationFilter()
m_filterHor[2][1][0] = filter<2, false, true, false>; m_filterHor[2][1][0] = filter<2, false, true, false>;
m_filterHor[2][1][1] = filter<2, false, true, true>; m_filterHor[2][1][1] = filter<2, false, true, true>;
m_filterHor[3][0][0] = filter<6, false, false, false>;
m_filterHor[3][0][1] = filter<6, false, false, true>;
m_filterHor[3][1][0] = filter<6, false, true, false>;
m_filterHor[3][1][1] = filter<6, false, true, true>;
m_filterVer[0][0][0] = filter<8, true, false, false>; m_filterVer[0][0][0] = filter<8, true, false, false>;
m_filterVer[0][0][1] = filter<8, true, false, true>; m_filterVer[0][0][1] = filter<8, true, false, true>;
m_filterVer[0][1][0] = filter<8, true, true, false>; m_filterVer[0][1][0] = filter<8, true, true, false>;
...@@ -406,7 +390,8 @@ InterpolationFilter::InterpolationFilter() ...@@ -406,7 +390,8 @@ InterpolationFilter::InterpolationFilter()
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<bool isFirst, bool isLast> template<bool isFirst, bool isLast>
void InterpolationFilter::filterCopy( const ClpRng& clpRng, const Pel *src, int srcStride, Pel *dst, int dstStride, int width, int height, bool biMCForDMVR) void InterpolationFilter::filterCopy(const ClpRng &clpRng, const Pel *src, const ptrdiff_t srcStride, Pel *dst,
const ptrdiff_t dstStride, int width, int height, bool biMCForDMVR)
{ {
int row, col; int row, col;
...@@ -553,7 +538,9 @@ void InterpolationFilter::filterCopy( const ClpRng& clpRng, const Pel *src, int ...@@ -553,7 +538,9 @@ void InterpolationFilter::filterCopy( const ClpRng& clpRng, const Pel *src, int
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<int N, bool isVertical, bool isFirst, bool isLast> template<int N, bool isVertical, bool isFirst, bool isLast>
void InterpolationFilter::filter(const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR) void InterpolationFilter::filter(const ClpRng &clpRng, Pel const *src, const ptrdiff_t srcStride, Pel *dst,
const ptrdiff_t dstStride, int width, int height, TFilterCoeff const *coeff,
bool biMCForDMVR)
{ {
int row, col; int row, col;
...@@ -576,7 +563,7 @@ void InterpolationFilter::filter(const ClpRng& clpRng, Pel const *src, int srcSt ...@@ -576,7 +563,7 @@ void InterpolationFilter::filter(const ClpRng& clpRng, Pel const *src, int srcSt
c[7] = coeff[7]; c[7] = coeff[7];
} }
int cStride = ( isVertical ) ? srcStride : 1; const ptrdiff_t cStride = (isVertical) ? srcStride : 1;
src -= ( N/2 - 1 ) * cStride; src -= ( N/2 - 1 ) * cStride;
int offset; int offset;
...@@ -662,15 +649,19 @@ static constexpr int tapToIdx(const int N) ...@@ -662,15 +649,19 @@ static constexpr int tapToIdx(const int N)
} }
template<int N> template<int N>
void InterpolationFilter::filterHor(const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, bool isLast, TFilterCoeff const *coeff, bool biMCForDMVR) void InterpolationFilter::filterHor(const ClpRng &clpRng, Pel const *src, const ptrdiff_t srcStride, Pel *dst,
const ptrdiff_t dstStride, int width, int height, bool isLast,
TFilterCoeff const *coeff, bool biMCForDMVR)
{ {
constexpr int IDX = tapToIdx(N); constexpr int IDX = tapToIdx(N);
static_assert(IDX < 3, "Unsupported tap count"); static_assert(IDX < 4, "Unsupported tap count");
m_filterHor[IDX][1][isLast](clpRng, src, srcStride, dst, dstStride, width, height, coeff, biMCForDMVR); m_filterHor[IDX][1][isLast](clpRng, src, srcStride, dst, dstStride, width, height, coeff, biMCForDMVR);
} }
template<int N> template<int N>
void InterpolationFilter::filterVer(const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, bool isFirst, bool isLast, TFilterCoeff const *coeff, bool biMCForDMVR) void InterpolationFilter::filterVer(const ClpRng &clpRng, Pel const *src, const ptrdiff_t srcStride, Pel *dst,
const ptrdiff_t dstStride, int width, int height, bool isFirst, bool isLast,
TFilterCoeff const *coeff, bool biMCForDMVR)
{ {
constexpr int IDX = tapToIdx(N); constexpr int IDX = tapToIdx(N);
static_assert(IDX < 4, "Unsupported tap count"); static_assert(IDX < 4, "Unsupported tap count");
...@@ -681,9 +672,9 @@ void InterpolationFilter::filterVer(const ClpRng& clpRng, Pel const *src, int sr ...@@ -681,9 +672,9 @@ void InterpolationFilter::filterVer(const ClpRng& clpRng, Pel const *src, int sr
// Public member functions // Public member functions
// ==================================================================================================================== // ====================================================================================================================
void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, int srcStride, Pel *dst, int dstStride, void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, const ptrdiff_t srcStride, Pel *dst,
int width, int height, int frac, bool isLast, const ClpRng &clpRng, int nFilterIdx, const ptrdiff_t dstStride, int width, int height, int frac, bool isLast,
bool useAltHpelIf) const ClpRng &clpRng, int nFilterIdx, bool useAltHpelIf)
{ {
const bool biMCForDMVR = nFilterIdx == FILTER_DMVR; const bool biMCForDMVR = nFilterIdx == FILTER_DMVR;
...@@ -700,7 +691,8 @@ void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, in ...@@ -700,7 +691,8 @@ void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, in
} }
else if (nFilterIdx == FILTER_AFFINE) else if (nFilterIdx == FILTER_AFFINE)
{ {
filterHor<NTAPS_LUMA>( clpRng, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter4x4[frac], biMCForDMVR ); filterHor<NTAPS_LUMA_AFFINE>(clpRng, src, srcStride, dst, dstStride, width, height, isLast,
m_affineLumaFilter[frac], biMCForDMVR);
} }
else if (nFilterIdx == FILTER_RPR1) else if (nFilterIdx == FILTER_RPR1)
{ {
...@@ -748,9 +740,9 @@ void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, in ...@@ -748,9 +740,9 @@ void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, in
} }
} }
void InterpolationFilter::filterVer(const ComponentID compID, Pel const *src, int srcStride, Pel *dst, int dstStride, void InterpolationFilter::filterVer(const ComponentID compID, Pel const *src, const ptrdiff_t srcStride, Pel *dst,
int width, int height, int frac, bool isFirst, bool isLast, const ClpRng &clpRng, const ptrdiff_t dstStride, int width, int height, int frac, bool isFirst,
int nFilterIdx, bool useAltHpelIf) bool isLast, const ClpRng &clpRng, int nFilterIdx, bool useAltHpelIf)
{ {
const bool biMCForDMVR = nFilterIdx == FILTER_DMVR; const bool biMCForDMVR = nFilterIdx == FILTER_DMVR;
......
...@@ -56,7 +56,6 @@ static inline int IF_INTERNAL_FRAC_BITS(const int bd) { return std::max(2, IF_IN ...@@ -56,7 +56,6 @@ static inline int IF_INTERNAL_FRAC_BITS(const int bd) { return std::max(2, IF_IN
*/ */
class InterpolationFilter class InterpolationFilter
{ {
static const TFilterCoeff m_lumaFilter4x4[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA];
static const TFilterCoeff m_affineLumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA]; static const TFilterCoeff m_affineLumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA];
public: public:
...@@ -73,15 +72,19 @@ private: ...@@ -73,15 +72,19 @@ private:
static const TFilterCoeff m_bilinearFilterPrec4[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_BILINEAR]; ///< bilinear filter taps static const TFilterCoeff m_bilinearFilterPrec4[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_BILINEAR]; ///< bilinear filter taps
public: public:
template<bool isFirst, bool isLast> template<bool isFirst, bool isLast>
static void filterCopy( const ClpRng& clpRng, const Pel *src, int srcStride, Pel *dst, int dstStride, int width, int height, bool biMCForDMVR); static void filterCopy(const ClpRng &clpRng, const Pel *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride,
int width, int height, bool biMCForDMVR);
template<int N, bool isVertical, bool isFirst, bool isLast> template<int N, bool isVertical, bool isFirst, bool isLast>
static void filter(const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR); static void filter(const ClpRng &clpRng, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride,
int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR);
template<int N> template<int N>
void filterHor(const ClpRng& clpRng, Pel const* src, int srcStride, Pel *dst, int dstStride, int width, int height, bool isLast, TFilterCoeff const *coeff, bool biMCForDMVR); void filterHor(const ClpRng &clpRng, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride, int width,
int height, bool isLast, TFilterCoeff const *coeff, bool biMCForDMVR);
template<int N> template<int N>
void filterVer(const ClpRng& clpRng, Pel const* src, int srcStride, Pel *dst, int dstStride, int width, int height, bool isFirst, bool isLast, TFilterCoeff const *coeff, bool biMCForDMVR); void filterVer(const ClpRng &clpRng, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride, int width,
int height, bool isFirst, bool isLast, TFilterCoeff const *coeff, bool biMCForDMVR);
static void xWeightedGeoBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); static void xWeightedGeoBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1);
void weightedGeoBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); void weightedGeoBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1);
...@@ -103,10 +106,12 @@ public: ...@@ -103,10 +106,12 @@ public:
InterpolationFilter(); InterpolationFilter();
~InterpolationFilter() {} ~InterpolationFilter() {}
void( *m_filterHor[3][2][2] )( const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR); void (*m_filterHor[4][2][2])(const ClpRng &clpRng, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride,
void (*m_filterVer[4][2][2])(const ClpRng &clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR);
int height, TFilterCoeff const *coeff, bool biMCForDMVR); void (*m_filterVer[4][2][2])(const ClpRng &clpRng, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride,
void( *m_filterCopy[2][2] ) ( const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, bool biMCForDMVR); int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR);
void (*m_filterCopy[2][2])(const ClpRng &clpRng, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride,
int width, int height, bool biMCForDMVR);
void( *m_weightedGeoBlk )(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); void( *m_weightedGeoBlk )(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1);
void initInterpolationFilter( bool enable ); void initInterpolationFilter( bool enable );
...@@ -115,12 +120,12 @@ public: ...@@ -115,12 +120,12 @@ public:
template <X86_VEXT vext> template <X86_VEXT vext>
void _initInterpolationFilterX86(); void _initInterpolationFilterX86();
#endif #endif
void filterHor(const ComponentID compID, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, void filterHor(const ComponentID compID, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride,
int height, int frac, bool isLast, const ClpRng &clpRng, int nFilterIdx = FILTER_DEFAULT, int width, int height, int frac, bool isLast, const ClpRng &clpRng, int nFilterIdx = FILTER_DEFAULT,
bool useAltHpelIf = false);
void filterVer(const ComponentID compID, Pel const *src, int srcStride, Pel *dst, int dstStride, int width,
int height, int frac, bool isFirst, bool isLast, const ClpRng &clpRng, int nFilterIdx = FILTER_DEFAULT,
bool useAltHpelIf = false); bool useAltHpelIf = false);
void filterVer(const ComponentID compID, Pel const *src, ptrdiff_t srcStride, Pel *dst, ptrdiff_t dstStride,
int width, int height, int frac, bool isFirst, bool isLast, const ClpRng &clpRng,
int nFilterIdx = FILTER_DEFAULT, bool useAltHpelIf = false);
#if JVET_J0090_MEMORY_BANDWITH_MEASURE #if JVET_J0090_MEMORY_BANDWITH_MEASURE
void cacheAssign( CacheModel *cache ) { m_cacheModel = cache; } void cacheAssign( CacheModel *cache ) { m_cacheModel = cache; }
#endif #endif
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment