History

[Processing/x86] Add an AVX2 implementation of GeneralBilinearFastDownsample

Keep track of relative pixel offsets and utilize pshufb to efficiently extract relevant pixels for horizontal scaling ratios <= 8. Because pshufb does not cross 128-bit lanes, the overhead of address calculations and loads is relatively greater as compared with an SSSE3 implementation. Fall back to a generic approach for ratios > 8. The implementation assumes that data beyond the end of each line, before the next line begins, can be dirtied; which AFAICT is safe with the current usage of these routines. Speedup is ~10.42x/~5.23x (32-bit/64-bit) for horizontal ratios <= 2, ~9.49x/~4.64x for ratios within (2, 4], ~6.43x/~3.18x for ratios within (4, 8], and ~5.42x/~2.50x for ratios > 8 when not memory-bound on Haswell as compared with the current SSE2 implementation.

Sindre Aamås committed 10 years ago

Commit b43e58a1 parent b1013095 files · +709 −8Browse files

Showing the changes to codec/processing/src/downsample (3 of 5 files). Show all

Unified · Split

3 files
  1. codec/processing/src/downsample/downsample.cpp +3 −0
  2. codec/processing/src/downsample/downsample.h +4 −0
  3. codec/processing/src/downsample/downsamplefuncs.cpp +1 −0
codec/processing/src/downsample/downsample.cpp+3−0
@@ -109,6 +109,9 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 108 unmodified lines
109 sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_sse4;109 sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_sse4;
110 sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse41;110 sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse41;
111 }111 }
112 if (iCpuFlag & WELS_CPU_AVX2) {
113 sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsamplerWrap_avx2;
114 }
112#endif//X86_ASM115#endif//X86_ASM
113 116
114#if defined(HAVE_NEON)117#if defined(HAVE_NEON)
codec/processing/src/downsample/downsample.h+4−0
@@ -103,6 +103,7 @@ GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2; · 102 unmodified lines
103GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2;103GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2;
104GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_ssse3;104GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_ssse3;
105GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse41;105GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse41;
106GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_avx2;
106 107
107SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_ssse3;108SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_ssse3;
108SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_sse4;109SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_sse4;
@@ -122,6 +123,9 @@ void GeneralBilinearFastDownsampler_ssse3 (uint8_t* pDst, int32_t iDstStride, in · 13 unmodified lines
122void GeneralBilinearAccurateDownsampler_sse41 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth,123void GeneralBilinearAccurateDownsampler_sse41 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth,
123 int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX,124 int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX,
124 uint32_t uiScaleY);125 uint32_t uiScaleY);
126void GeneralBilinearFastDownsampler_avx2 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth,
127 int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX,
128 uint32_t uiScaleY);
125 129
126WELSVP_EXTERN_C_END130WELSVP_EXTERN_C_END
127#endif131#endif
codec/processing/src/downsample/downsamplefuncs.cpp+1−0
@@ -284,6 +284,7 @@ DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (sse2) · 283 unmodified lines
284DEFINE_GENERAL_BILINEAR_ACCURATE_DOWNSAMPLER_WRAP (sse2)284DEFINE_GENERAL_BILINEAR_ACCURATE_DOWNSAMPLER_WRAP (sse2)
285DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (ssse3)285DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (ssse3)
286DEFINE_GENERAL_BILINEAR_ACCURATE_DOWNSAMPLER_WRAP (sse41)286DEFINE_GENERAL_BILINEAR_ACCURATE_DOWNSAMPLER_WRAP (sse41)
287DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (avx2)
287#endif //X86_ASM288#endif //X86_ASM
288 289
289#ifdef HAVE_NEON290#ifdef HAVE_NEON

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t