--- libavcodec/x86/Makefile | 3 +- libavcodec/x86/blockdsp.asm | 56 +++++++++++++++++++ libavcodec/x86/blockdsp.c | 118 ----------------------------------------- libavcodec/x86/blockdsp_init.c | 64 ++++++++++++++++++++++ 4 files changed, 122 insertions(+), 119 deletions(-) create mode 100644 libavcodec/x86/blockdsp.asm delete mode 100644 libavcodec/x86/blockdsp.c create mode 100644 libavcodec/x86/blockdsp_init.c
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 204c856..906bd0ea 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -3,7 +3,7 @@ OBJS += x86/constants.o \ # subsystems OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_init.o OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_init.o -OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp.o +OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp_init.o OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp_init.o OBJS-$(CONFIG_DCT) += x86/dct_init.o OBJS-$(CONFIG_FDCTDSP) += x86/fdctdsp_init.o @@ -74,6 +74,7 @@ MMX-OBJS-$(CONFIG_MPEG4_DECODER) += x86/xvididct_mmx.o \ # subsystems YASM-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp.o YASM-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp.o +YASM-OBJS-$(CONFIG_BLOCKDSP) += x86/blockdsp.o YASM-OBJS-$(CONFIG_BSWAPDSP) += x86/bswapdsp.o YASM-OBJS-$(CONFIG_DCT) += x86/dct32.o YASM-OBJS-$(CONFIG_FFT) += x86/fft.o diff --git a/libavcodec/x86/blockdsp.asm b/libavcodec/x86/blockdsp.asm new file mode 100644 index 0000000..2b46b9d --- /dev/null +++ b/libavcodec/x86/blockdsp.asm @@ -0,0 +1,56 @@ +;***************************************************************************** +;* This file is part of Libav. +;* +;* Libav 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. +;* +;* Libav 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 Libav; 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 + +; %1 -- size in bytes +%macro CLEAR_BLOCK 1 +%assign blocks (%1 / mmsize) +%assign loops (blocks / 8) + +cglobal clear_block_ %+ %1, 1, 2, 1, block + pxor m0, m0 +%if loops > 1 + mov r1q, loops +%endif + +.loop +%assign i 0 +%rep 8 + mova [blockq + mmsize * i], m0 +%assign i (i + 1) +%endrep + +%if loops > 1 + add blockq, mmsize * 8 + dec r1q + jg .loop +%endif + + RET +%endmacro + +INIT_MMX mmx +CLEAR_BLOCK 128 +CLEAR_BLOCK 768 + +INIT_XMM sse2 +CLEAR_BLOCK 128 +CLEAR_BLOCK 768 diff --git a/libavcodec/x86/blockdsp.c b/libavcodec/x86/blockdsp.c deleted file mode 100644 index 9bb5185..0000000 --- a/libavcodec/x86/blockdsp.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdint.h> - -#include "config.h" -#include "libavutil/attributes.h" -#include "libavutil/internal.h" -#include "libavutil/cpu.h" -#include "libavutil/x86/asm.h" -#include "libavutil/x86/cpu.h" -#include "libavcodec/blockdsp.h" -#include "libavcodec/version.h" - -#if HAVE_INLINE_ASM - -#define CLEAR_BLOCKS(name, n) \ -static void name(int16_t *blocks) \ -{ \ - __asm__ volatile ( \ - "pxor %%mm7, %%mm7 \n\t" \ - "mov %1, %%"FF_REG_a" \n\t" \ - "1: \n\t" \ - "movq %%mm7, (%0, %%"FF_REG_a") \n\t" \ - "movq %%mm7, 8(%0, %%"FF_REG_a") \n\t" \ - "movq %%mm7, 16(%0, %%"FF_REG_a") \n\t" \ - "movq %%mm7, 24(%0, %%"FF_REG_a") \n\t" \ - "add $32, %%"FF_REG_a" \n\t" \ - "js 1b \n\t" \ - :: "r"(((uint8_t *) blocks) + 128 * n), \ - "i"(-128 * n) \ - : "%"FF_REG_a); \ -} -CLEAR_BLOCKS(clear_blocks_mmx, 6) -CLEAR_BLOCKS(clear_block_mmx, 1) - -static void clear_block_sse(int16_t *block) -{ - __asm__ volatile ( - "xorps %%xmm0, %%xmm0 \n" - "movaps %%xmm0, (%0) \n" - "movaps %%xmm0, 16(%0) \n" - "movaps %%xmm0, 32(%0) \n" - "movaps %%xmm0, 48(%0) \n" - "movaps %%xmm0, 64(%0) \n" - "movaps %%xmm0, 80(%0) \n" - "movaps %%xmm0, 96(%0) \n" - "movaps %%xmm0, 112(%0) \n" - :: "r" (block) - : "memory"); -} - -static void clear_blocks_sse(int16_t *blocks) -{ - __asm__ volatile ( - "xorps %%xmm0, %%xmm0 \n" - "mov %1, %%"FF_REG_a" \n" - "1: \n" - "movaps %%xmm0, (%0, %%"FF_REG_a") \n" - "movaps %%xmm0, 16(%0, %%"FF_REG_a") \n" - "movaps %%xmm0, 32(%0, %%"FF_REG_a") \n" - "movaps %%xmm0, 48(%0, %%"FF_REG_a") \n" - "movaps %%xmm0, 64(%0, %%"FF_REG_a") \n" - "movaps %%xmm0, 80(%0, %%"FF_REG_a") \n" - "movaps %%xmm0, 96(%0, %%"FF_REG_a") \n" - "movaps %%xmm0, 112(%0, %%"FF_REG_a") \n" - "add $128, %%"FF_REG_a" \n" - "js 1b \n" - :: "r"(((uint8_t *) blocks) + 128 * 6), "i"(-128 * 6) - : "%"FF_REG_a); -} - -#endif /* HAVE_INLINE_ASM */ - -#if FF_API_XVMC -av_cold void ff_blockdsp_init_x86(BlockDSPContext *c, - AVCodecContext *avctx) -#else -av_cold void ff_blockdsp_init_x86(BlockDSPContext *c) -#endif /* FF_API_XVMC */ -{ -#if HAVE_INLINE_ASM - int cpu_flags = av_get_cpu_flags(); - - if (INLINE_MMX(cpu_flags)) { - c->clear_block = clear_block_mmx; - c->clear_blocks = clear_blocks_mmx; - } - -#if FF_API_XVMC -FF_DISABLE_DEPRECATION_WARNINGS - /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */ - if (CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1) - return; -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_XVMC */ - - if (INLINE_SSE(cpu_flags)) { - c->clear_block = clear_block_sse; - c->clear_blocks = clear_blocks_sse; - } -#endif /* HAVE_INLINE_ASM */ -} diff --git a/libavcodec/x86/blockdsp_init.c b/libavcodec/x86/blockdsp_init.c new file mode 100644 index 0000000..06e9520 --- /dev/null +++ b/libavcodec/x86/blockdsp_init.c @@ -0,0 +1,64 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdint.h> + +#include "config.h" + +#include "libavutil/attributes.h" +#include "libavutil/internal.h" +#include "libavutil/cpu.h" +#include "libavutil/x86/asm.h" +#include "libavutil/x86/cpu.h" + +#include "libavcodec/blockdsp.h" +#include "libavcodec/version.h" + +void ff_clear_block_128_mmx(int16_t *block); +void ff_clear_block_768_mmx(int16_t *block); +void ff_clear_block_128_sse2(int16_t *block); +void ff_clear_block_768_sse2(int16_t *block); + +#if FF_API_XVMC +av_cold void ff_blockdsp_init_x86(BlockDSPContext *c, + AVCodecContext *avctx) +#else +av_cold void ff_blockdsp_init_x86(BlockDSPContext *c) +#endif /* FF_API_XVMC */ +{ +#if HAVE_YASM + int cpu_flags = av_get_cpu_flags(); + +#if FF_API_XVMC +FF_DISABLE_DEPRECATION_WARNINGS + /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */ + if (CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1) + return; +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* FF_API_XVMC */ + + if (EXTERNAL_MMX(cpu_flags)) { + c->clear_block = ff_clear_block_128_mmx; + c->clear_blocks = ff_clear_block_768_mmx; + } + if (EXTERNAL_SSE2(cpu_flags)) { + c->clear_block = ff_clear_block_128_sse2; + c->clear_blocks = ff_clear_block_768_sse2; + } +#endif +} -- 2.0.0 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel