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/SSE4.1 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 ~8.52x/~6.89x (32-bit/64-bit) for horizontal ratios <= 2, ~7.81x/~6.13x for ratios within (2, 4], ~5.81x/~4.52x for ratios within (4, 8], and ~5.06x/~4.09x for ratios > 8 when not memory-bound on Haswell as compared with the current SSE2 implementation.
Showing the changes to codec/processing/src/downsample (3 of 5 files). Show all
Unified · Split
| @@ -110,6 +110,7 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 109 unmodified lines | ||
| 110 | 110 | sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse41; |
| 111 | 111 | } |
| 112 | 112 | if (iCpuFlag & WELS_CPU_AVX2) { |
| 113 | + sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_avx2; | |
| 113 | 114 | sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsamplerWrap_avx2; |
| 114 | 115 | } |
| 115 | 116 | #endif//X86_ASM |
| @@ -104,6 +104,7 @@ GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2; · 103 unmodified lines | ||
| 104 | 104 | GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_ssse3; |
| 105 | 105 | GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse41; |
| 106 | 106 | GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_avx2; |
| 107 | +GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_avx2; | |
| 107 | 108 | |
| 108 | 109 | SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_ssse3; |
| 109 | 110 | SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_sse4; |
| @@ -126,6 +127,9 @@ void GeneralBilinearAccurateDownsampler_sse41 (uint8_t* pDst, int32_t iDstStride · 16 unmodified lines | ||
| 126 | 127 | void GeneralBilinearFastDownsampler_avx2 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth, |
| 127 | 128 | int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX, |
| 128 | 129 | uint32_t uiScaleY); |
| 130 | +void GeneralBilinearAccurateDownsampler_avx2 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth, | |
| 131 | + int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX, | |
| 132 | + uint32_t uiScaleY); | |
| 129 | 133 | |
| 130 | 134 | WELSVP_EXTERN_C_END |
| 131 | 135 | #endif |
| @@ -285,6 +285,7 @@ DEFINE_GENERAL_BILINEAR_ACCURATE_DOWNSAMPLER_WRAP (sse2) · 284 unmodified lines | ||
| 285 | 285 | DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (ssse3) |
| 286 | 286 | DEFINE_GENERAL_BILINEAR_ACCURATE_DOWNSAMPLER_WRAP (sse41) |
| 287 | 287 | DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (avx2) |
| 288 | +DEFINE_GENERAL_BILINEAR_ACCURATE_DOWNSAMPLER_WRAP (avx2) | |
| 288 | 289 | #endif //X86_ASM |
| 289 | 290 | |
| 290 | 291 | #ifdef HAVE_NEON |