11975
|
1 /*
|
|
2 * VP8 DSP functions x86-optimized
|
|
3 * Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com>
|
|
4 * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@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 #include "libavutil/x86_cpu.h"
|
|
24 #include "libavcodec/vp8dsp.h"
|
|
25
|
11991
|
26 #if HAVE_YASM
|
|
27
|
11975
|
28 /*
|
|
29 * MC functions
|
|
30 */
|
|
31 extern void ff_put_vp8_epel4_h4_mmxext(uint8_t *dst, int dststride,
|
|
32 uint8_t *src, int srcstride,
|
|
33 int height, int mx, int my);
|
|
34 extern void ff_put_vp8_epel4_h6_mmxext(uint8_t *dst, int dststride,
|
|
35 uint8_t *src, int srcstride,
|
|
36 int height, int mx, int my);
|
|
37 extern void ff_put_vp8_epel4_v4_mmxext(uint8_t *dst, int dststride,
|
|
38 uint8_t *src, int srcstride,
|
|
39 int height, int mx, int my);
|
|
40 extern void ff_put_vp8_epel4_v6_mmxext(uint8_t *dst, int dststride,
|
|
41 uint8_t *src, int srcstride,
|
|
42 int height, int mx, int my);
|
|
43
|
|
44 extern void ff_put_vp8_epel8_h4_sse2 (uint8_t *dst, int dststride,
|
|
45 uint8_t *src, int srcstride,
|
|
46 int height, int mx, int my);
|
|
47 extern void ff_put_vp8_epel8_h6_sse2 (uint8_t *dst, int dststride,
|
|
48 uint8_t *src, int srcstride,
|
|
49 int height, int mx, int my);
|
|
50 extern void ff_put_vp8_epel8_v4_sse2 (uint8_t *dst, int dststride,
|
|
51 uint8_t *src, int srcstride,
|
|
52 int height, int mx, int my);
|
|
53 extern void ff_put_vp8_epel8_v6_sse2 (uint8_t *dst, int dststride,
|
|
54 uint8_t *src, int srcstride,
|
|
55 int height, int mx, int my);
|
|
56
|
|
57 extern void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, int dststride,
|
|
58 uint8_t *src, int srcstride,
|
|
59 int height, int mx, int my);
|
|
60 extern void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, int dststride,
|
|
61 uint8_t *src, int srcstride,
|
|
62 int height, int mx, int my);
|
|
63 extern void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, int dststride,
|
|
64 uint8_t *src, int srcstride,
|
|
65 int height, int mx, int my);
|
|
66 extern void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, int dststride,
|
|
67 uint8_t *src, int srcstride,
|
|
68 int height, int mx, int my);
|
|
69
|
11991
|
70 extern void ff_put_vp8_bilinear4_h_mmxext(uint8_t *dst, int dststride,
|
|
71 uint8_t *src, int srcstride,
|
|
72 int height, int mx, int my);
|
|
73 extern void ff_put_vp8_bilinear8_h_sse2 (uint8_t *dst, int dststride,
|
|
74 uint8_t *src, int srcstride,
|
|
75 int height, int mx, int my);
|
|
76
|
|
77 extern void ff_put_vp8_bilinear4_v_mmxext(uint8_t *dst, int dststride,
|
|
78 uint8_t *src, int srcstride,
|
|
79 int height, int mx, int my);
|
|
80 extern void ff_put_vp8_bilinear8_v_sse2 (uint8_t *dst, int dststride,
|
|
81 uint8_t *src, int srcstride,
|
|
82 int height, int mx, int my);
|
|
83 extern void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, int dststride,
|
|
84 uint8_t *src, int srcstride,
|
|
85 int height, int mx, int my);
|
|
86 extern void ff_put_vp8_bilinear8_h_ssse3 (uint8_t *dst, int dststride,
|
|
87 uint8_t *src, int srcstride,
|
|
88 int height, int mx, int my);
|
|
89
|
11992
|
90 extern void ff_put_vp8_pixels8_mmx (uint8_t *dst, int dststride,
|
|
91 uint8_t *src, int srcstride,
|
|
92 int height, int mx, int my);
|
|
93 extern void ff_put_vp8_pixels16_mmx(uint8_t *dst, int dststride,
|
|
94 uint8_t *src, int srcstride,
|
|
95 int height, int mx, int my);
|
|
96 extern void ff_put_vp8_pixels16_sse(uint8_t *dst, int dststride,
|
|
97 uint8_t *src, int srcstride,
|
|
98 int height, int mx, int my);
|
|
99
|
11991
|
100 #define TAP_W16(OPT, FILTERTYPE, TAPTYPE) \
|
|
101 static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \
|
|
102 uint8_t *dst, int dststride, uint8_t *src, \
|
|
103 int srcstride, int height, int mx, int my) \
|
11975
|
104 { \
|
11991
|
105 ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
|
|
106 dst, dststride, src, srcstride, height, mx, my); \
|
|
107 ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
|
|
108 dst + 8, dststride, src + 8, srcstride, height, mx, my); \
|
11975
|
109 }
|
11991
|
110 #define TAP_W8(OPT, FILTERTYPE, TAPTYPE) \
|
|
111 static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
|
|
112 uint8_t *dst, int dststride, uint8_t *src, \
|
|
113 int srcstride, int height, int mx, int my) \
|
11975
|
114 { \
|
11991
|
115 ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \
|
|
116 dst, dststride, src, srcstride, height, mx, my); \
|
|
117 ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \
|
|
118 dst + 4, dststride, src + 4, srcstride, height, mx, my); \
|
11975
|
119 }
|
|
120
|
11991
|
121 TAP_W8 (mmxext, epel, h4)
|
|
122 TAP_W8 (mmxext, epel, h6)
|
|
123 TAP_W16(mmxext, epel, h6)
|
|
124 TAP_W8 (mmxext, epel, v4)
|
|
125 TAP_W8 (mmxext, epel, v6)
|
|
126 TAP_W16(mmxext, epel, v6)
|
|
127 TAP_W8 (mmxext, bilinear, h)
|
|
128 TAP_W16(mmxext, bilinear, h)
|
|
129 TAP_W8 (mmxext, bilinear, v)
|
|
130 TAP_W16(mmxext, bilinear, v)
|
11975
|
131
|
11991
|
132 TAP_W16(sse2, epel, h6)
|
|
133 TAP_W16(sse2, epel, v6)
|
|
134 TAP_W16(sse2, bilinear, h)
|
|
135 TAP_W16(sse2, bilinear, v)
|
11975
|
136
|
11991
|
137 TAP_W16(ssse3, epel, h6)
|
|
138 TAP_W16(ssse3, epel, v6)
|
|
139 TAP_W16(ssse3, bilinear, h)
|
|
140 TAP_W16(ssse3, bilinear, v)
|
11975
|
141
|
|
142 #define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \
|
11991
|
143 static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT( \
|
|
144 uint8_t *dst, int dststride, uint8_t *src, \
|
|
145 int srcstride, int height, int mx, int my) \
|
11975
|
146 { \
|
|
147 DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \
|
|
148 uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \
|
|
149 src -= srcstride * (TAPNUMY / 2 - 1); \
|
11991
|
150 ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## _ ## OPT( \
|
|
151 tmp, SIZE, src, srcstride, height + TAPNUMY - 1, mx, my); \
|
|
152 ff_put_vp8_epel ## SIZE ## _v ## TAPNUMY ## _ ## OPT( \
|
|
153 dst, dststride, tmpptr, SIZE, height, mx, my); \
|
11975
|
154 }
|
|
155
|
|
156 #define HVTAPMMX(x, y) \
|
|
157 HVTAP(mmxext, 8, x, y, 4, 8) \
|
|
158 HVTAP(mmxext, 8, x, y, 8, 16)
|
|
159
|
|
160 HVTAPMMX(4, 4)
|
|
161 HVTAPMMX(4, 6)
|
|
162 HVTAPMMX(6, 4)
|
|
163 HVTAPMMX(6, 6)
|
|
164 HVTAP(mmxext, 8, 6, 6, 16, 16)
|
|
165
|
|
166 #define HVTAPSSE2(x, y, w) \
|
|
167 HVTAP(sse2, 16, x, y, w, 16) \
|
|
168 HVTAP(ssse3, 16, x, y, w, 16)
|
|
169
|
|
170 HVTAPSSE2(4, 4, 8)
|
|
171 HVTAPSSE2(4, 6, 8)
|
|
172 HVTAPSSE2(6, 4, 8)
|
|
173 HVTAPSSE2(6, 6, 8)
|
|
174 HVTAPSSE2(6, 6, 16)
|
11991
|
175
|
|
176 #define HVBILIN(OPT, ALIGN, SIZE, MAXHEIGHT) \
|
|
177 static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \
|
|
178 uint8_t *dst, int dststride, uint8_t *src, \
|
|
179 int srcstride, int height, int mx, int my) \
|
|
180 { \
|
|
181 DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + 2)]; \
|
|
182 ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT( \
|
|
183 tmp, SIZE, src, srcstride, height + 1, mx, my); \
|
|
184 ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT( \
|
|
185 dst, dststride, tmp, SIZE, height, mx, my); \
|
|
186 }
|
|
187
|
|
188 HVBILIN(mmxext, 8, 4, 8)
|
|
189 HVBILIN(mmxext, 8, 8, 16)
|
|
190 HVBILIN(mmxext, 8, 16, 16)
|
|
191 HVBILIN(sse2, 8, 8, 16)
|
|
192 HVBILIN(sse2, 8, 16, 16)
|
|
193 HVBILIN(ssse3, 8, 8, 16)
|
|
194 HVBILIN(ssse3, 8, 16, 16)
|
11975
|
195
|
|
196 extern void ff_vp8_idct_dc_add_mmx(uint8_t *dst, DCTELEM block[16], int stride);
|
|
197 extern void ff_vp8_idct_dc_add_sse4(uint8_t *dst, DCTELEM block[16], int stride);
|
11991
|
198 #endif
|
|
199
|
|
200 #define VP8_LUMA_MC_FUNC(IDX, SIZE, OPT) \
|
|
201 c->put_vp8_epel_pixels_tab[IDX][0][2] = ff_put_vp8_epel ## SIZE ## _h6_ ## OPT; \
|
|
202 c->put_vp8_epel_pixels_tab[IDX][2][0] = ff_put_vp8_epel ## SIZE ## _v6_ ## OPT; \
|
|
203 c->put_vp8_epel_pixels_tab[IDX][2][2] = ff_put_vp8_epel ## SIZE ## _h6v6_ ## OPT
|
|
204
|
|
205 #define VP8_MC_FUNC(IDX, SIZE, OPT) \
|
|
206 c->put_vp8_epel_pixels_tab[IDX][0][1] = ff_put_vp8_epel ## SIZE ## _h4_ ## OPT; \
|
|
207 c->put_vp8_epel_pixels_tab[IDX][1][0] = ff_put_vp8_epel ## SIZE ## _v4_ ## OPT; \
|
|
208 c->put_vp8_epel_pixels_tab[IDX][1][1] = ff_put_vp8_epel ## SIZE ## _h4v4_ ## OPT; \
|
|
209 c->put_vp8_epel_pixels_tab[IDX][1][2] = ff_put_vp8_epel ## SIZE ## _h6v4_ ## OPT; \
|
|
210 c->put_vp8_epel_pixels_tab[IDX][2][1] = ff_put_vp8_epel ## SIZE ## _h4v6_ ## OPT; \
|
|
211 VP8_LUMA_MC_FUNC(IDX, SIZE, OPT)
|
|
212
|
|
213 #define VP8_BILINEAR_MC_FUNC(IDX, SIZE, OPT) \
|
|
214 c->put_vp8_bilinear_pixels_tab[IDX][0][1] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
|
|
215 c->put_vp8_bilinear_pixels_tab[IDX][0][2] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
|
|
216 c->put_vp8_bilinear_pixels_tab[IDX][1][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
|
|
217 c->put_vp8_bilinear_pixels_tab[IDX][1][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
|
|
218 c->put_vp8_bilinear_pixels_tab[IDX][1][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
|
|
219 c->put_vp8_bilinear_pixels_tab[IDX][2][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
|
|
220 c->put_vp8_bilinear_pixels_tab[IDX][2][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
|
|
221 c->put_vp8_bilinear_pixels_tab[IDX][2][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT
|
|
222
|
11975
|
223
|
|
224 av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
|
|
225 {
|
|
226 mm_flags = mm_support();
|
|
227
|
11976
|
228 #if HAVE_YASM
|
11975
|
229 if (mm_flags & FF_MM_MMX) {
|
|
230 c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx;
|
11992
|
231 c->put_vp8_epel_pixels_tab[0][0][0] =
|
|
232 c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx;
|
|
233 c->put_vp8_epel_pixels_tab[1][0][0] =
|
|
234 c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx;
|
11975
|
235 }
|
|
236
|
|
237 /* note that 4-tap width=16 functions are missing because w=16
|
|
238 * is only used for luma, and luma is always a copy or sixtap. */
|
|
239 if (mm_flags & FF_MM_MMXEXT) {
|
11991
|
240 VP8_LUMA_MC_FUNC(0, 16, mmxext);
|
|
241 VP8_MC_FUNC(1, 8, mmxext);
|
|
242 VP8_MC_FUNC(1, 4, mmxext);
|
|
243 VP8_BILINEAR_MC_FUNC(0, 16, mmxext);
|
|
244 VP8_BILINEAR_MC_FUNC(1, 8, mmxext);
|
|
245 VP8_BILINEAR_MC_FUNC(1, 4, mmxext);
|
11975
|
246 }
|
|
247
|
11992
|
248 if (mm_flags & FF_MM_SSE) {
|
|
249 c->put_vp8_epel_pixels_tab[0][0][0] =
|
|
250 c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse;
|
|
251 }
|
|
252
|
11975
|
253 if (mm_flags & FF_MM_SSE2) {
|
11991
|
254 VP8_LUMA_MC_FUNC(0, 16, sse2);
|
|
255 VP8_MC_FUNC(1, 8, sse2);
|
|
256 VP8_BILINEAR_MC_FUNC(0, 16, sse2);
|
|
257 VP8_BILINEAR_MC_FUNC(1, 8, sse2);
|
11975
|
258 }
|
|
259
|
|
260 if (mm_flags & FF_MM_SSSE3) {
|
11991
|
261 VP8_LUMA_MC_FUNC(0, 16, ssse3);
|
|
262 VP8_MC_FUNC(1, 8, ssse3);
|
|
263 VP8_BILINEAR_MC_FUNC(0, 16, ssse3);
|
|
264 VP8_BILINEAR_MC_FUNC(1, 8, ssse3);
|
11975
|
265 }
|
|
266
|
|
267 if (mm_flags & FF_MM_SSE4) {
|
|
268 c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4;
|
|
269 }
|
11976
|
270 #endif
|
11975
|
271 }
|