2 * VP9 SIMD optimizations
4 * Copyright (c) 2013 Ronald S. Bultje <rsbultje gmail com>
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "libavutil/attributes.h"
24 #include "libavutil/cpu.h"
25 #include "libavutil/mem.h"
26 #include "libavutil/x86/cpu.h"
27 #include "libavcodec/vp9dsp.h"
28 #include "libavcodec/x86/vp9dsp_init.h"
32 extern const int16_t ff_filters_16bpp[3][15][4][16];
34 decl_mc_funcs(4, sse2, int16_t, 16, BPC);
35 decl_mc_funcs(8, sse2, int16_t, 16, BPC);
36 decl_mc_funcs(16, avx2, int16_t, 16, BPC);
38 mc_rep_funcs(16, 8, 16, sse2, int16_t, 16, BPC);
39 mc_rep_funcs(32, 16, 32, sse2, int16_t, 16, BPC);
40 mc_rep_funcs(64, 32, 64, sse2, int16_t, 16, BPC);
41 #if HAVE_AVX2_EXTERNAL
42 mc_rep_funcs(32, 16, 32, avx2, int16_t, 16, BPC);
43 mc_rep_funcs(64, 32, 64, avx2, int16_t, 16, BPC);
46 filters_8tap_2d_fn2(put, 16, BPC, 2, sse2, sse2, 16bpp)
47 filters_8tap_2d_fn2(avg, 16, BPC, 2, sse2, sse2, 16bpp)
48 #if HAVE_AVX2_EXTERNAL
49 filters_8tap_2d_fn(put, 64, 32, BPC, 2, avx2, 16bpp)
50 filters_8tap_2d_fn(avg, 64, 32, BPC, 2, avx2, 16bpp)
51 filters_8tap_2d_fn(put, 32, 32, BPC, 2, avx2, 16bpp)
52 filters_8tap_2d_fn(avg, 32, 32, BPC, 2, avx2, 16bpp)
53 filters_8tap_2d_fn(put, 16, 32, BPC, 2, avx2, 16bpp)
54 filters_8tap_2d_fn(avg, 16, 32, BPC, 2, avx2, 16bpp)
57 filters_8tap_1d_fn3(put, BPC, sse2, sse2, 16bpp)
58 filters_8tap_1d_fn3(avg, BPC, sse2, sse2, 16bpp)
59 #if HAVE_AVX2_EXTERNAL
60 filters_8tap_1d_fn2(put, 64, BPC, avx2, 16bpp)
61 filters_8tap_1d_fn2(avg, 64, BPC, avx2, 16bpp)
62 filters_8tap_1d_fn2(put, 32, BPC, avx2, 16bpp)
63 filters_8tap_1d_fn2(avg, 32, BPC, avx2, 16bpp)
64 filters_8tap_1d_fn2(put, 16, BPC, avx2, 16bpp)
65 filters_8tap_1d_fn2(avg, 16, BPC, avx2, 16bpp)
68 #endif /* HAVE_YASM */
70 av_cold void INIT_FUNC(VP9DSPContext *dsp)
73 int cpu_flags = av_get_cpu_flags();
75 if (EXTERNAL_SSE2(cpu_flags)) {
76 init_subpel3(0, put, BPC, sse2);
77 init_subpel3(1, avg, BPC, sse2);
80 if (EXTERNAL_AVX2(cpu_flags)) {
81 #if HAVE_AVX2_EXTERNAL
82 init_subpel3_32_64(0, put, BPC, avx2);
83 init_subpel3_32_64(1, avg, BPC, avx2);
84 init_subpel2(2, 0, 16, put, BPC, avx2);
85 init_subpel2(2, 1, 16, avg, BPC, avx2);
89 #endif /* HAVE_YASM */
91 ff_vp9dsp_init_16bpp_x86(dsp);