History

[Processing/x86] Add an SSE4.1 implementation of GeneralBilinearAccurateDownsample

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.

Sindre Aamås committed 10 years ago

Commit b1013091 parent 1995e035 files · +455 −0Browse 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 +1 −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+1−0
@@ -107,6 +107,7 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 106 unmodified lines
107 sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse4;107 sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse4;
108 sDownsampleFunc.pfOneThirdDownsampler = DyadicBilinearOneThirdDownsampler_sse4;108 sDownsampleFunc.pfOneThirdDownsampler = DyadicBilinearOneThirdDownsampler_sse4;
109 sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_sse4;109 sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_sse4;
110 sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse41;
110 }111 }
111#endif//X86_ASM112#endif//X86_ASM
112 113
codec/processing/src/downsample/downsample.h+4−0
@@ -102,6 +102,7 @@ HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_sse4; · 101 unmodified lines
102GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2;102GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2;
103GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2;103GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2;
104GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_ssse3;104GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_ssse3;
105GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse41;
105 106
106SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_ssse3;107SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_ssse3;
107SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_sse4;108SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_sse4;
@@ -118,6 +119,9 @@ void GeneralBilinearAccurateDownsampler_sse2 (uint8_t* pDst, const int32_t kiDst · 10 unmodified lines
118void GeneralBilinearFastDownsampler_ssse3 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth,119void GeneralBilinearFastDownsampler_ssse3 (uint8_t* pDst, int32_t iDstStride, int32_t iDstWidth,
119 int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX,120 int32_t iDstHeight, uint8_t* pSrc, int32_t iSrcStride, uint32_t uiScaleX,
120 uint32_t uiScaleY);121 uint32_t uiScaleY);
122void 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
122WELSVP_EXTERN_C_END126WELSVP_EXTERN_C_END
123#endif127#endif
codec/processing/src/downsample/downsamplefuncs.cpp+1−0
@@ -283,6 +283,7 @@ static void GeneralBilinearDownsamplerWrap (uint8_t* pDst, const int32_t kiDstSt · 282 unmodified lines
283DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (sse2)283DEFINE_GENERAL_BILINEAR_FAST_DOWNSAMPLER_WRAP (sse2)
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)
286#endif //X86_ASM287#endif //X86_ASM
287 288
288#ifdef HAVE_NEON289#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