mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-23 11:39:49 +00:00
avfilter/vf_transpose: add x86 SIMD
This commit is contained in:
parent
f7f4691f9f
commit
ccd9bca15a
@ -34,4 +34,14 @@ enum TransposeDir {
|
||||
TRANSPOSE_VFLIP,
|
||||
};
|
||||
|
||||
typedef struct TransVtable {
|
||||
void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
|
||||
uint8_t *dst, ptrdiff_t dst_linesize);
|
||||
void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
|
||||
uint8_t *dst, ptrdiff_t dst_linesize,
|
||||
int w, int h);
|
||||
} TransVtable;
|
||||
|
||||
void ff_transpose_init_x86(TransVtable *v, int pixstep);
|
||||
|
||||
#endif
|
||||
|
@ -40,14 +40,6 @@
|
||||
#include "video.h"
|
||||
#include "transpose.h"
|
||||
|
||||
typedef struct TransVtable {
|
||||
void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
|
||||
uint8_t *dst, ptrdiff_t dst_linesize);
|
||||
void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
|
||||
uint8_t *dst, ptrdiff_t dst_linesize,
|
||||
int w, int h);
|
||||
} TransVtable;
|
||||
|
||||
typedef struct TransContext {
|
||||
const AVClass *class;
|
||||
int hsub, vsub;
|
||||
@ -243,6 +235,14 @@ static int config_props_output(AVFilterLink *outlink)
|
||||
}
|
||||
}
|
||||
|
||||
if (ARCH_X86) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
TransVtable *v = &s->vtables[i];
|
||||
|
||||
ff_transpose_init_x86(v, s->pixsteps[i]);
|
||||
}
|
||||
}
|
||||
|
||||
av_log(ctx, AV_LOG_VERBOSE,
|
||||
"w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
|
||||
inlink->w, inlink->h, s->dir, outlink->w, outlink->h,
|
||||
|
@ -31,6 +31,7 @@ OBJS-$(CONFIG_STEREO3D_FILTER) += x86/vf_stereo3d_init.o
|
||||
OBJS-$(CONFIG_TBLEND_FILTER) += x86/vf_blend_init.o
|
||||
OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold_init.o
|
||||
OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_tinterlace_init.o
|
||||
OBJS-$(CONFIG_TRANSPOSE_FILTER) += x86/vf_transpose_init.o
|
||||
OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o
|
||||
OBJS-$(CONFIG_V360_FILTER) += x86/vf_v360_init.o
|
||||
OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif_init.o
|
||||
@ -69,6 +70,7 @@ X86ASM-OBJS-$(CONFIG_STEREO3D_FILTER) += x86/vf_stereo3d.o
|
||||
X86ASM-OBJS-$(CONFIG_TBLEND_FILTER) += x86/vf_blend.o
|
||||
X86ASM-OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold.o
|
||||
X86ASM-OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_interlace.o
|
||||
X86ASM-OBJS-$(CONFIG_TRANSPOSE_FILTER) += x86/vf_transpose.o
|
||||
X86ASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o
|
||||
X86ASM-OBJS-$(CONFIG_V360_FILTER) += x86/vf_v360.o
|
||||
X86ASM-OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif.o
|
||||
|
88
libavfilter/x86/vf_transpose.asm
Normal file
88
libavfilter/x86/vf_transpose.asm
Normal file
@ -0,0 +1,88 @@
|
||||
;*****************************************************************************
|
||||
;* x86-optimized functions for transpose filter
|
||||
;*
|
||||
;* Copyright (C) 2019 Paul B Mahol
|
||||
;*
|
||||
;* This file is part of FFmpeg.
|
||||
;*
|
||||
;* FFmpeg is free software; you can redistribute it and/or
|
||||
;* modify it under the terms of the GNU Lesser General Public
|
||||
;* License as published by the Free Software Foundation; either
|
||||
;* version 2.1 of the License, or (at your option) any later version.
|
||||
;*
|
||||
;* FFmpeg is distributed in the hope that it will be useful,
|
||||
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;* Lesser General Public License for more details.
|
||||
;*
|
||||
;* You should have received a copy of the GNU Lesser General Public
|
||||
;* License along with FFmpeg; if not, write to the Free Software
|
||||
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
;******************************************************************************
|
||||
|
||||
%include "libavutil/x86/x86util.asm"
|
||||
|
||||
SECTION .text
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; void ff_transpose_8x8(uint8_t *src, ptrdiff_t src_linesize,
|
||||
; uint8_t *dst, ptrdiff_t dst_linesize)
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
INIT_XMM sse2
|
||||
cglobal transpose_8x8_8, 4,5,8, src, src_linesize, dst, dst_linesize, linesize3
|
||||
lea linesize3q, [src_linesizeq * 3]
|
||||
movq m0, [srcq + src_linesizeq * 0]
|
||||
movq m1, [srcq + src_linesizeq * 1]
|
||||
movq m2, [srcq + src_linesizeq * 2]
|
||||
movq m3, [srcq + linesize3q]
|
||||
lea srcq, [srcq + src_linesizeq * 4]
|
||||
movq m4, [srcq + src_linesizeq * 0]
|
||||
movq m5, [srcq + src_linesizeq * 1]
|
||||
movq m6, [srcq + src_linesizeq * 2]
|
||||
movq m7, [srcq + linesize3q]
|
||||
|
||||
TRANSPOSE_8X8B 0, 1, 2, 3, 4, 5, 6, 7
|
||||
|
||||
lea linesize3q, [dst_linesizeq * 3]
|
||||
movq [dstq + dst_linesizeq * 0], m0
|
||||
movq [dstq + dst_linesizeq * 1], m1
|
||||
movq [dstq + dst_linesizeq * 2], m2
|
||||
movq [dstq + linesize3q], m3
|
||||
lea dstq, [dstq + dst_linesizeq * 4]
|
||||
movq [dstq + dst_linesizeq * 0], m4
|
||||
movq [dstq + dst_linesizeq * 1], m5
|
||||
movq [dstq + dst_linesizeq * 2], m6
|
||||
movq [dstq + linesize3q], m7
|
||||
RET
|
||||
|
||||
%if ARCH_X86_64
|
||||
|
||||
INIT_XMM sse2
|
||||
cglobal transpose_8x8_16, 4,5,9, src, src_linesize, dst, dst_linesize, linesize3
|
||||
lea linesize3q, [src_linesizeq * 3]
|
||||
movu m0, [srcq + src_linesizeq * 0]
|
||||
movu m1, [srcq + src_linesizeq * 1]
|
||||
movu m2, [srcq + src_linesizeq * 2]
|
||||
movu m3, [srcq + linesize3q]
|
||||
lea srcq, [srcq + src_linesizeq * 4]
|
||||
movu m4, [srcq + src_linesizeq * 0]
|
||||
movu m5, [srcq + src_linesizeq * 1]
|
||||
movu m6, [srcq + src_linesizeq * 2]
|
||||
movu m7, [srcq + linesize3q]
|
||||
|
||||
TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 8
|
||||
|
||||
lea linesize3q, [dst_linesizeq * 3]
|
||||
movu [dstq + dst_linesizeq * 0], m0
|
||||
movu [dstq + dst_linesizeq * 1], m1
|
||||
movu [dstq + dst_linesizeq * 2], m2
|
||||
movu [dstq + linesize3q], m3
|
||||
lea dstq, [dstq + dst_linesizeq * 4]
|
||||
movu [dstq + dst_linesizeq * 0], m4
|
||||
movu [dstq + dst_linesizeq * 1], m5
|
||||
movu [dstq + dst_linesizeq * 2], m6
|
||||
movu [dstq + linesize3q], m7
|
||||
RET
|
||||
|
||||
%endif
|
49
libavfilter/x86/vf_transpose_init.c
Normal file
49
libavfilter/x86/vf_transpose_init.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Paul B Mahol
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/x86/asm.h"
|
||||
#include "libavutil/x86/cpu.h"
|
||||
#include "libavfilter/transpose.h"
|
||||
|
||||
void ff_transpose_8x8_8_sse2(uint8_t *src,
|
||||
ptrdiff_t src_linesize,
|
||||
uint8_t *dst,
|
||||
ptrdiff_t dst_linesize);
|
||||
|
||||
void ff_transpose_8x8_16_sse2(uint8_t *src,
|
||||
ptrdiff_t src_linesize,
|
||||
uint8_t *dst,
|
||||
ptrdiff_t dst_linesize);
|
||||
|
||||
av_cold void ff_transpose_init_x86(TransVtable *v, int pixstep)
|
||||
{
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (EXTERNAL_SSE4(cpu_flags) && pixstep == 1) {
|
||||
v->transpose_8x8 = ff_transpose_8x8_8_sse2;
|
||||
}
|
||||
|
||||
if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && pixstep == 2) {
|
||||
v->transpose_8x8 = ff_transpose_8x8_16_sse2;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user