FFmpeg
Loading...
Searching...
No Matches
vp9dsp_init.h
Go to the documentation of this file.
1/*
2 * VP9 SIMD optimizations
3 *
4 * Copyright (c) 2013 Ronald S. Bultje <rsbultje gmail com>
5 *
6 * This file is part of FFmpeg.
7 *
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.
12 *
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.
17 *
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
21 */
22
23#ifndef AVCODEC_X86_VP9DSP_INIT_H
24#define AVCODEC_X86_VP9DSP_INIT_H
25
28
29#include "libavcodec/vp9dsp.h"
30
31// hack to force-expand BPC
32#define cat(a, bpp, b) a##bpp##b
33
34#define decl_fpel_func(avg, sz, bpp, opt) \
35void ff_vp9_##avg##sz##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
36 const uint8_t *src, ptrdiff_t src_stride, \
37 int h, int mx, int my)
38
39#define decl_mc_func(avg, sz, dir, opt, type, f_sz, bpp) \
40void ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
41 const uint8_t *src, ptrdiff_t src_stride, \
42 int h, const type (*filter)[f_sz])
43
44#define decl_mc_funcs(sz, opt, type, fsz, bpp) \
45decl_mc_func(put, sz, h, opt, type, fsz, bpp); \
46decl_mc_func(avg, sz, h, opt, type, fsz, bpp); \
47decl_mc_func(put, sz, v, opt, type, fsz, bpp); \
48decl_mc_func(avg, sz, v, opt, type, fsz, bpp)
49
50#define decl_ipred_fn(type, sz, bpp, opt) \
51void ff_vp9_ipred_##type##_##sz##x##sz##_##bpp##_##opt(uint8_t *dst, \
52 ptrdiff_t stride, \
53 const uint8_t *l, \
54 const uint8_t *a)
55
56#define decl_ipred_fns(type, bpp, opt4, opt8_16_32) \
57decl_ipred_fn(type, 4, bpp, opt4); \
58decl_ipred_fn(type, 8, bpp, opt8_16_32); \
59decl_ipred_fn(type, 16, bpp, opt8_16_32); \
60decl_ipred_fn(type, 32, bpp, opt8_16_32)
61
62#define decl_itxfm_func(typea, typeb, size, bpp, opt) \
63void cat(ff_vp9_##typea##_##typeb##_##size##x##size##_add_, bpp, _##opt)(uint8_t *dst, \
64 ptrdiff_t stride, \
65 int16_t *block, \
66 int eob)
67
68#define decl_itxfm_funcs(size, bpp, opt) \
69decl_itxfm_func(idct, idct, size, bpp, opt); \
70decl_itxfm_func(iadst, idct, size, bpp, opt); \
71decl_itxfm_func(idct, iadst, size, bpp, opt); \
72decl_itxfm_func(iadst, iadst, size, bpp, opt)
73
74#define mc_rep_func(avg, sz, hsz, hszb, dir, opt, type, f_sz, bpp) \
75static av_always_inline void \
76ff_vp9_##avg##_8tap_1d_##dir##_##sz##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
77 const uint8_t *src, ptrdiff_t src_stride, \
78 int h, const type (*filter)[f_sz]) \
79{ \
80 ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##bpp##_##opt(dst, dst_stride, src, \
81 src_stride, h, filter); \
82 ff_vp9_##avg##_8tap_1d_##dir##_##hsz##_##bpp##_##opt(dst + hszb, dst_stride, src + hszb, \
83 src_stride, h, filter); \
84}
85
86#define mc_rep_funcs(sz, hsz, hszb, opt, type, fsz, bpp) \
87mc_rep_func(put, sz, hsz, hszb, h, opt, type, fsz, bpp) \
88mc_rep_func(avg, sz, hsz, hszb, h, opt, type, fsz, bpp) \
89mc_rep_func(put, sz, hsz, hszb, v, opt, type, fsz, bpp) \
90mc_rep_func(avg, sz, hsz, hszb, v, opt, type, fsz, bpp)
91
92#define filter_8tap_1d_fn(op, sz, f, f_opt, fname, dir, dvar, bpp, opt) \
93static void op##_8tap_##fname##_##sz##dir##_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
94 const uint8_t *src, ptrdiff_t src_stride, \
95 int h, int mx, int my) \
96{ \
97 ff_vp9_##op##_8tap_1d_##dir##_##sz##_##bpp##_##opt(dst, dst_stride, src, src_stride, \
98 h, ff_filters_##f_opt[f][dvar - 1]); \
99}
100
101#define filters_8tap_1d_fn(op, sz, dir, dvar, bpp, opt, f_opt) \
102filter_8tap_1d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, dir, dvar, bpp, opt) \
103filter_8tap_1d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, dir, dvar, bpp, opt) \
104filter_8tap_1d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, dir, dvar, bpp, opt)
105
106#define filters_8tap_1d_fn2(op, sz, bpp, opt, f_opt) \
107filters_8tap_1d_fn(op, sz, h, mx, bpp, opt, f_opt) \
108filters_8tap_1d_fn(op, sz, v, my, bpp, opt, f_opt)
109
110#define filters_8tap_1d_fn3(op, bpp, opt8, f_opt) \
111filters_8tap_1d_fn2(op, 64, bpp, opt8, f_opt) \
112filters_8tap_1d_fn2(op, 32, bpp, opt8, f_opt) \
113filters_8tap_1d_fn2(op, 16, bpp, opt8, f_opt) \
114filters_8tap_1d_fn2(op, 8, bpp, opt8, f_opt) \
115
116#define filters_8tap_1d_fn4(op, bpp, opt, f_opt) \
117filters_8tap_1d_fn3(op, bpp, opt, f_opt) \
118filters_8tap_1d_fn2(op, 4, bpp, opt, f_opt) \
119
120#define filter_8tap_2d_fn(op, sz, f, f_opt, fname, align, bpp, bytes, opt) \
121static void op##_8tap_##fname##_##sz##hv_##bpp##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \
122 const uint8_t *src, ptrdiff_t src_stride, \
123 int h, int mx, int my) \
124{ \
125 LOCAL_ALIGNED_##align(uint8_t, temp, [71 * 64 * bytes]); \
126 ff_vp9_put_8tap_1d_h_##sz##_##bpp##_##opt(temp, 64 * bytes, src - 3 * src_stride, \
127 src_stride, h + 7, \
128 ff_filters_##f_opt[f][mx - 1]); \
129 ff_vp9_##op##_8tap_1d_v_##sz##_##bpp##_##opt(dst, dst_stride, temp + 3 * bytes * 64, \
130 64 * bytes, h, \
131 ff_filters_##f_opt[f][my - 1]); \
132}
133
134#define filters_8tap_2d_fn(op, sz, align, bpp, bytes, opt, f_opt) \
135filter_8tap_2d_fn(op, sz, FILTER_8TAP_REGULAR, f_opt, regular, align, bpp, bytes, opt) \
136filter_8tap_2d_fn(op, sz, FILTER_8TAP_SHARP, f_opt, sharp, align, bpp, bytes, opt) \
137filter_8tap_2d_fn(op, sz, FILTER_8TAP_SMOOTH, f_opt, smooth, align, bpp, bytes, opt)
138
139#define filters_8tap_2d_fn2(op, align, bpp, bytes, opt8, f_opt) \
140filters_8tap_2d_fn(op, 64, align, bpp, bytes, opt8, f_opt) \
141filters_8tap_2d_fn(op, 32, align, bpp, bytes, opt8, f_opt) \
142filters_8tap_2d_fn(op, 16, align, bpp, bytes, opt8, f_opt) \
143filters_8tap_2d_fn(op, 8, align, bpp, bytes, opt8, f_opt) \
144
145#define filters_8tap_2d_fn3(op, align, bpp, bytes, opt, f_opt) \
146filters_8tap_2d_fn2(op, align, bpp, bytes, opt, f_opt) \
147filters_8tap_2d_fn(op, 4, align, bpp, bytes, opt, f_opt)
148
149#define init_fpel_func(idx1, idx2, sz, type, bpp, opt) \
150 dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = \
151 dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = \
152 dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = \
153 dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = ff_vp9_##type##sz##bpp##_##opt
154
155#define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type, bpp, opt) \
156 dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = \
157 type##_8tap_smooth_##sz##dir##_##bpp##_##opt; \
158 dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = \
159 type##_8tap_regular_##sz##dir##_##bpp##_##opt; \
160 dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = \
161 type##_8tap_sharp_##sz##dir##_##bpp##_##opt
162
163#define init_subpel2(idx1, idx2, sz, type, bpp, opt) \
164 init_subpel1(idx1, idx2, 1, 1, sz, hv, type, bpp, opt); \
165 init_subpel1(idx1, idx2, 0, 1, sz, v, type, bpp, opt); \
166 init_subpel1(idx1, idx2, 1, 0, sz, h, type, bpp, opt)
167
168#define init_subpel3_32_64(idx, type, bpp, opt) \
169 init_subpel2(0, idx, 64, type, bpp, opt); \
170 init_subpel2(1, idx, 32, type, bpp, opt)
171
172#define init_subpel3_8to64(idx, type, bpp, opt) \
173 init_subpel3_32_64(idx, type, bpp, opt); \
174 init_subpel2(2, idx, 16, type, bpp, opt); \
175 init_subpel2(3, idx, 8, type, bpp, opt)
176
177#define init_subpel3(idx, type, bpp, opt) \
178 init_subpel3_8to64(idx, type, bpp, opt); \
179 init_subpel2(4, idx, 4, type, bpp, opt)
180
181#define decl_subpel_asm_fn(type) \
182 void ff_vp9_put_8tap_##type(uint8_t *dst, ptrdiff_t dst_stride, \
183 const uint8_t *src, ptrdiff_t src_stride, \
184 int h, int mx, int my); \
185 void ff_vp9_avg_8tap_##type(uint8_t *dst, ptrdiff_t dst_stride, \
186 const uint8_t *src, ptrdiff_t src_stride, \
187 int h, int mx, int my)
188
189#define decl_subpel_asm_dir(type) \
190 decl_subpel_asm_fn(regular_##type); \
191 decl_subpel_asm_fn(smooth_##type); \
192 decl_subpel_asm_fn(sharp_##type)
193
194#define decl_subpel_asm(sz, bpp, opt) \
195 decl_subpel_asm_dir(sz##h_##bpp##_##opt); \
196 decl_subpel_asm_dir(sz##v_##bpp##_##opt); \
197 decl_subpel_asm_dir(sz##hv_##bpp##_##opt)
198
199#define init_subpel_asm_dir(idx1, idx2, idx3, type) \
200 dsp->mc[idx1][FILTER_8TAP_REGULAR][0][idx2][idx3] = ff_vp9_put_8tap_regular_##type; \
201 dsp->mc[idx1][FILTER_8TAP_SHARP ][0][idx2][idx3] = ff_vp9_put_8tap_sharp_##type; \
202 dsp->mc[idx1][FILTER_8TAP_SMOOTH ][0][idx2][idx3] = ff_vp9_put_8tap_smooth_##type; \
203 dsp->mc[idx1][FILTER_8TAP_REGULAR][1][idx2][idx3] = ff_vp9_avg_8tap_regular_##type; \
204 dsp->mc[idx1][FILTER_8TAP_SHARP ][1][idx2][idx3] = ff_vp9_avg_8tap_sharp_##type; \
205 dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][idx2][idx3] = ff_vp9_avg_8tap_smooth_##type
206
207#define init_subpel_asm(idx, sz, bpp, opt) \
208 init_subpel_asm_dir(idx, 1, 0, sz##h_##bpp##_##opt); \
209 init_subpel_asm_dir(idx, 0, 1, sz##v_##bpp##_##opt); \
210 init_subpel_asm_dir(idx, 1, 1, sz##hv_##bpp##_##opt)
211
212#define init_ipred_func(type, enum, sz, bpp, opt) \
213 dsp->intra_pred[TX_##sz##X##sz][enum##_PRED] = \
214 cat(ff_vp9_ipred_##type##_##sz##x##sz##_, bpp, _##opt)
215
216#define init_8_16_32_ipred_funcs(type, enum, bpp, opt) \
217 init_ipred_func(type, enum, 8, bpp, opt); \
218 init_ipred_func(type, enum, 16, bpp, opt); \
219 init_ipred_func(type, enum, 32, bpp, opt)
220
221#define init_ipred_funcs(type, enum, bpp, opt) \
222 init_ipred_func(type, enum, 4, bpp, opt); \
223 init_8_16_32_ipred_funcs(type, enum, bpp, opt)
224
228
229#endif /* AVCODEC_X86_VP9DSP_INIT_H */
Macro definitions for various function/variable attributes.
void ff_vp9dsp_init_16bpp_x86(VP9DSPContext *dsp)
void ff_vp9dsp_init_12bpp_x86(VP9DSPContext *dsp, int bitexact)
void ff_vp9dsp_init_10bpp_x86(VP9DSPContext *dsp, int bitexact)