--- libavcodec/x86/Makefile | 3 +- libavcodec/x86/vp9dsp_init.c | 6 ++- libavcodec/x86/vp9dsp_init.h | 28 +++++++++++++ libavcodec/x86/vp9dsp_init_16bpp.c | 85 ++++++++++++++++++++++++++++++++++++++ libavcodec/x86/vp9mc.asm | 18 +++++++- 5 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 libavcodec/x86/vp9dsp_init.h create mode 100644 libavcodec/x86/vp9dsp_init_16bpp.c
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 3c3cc1c..616f830 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -62,7 +62,8 @@ OBJS-$(CONFIG_V210_ENCODER) += x86/v210enc_init.o OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_init.o OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp_init.o OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp_init.o -OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o +OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o \ + x86/vp9dsp_init_16bpp.o OBJS-$(CONFIG_WEBP_DECODER) += x86/vp8dsp_init.o diff --git a/libavcodec/x86/vp9dsp_init.c b/libavcodec/x86/vp9dsp_init.c index f24cb67..c1410d1 100644 --- a/libavcodec/x86/vp9dsp_init.c +++ b/libavcodec/x86/vp9dsp_init.c @@ -26,6 +26,7 @@ #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" #include "libavcodec/vp9dsp.h" +#include "libavcodec/x86/vp9dsp_init.h" #if HAVE_YASM @@ -311,7 +312,10 @@ av_cold void ff_vp9dsp_init_x86(VP9DSPContext *dsp, int bpp, int bitexact) { #if HAVE_YASM int cpu_flags; - if (bpp != 8) return; + if (bpp != 8) { + ff_vp9dsp_init_16bpp_x86(dsp, bpp); + return; + } cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/x86/vp9dsp_init.h b/libavcodec/x86/vp9dsp_init.h new file mode 100644 index 0000000..c791190 --- /dev/null +++ b/libavcodec/x86/vp9dsp_init.h @@ -0,0 +1,28 @@ +/* + * VP9 SIMD optimizations + * + * Copyright (c) 2013 Ronald S. Bultje <rsbultje gmail com> + * + * 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 + */ + +#ifndef AVCODEC_X86_VP9DSP_INIT_H +#define AVCODEC_X86_VP9DSP_INIT_H + +void ff_vp9dsp_init_16bpp_x86(VP9DSPContext *dsp, int bpp); + +#endif /* AVCODEC_X86_VP9DSP_INIT_H */ diff --git a/libavcodec/x86/vp9dsp_init_16bpp.c b/libavcodec/x86/vp9dsp_init_16bpp.c new file mode 100644 index 0000000..3319012 --- /dev/null +++ b/libavcodec/x86/vp9dsp_init_16bpp.c @@ -0,0 +1,85 @@ +/* + * VP9 SIMD optimizations + * + * Copyright (c) 2013 Ronald S. Bultje <rsbultje gmail com> + * + * 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/avassert.h" +#include "libavutil/cpu.h" +#include "libavutil/mem.h" +#include "libavutil/x86/asm.h" +#include "libavutil/x86/cpu.h" +#include "libavcodec/vp9dsp.h" +#include "libavcodec/x86/vp9dsp_init.h" + +#if HAVE_YASM + +#define fpel_func(avg, sz, opt) \ +void ff_vp9_##avg##sz##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \ + const uint8_t *src, ptrdiff_t src_stride, \ + int h, int mx, int my) + +fpel_func(put, 8, mmx); +fpel_func(put, 16, sse); +fpel_func(put, 32, sse); +fpel_func(put, 64, sse); +fpel_func(put, 128, sse); +fpel_func(put, 32, avx); +fpel_func(put, 64, avx); +fpel_func(put, 128, avx); +#undef fpel_func + +#endif /* HAVE_YASM */ + +av_cold void ff_vp9dsp_init_16bpp_x86(VP9DSPContext *dsp, int bpp) +{ +#if HAVE_YASM + int cpu_flags; + + av_assert1(bpp > 8); + + cpu_flags = av_get_cpu_flags(); + +#define init_fpel(idx1, idx2, sz, type, opt) \ + dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \ + dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \ + dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \ + dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##_##opt + + if (EXTERNAL_MMX(cpu_flags)) { + init_fpel(4, 0, 8, put, mmx); + } + + if (EXTERNAL_SSE(cpu_flags)) { + init_fpel(3, 0, 16, put, sse); + init_fpel(2, 0, 32, put, sse); + init_fpel(1, 0, 64, put, sse); + init_fpel(0, 0, 128, put, sse); + } + if (EXTERNAL_AVX_FAST(cpu_flags)) { + init_fpel(2, 0, 32, put, avx); + init_fpel(1, 0, 64, put, avx); + init_fpel(0, 0, 128, put, avx); + } + +#undef init_fpel + +#endif /* HAVE_YASM */ +} diff --git a/libavcodec/x86/vp9mc.asm b/libavcodec/x86/vp9mc.asm index 5393957..fb5b1e9 100644 --- a/libavcodec/x86/vp9mc.asm +++ b/libavcodec/x86/vp9mc.asm @@ -553,7 +553,7 @@ filter_vx2_fn avg %endif ; ARCH_X86_64 -%macro fpel_fn 6 +%macro fpel_fn 6-7 4 %if %2 == 4 %define %%srcfn movh %define %%dstfn movh @@ -567,13 +567,19 @@ cglobal vp9_%1%2, 5, 7, 4, dst, dstride, src, sstride, h, dstride3, sstride3 lea sstride3q, [sstrideq*3] lea dstride3q, [dstrideq*3] %else -cglobal vp9_%1%2, 5, 5, 4, dst, dstride, src, sstride, h +cglobal vp9_%1%2, 5, 5, %7, dst, dstride, src, sstride, h %endif .loop: %%srcfn m0, [srcq] %%srcfn m1, [srcq+s%3] %%srcfn m2, [srcq+s%4] %%srcfn m3, [srcq+s%5] +%if %2/mmsize == 8 + %%srcfn m4, [srcq+mmsize*4] + %%srcfn m5, [srcq+mmsize*5] + %%srcfn m6, [srcq+mmsize*6] + %%srcfn m7, [srcq+mmsize*7] +%endif lea srcq, [srcq+sstrideq*%6] %ifidn %1, avg pavgb m0, [dstq] @@ -585,6 +591,12 @@ cglobal vp9_%1%2, 5, 5, 4, dst, dstride, src, sstride, h %%dstfn [dstq+d%3], m1 %%dstfn [dstq+d%4], m2 %%dstfn [dstq+d%5], m3 +%if %2/mmsize == 8 + %%dstfn [dstq+mmsize*4], m4 + %%dstfn [dstq+mmsize*5], m5 + %%dstfn [dstq+mmsize*6], m6 + %%dstfn [dstq+mmsize*7], m7 +%endif lea dstq, [dstq+dstrideq*%6] sub hd, %6 jnz .loop @@ -605,6 +617,7 @@ INIT_XMM sse fpel_fn put, 16, strideq, strideq*2, stride3q, 4 fpel_fn put, 32, mmsize, strideq, strideq+mmsize, 2 fpel_fn put, 64, mmsize, mmsize*2, mmsize*3, 1 +fpel_fn put, 128, mmsize, mmsize*2, mmsize*3, 1, 8 INIT_XMM sse2 fpel_fn avg, 16, strideq, strideq*2, stride3q, 4 fpel_fn avg, 32, mmsize, strideq, strideq+mmsize, 2 @@ -612,6 +625,7 @@ fpel_fn avg, 64, mmsize, mmsize*2, mmsize*3, 1 INIT_YMM avx fpel_fn put, 32, strideq, strideq*2, stride3q, 4 fpel_fn put, 64, mmsize, strideq, strideq+mmsize, 2 +fpel_fn put, 128, mmsize, mmsize*2, mmsize*3, 1 %if HAVE_AVX2_EXTERNAL INIT_YMM avx2 fpel_fn avg, 32, strideq, strideq*2, stride3q, 4 -- 2.1.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel