Keep track of relative pixel offsets and utilize pshufb to efficiently extract relevant pixels for horizontal scaling ratios <= 4. Fall back to a generic approach for ratios > 4. The use of blendps makes this require SSE4.1. The pshufb path can be backported to SSSE3 and the generic path to SSE2 for a minor reduction in performance by replacing blendps and preceding instructions with an equivalent sequence. 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 ~5.32x/~4.25x (32-bit/64-bit) for horizontal ratios <= 2, ~5.06x/~3.97x for ratios within (2, 4], and ~3.93x/~3.13x for ratios > 4 when not memory-bound on Haswell as compared with the current SSE2 implementation.
Showing the changes to codec/processing/src/downsample/downsample.h (1 of 5 files). Show all
Unified · Split
| @@ -102,6 +102,7 @@ HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_sse4; · 101 unmodified lines | ||
| 102 | 102 | GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2; |
| 103 | 103 | GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2; |
| 104 | 104 | GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_ssse3; |
| 105 | +GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse41; | |
| 105 | 106 | |
| 106 | 107 | SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_ssse3; |
| 107 | 108 | SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_sse4; |
| @@ -118,6 +119,9 @@ void GeneralBilinearAccurateDownsampler_sse2 (uint8_t* pDst, const int32_t kiDst · 10 unmodified lines | ||
| 118 | 119 | void GeneralBilinearFastDownsampler_ssse3 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth, |
| 119 | 120 | int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX, |
| 120 | 121 | uint32_t uiScaleY); |
| 122 | +void 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 | + uint32_t uiScaleY); | |
| 121 | 125 | |
| 122 | 126 | WELSVP_EXTERN_C_END |
| 123 | 127 | #endif |