[FFmpeg-devel] [PATCH 2/2] avfilter/vf_v360: add SIMD for lagrange interpolation
James Almer
jamrial at gmail.com
Tue Mar 31 18:38:04 EEST 2020
On 3/31/2020 10:51 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavfilter/x86/vf_v360.asm | 46 ++++++++++++++++++++++++++++++++++
> libavfilter/x86/vf_v360_init.c | 6 +++++
> 2 files changed, 52 insertions(+)
>
> diff --git a/libavfilter/x86/vf_v360.asm b/libavfilter/x86/vf_v360.asm
> index 5b241220d8..e1908e5e71 100644
> --- a/libavfilter/x86/vf_v360.asm
> +++ b/libavfilter/x86/vf_v360.asm
> @@ -165,6 +165,52 @@ DEFINE_ARGS dst, width, src, x, u, v, ker
>
> %if ARCH_X86_64
>
> +INIT_YMM avx2
> +cglobal remap3_8bit_line, 7, 11, 8, dst, width, src, in_linesize, u, v, ker, x, y, tmp, z
> + movsxdifnidn widthq, widthd
> + xor zq, zq
> + xor yq, yq
> + xor xq, xq
> + movd xm0, in_linesized
> + pcmpeqw m7, m7
> + vpbroadcastd m0, xm0
> + vpbroadcastd m6, [pd_255]
> +
> + .loop:
> + pmovsxwd m1, [kerq + yq]
> + pmovsxwd m2, [vq + yq]
> + pmovsxwd m3, [uq + yq]
> +
> + pmulld m4, m2, m0
> + paddd m4, m3
> + mova m3, m7
> + vpgatherdd m2, [srcq + m4], m3
> + pand m2, m6
> + pmulld m2, m1
> + phaddd m2, m2
> + phaddd m1, m2, m2
> + vextracti128 xm2, m1, 1
> + paddd m2, m1
This is very slow. Use the HADDD macro instead.
> + movzx tmpq, word [vq + yq + 16]
> + imul tmpq, in_linesizeq
> + movzx zq, word [uq + yq + 16]
> + add tmpq, zq
> + movzx zq, byte [srcq + tmpq]
> + movzx tmpq, word [kerq + yq + 16]
> + imul zq, tmpq
> + movd xm1, zd
> + paddd m2, m1
> + psrld m2, m2, 0xe
> +
> + packuswb m2, m2
> + pextrb [dstq+xq], xm2, 0
> +
> + add xq, 1
> + add yq, 18
> + cmp xq, widthq
> + jl .loop
> + RET
> +
> INIT_YMM avx2
> cglobal remap4_8bit_line, 7, 9, 11, dst, width, src, in_linesize, u, v, ker, x, y
> movsxdifnidn widthq, widthd
> diff --git a/libavfilter/x86/vf_v360_init.c b/libavfilter/x86/vf_v360_init.c
> index babc6c426a..83f58bb96a 100644
> --- a/libavfilter/x86/vf_v360_init.c
> +++ b/libavfilter/x86/vf_v360_init.c
> @@ -29,6 +29,9 @@ void ff_remap1_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdi
> void ff_remap2_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
> const int16_t *const u, const int16_t *const v, const int16_t *const ker);
>
> +void ff_remap3_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
> + const int16_t *const u, const int16_t *const v, const int16_t *const ker);
> +
> void ff_remap4_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
> const int16_t *const u, const int16_t *const v, const int16_t *const ker);
>
> @@ -48,6 +51,9 @@ av_cold void ff_v360_init_x86(V360Context *s, int depth)
> if (EXTERNAL_AVX2_FAST(cpu_flags) && s->interp == BILINEAR && depth <= 8)
> s->remap_line = ff_remap2_8bit_line_avx2;
>
> + if (EXTERNAL_AVX2_FAST(cpu_flags) && s->interp == LAGRANGE && depth <= 8)
> + s->remap_line = ff_remap3_8bit_line_avx2;
> +
> if (EXTERNAL_AVX2_FAST(cpu_flags) && s->interp == NEAREST && depth > 8)
> s->remap_line = ff_remap1_16bit_line_avx2;
>
>
More information about the ffmpeg-devel
mailing list