summaryrefslogtreecommitdiff
path: root/libavfilter/x86/vf_gblur_init.c
diff options
context:
space:
mode:
authorWu Jianhua <jianhua.wu@intel.com>2021-08-04 10:06:15 +0800
committerPaul B Mahol <onemda@gmail.com>2021-08-29 19:58:33 +0200
commit4041c1029b93162faacda9e3f3cd083d1fbca7ce (patch)
tree0c7693b822eb51ccbef214df0be4e91a56f734f5 /libavfilter/x86/vf_gblur_init.c
parent0c54ab20c254bf26c33a5cceb83862d3a59b3db7 (diff)
libavfilter/x86/vf_gblur: add localbuf and ff_horiz_slice_avx2/512()
We introduced a ff_horiz_slice_avx2/512() implemented on a new algorithm. In a nutshell, the new algorithm does three things, gathering data from 8/16 rows, blurring data, and scattering data back to the image buffer. Here we used a customized transpose 8x8/16x16 to avoid the huge overhead brought by gather and scatter instructions, which is dependent on the temporary buffer called localbuf added newly. Performance data: ff_horiz_slice_avx2(old): 109.89 ff_horiz_slice_avx2(new): 666.67 ff_horiz_slice_avx512: 1000 Co-authored-by: Cheng Yanfei <yanfei.cheng@intel.com> Co-authored-by: Jin Jun <jun.i.jin@intel.com> Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
Diffstat (limited to 'libavfilter/x86/vf_gblur_init.c')
-rw-r--r--libavfilter/x86/vf_gblur_init.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libavfilter/x86/vf_gblur_init.c b/libavfilter/x86/vf_gblur_init.c
index 3e173410c2..b47f6fbffb 100644
--- a/libavfilter/x86/vf_gblur_init.c
+++ b/libavfilter/x86/vf_gblur_init.c
@@ -24,8 +24,9 @@
#include "libavutil/x86/cpu.h"
#include "libavfilter/gblur.h"
-void ff_horiz_slice_sse4(float *ptr, int width, int height, int steps, float nu, float bscale);
-void ff_horiz_slice_avx2(float *ptr, int width, int height, int steps, float nu, float bscale);
+void ff_horiz_slice_sse4(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf);
+void ff_horiz_slice_avx2(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf);
+void ff_horiz_slice_avx512(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf);
void ff_postscale_slice_sse(float *ptr, int length, float postscale, float min, float max);
void ff_postscale_slice_avx2(float *ptr, int length, float postscale, float min, float max);
@@ -51,12 +52,22 @@ av_cold void ff_gblur_init_x86(GBlurContext *s)
s->horiz_slice = ff_horiz_slice_sse4;
}
if (EXTERNAL_AVX2(cpu_flags)) {
- s->horiz_slice = ff_horiz_slice_avx2;
s->verti_slice = ff_verti_slice_avx2;
}
if (EXTERNAL_AVX512(cpu_flags)) {
s->postscale_slice = ff_postscale_slice_avx512;
s->verti_slice = ff_verti_slice_avx512;
}
+ if (EXTERNAL_AVX2(cpu_flags)) {
+ s->stride = EXTERNAL_AVX512(cpu_flags) ? 16 : 8;
+ s->localbuf = av_malloc(s->stride * sizeof(float) * s->planewidth[0] * s->planeheight[0]);
+ if (!s->localbuf)
+ return;
+
+ s->horiz_slice = ff_horiz_slice_avx2;
+ if (EXTERNAL_AVX512(cpu_flags)) {
+ s->horiz_slice = ff_horiz_slice_avx512;
+ }
+ }
#endif
}