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
|
|
26 /*
|
|
27 * MC functions
|
|
28 */
|
|
29 extern void ff_put_vp8_epel4_h4_mmxext(uint8_t *dst, int dststride,
|
|
30 uint8_t *src, int srcstride,
|
|
31 int height, int mx, int my);
|
|
32 extern void ff_put_vp8_epel4_h6_mmxext(uint8_t *dst, int dststride,
|
|
33 uint8_t *src, int srcstride,
|
|
34 int height, int mx, int my);
|
|
35 extern void ff_put_vp8_epel4_v4_mmxext(uint8_t *dst, int dststride,
|
|
36 uint8_t *src, int srcstride,
|
|
37 int height, int mx, int my);
|
|
38 extern void ff_put_vp8_epel4_v6_mmxext(uint8_t *dst, int dststride,
|
|
39 uint8_t *src, int srcstride,
|
|
40 int height, int mx, int my);
|
|
41
|
|
42 extern void ff_put_vp8_epel8_h4_sse2 (uint8_t *dst, int dststride,
|
|
43 uint8_t *src, int srcstride,
|
|
44 int height, int mx, int my);
|
|
45 extern void ff_put_vp8_epel8_h6_sse2 (uint8_t *dst, int dststride,
|
|
46 uint8_t *src, int srcstride,
|
|
47 int height, int mx, int my);
|
|
48 extern void ff_put_vp8_epel8_v4_sse2 (uint8_t *dst, int dststride,
|
|
49 uint8_t *src, int srcstride,
|
|
50 int height, int mx, int my);
|
|
51 extern void ff_put_vp8_epel8_v6_sse2 (uint8_t *dst, int dststride,
|
|
52 uint8_t *src, int srcstride,
|
|
53 int height, int mx, int my);
|
|
54
|
|
55 extern void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, int dststride,
|
|
56 uint8_t *src, int srcstride,
|
|
57 int height, int mx, int my);
|
|
58 extern void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, int dststride,
|
|
59 uint8_t *src, int srcstride,
|
|
60 int height, int mx, int my);
|
|
61 extern void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, int dststride,
|
|
62 uint8_t *src, int srcstride,
|
|
63 int height, int mx, int my);
|
|
64 extern void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, int dststride,
|
|
65 uint8_t *src, int srcstride,
|
|
66 int height, int mx, int my);
|
|
67
|
|
68 #define TAP_W16(OPT, TAPTYPE) \
|
|
69 static void ff_put_vp8_epel16_ ## TAPTYPE ## _ ## OPT(uint8_t *dst, \
|
|
70 int dststride, \
|
|
71 uint8_t *src, \
|
|
72 int srcstride, \
|
|
73 int height, \
|
|
74 int mx, int my) \
|
|
75 { \
|
|
76 ff_put_vp8_epel8_ ## TAPTYPE ## _ ## OPT(dst, dststride, \
|
|
77 src, srcstride, \
|
|
78 height, mx, my); \
|
|
79 ff_put_vp8_epel8_ ## TAPTYPE ## _ ## OPT(dst + 8, dststride, \
|
|
80 src + 8, srcstride, \
|
|
81 height, mx, my); \
|
|
82 }
|
|
83 #define TAP_W8(OPT, TAPTYPE) \
|
|
84 static void ff_put_vp8_epel8_ ## TAPTYPE ## _ ## OPT(uint8_t *dst, \
|
|
85 int dststride, \
|
|
86 uint8_t *src, \
|
|
87 int srcstride, \
|
|
88 int height, \
|
|
89 int mx, int my) \
|
|
90 { \
|
|
91 ff_put_vp8_epel4_ ## TAPTYPE ## _ ## OPT(dst, dststride, \
|
|
92 src, srcstride, \
|
|
93 height, mx, my); \
|
|
94 ff_put_vp8_epel4_ ## TAPTYPE ## _ ## OPT(dst + 4, dststride, \
|
|
95 src + 4, srcstride, \
|
|
96 height, mx, my); \
|
|
97 }
|
|
98
|
11976
|
99 #if HAVE_YASM
|
11975
|
100 TAP_W8 (mmxext, h4)
|
|
101 TAP_W8 (mmxext, h6)
|
|
102 TAP_W16(mmxext, h6)
|
|
103 TAP_W8 (mmxext, v4)
|
|
104 TAP_W8 (mmxext, v6)
|
|
105 TAP_W16(mmxext, v6)
|
|
106
|
|
107 TAP_W16(sse2, h6)
|
|
108 TAP_W16(sse2, v6)
|
|
109
|
|
110 TAP_W16(ssse3, h6)
|
|
111 TAP_W16(ssse3, v6)
|
11976
|
112 #endif
|
11975
|
113
|
|
114 #define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \
|
|
115 static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT \
|
|
116 (uint8_t *dst, int dststride, \
|
|
117 uint8_t *src, int srcstride, \
|
|
118 int height, int mx, int my) \
|
|
119 { \
|
|
120 DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \
|
|
121 uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \
|
|
122 src -= srcstride * (TAPNUMY / 2 - 1); \
|
|
123 ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## _ ## OPT(tmp, SIZE, \
|
|
124 src, srcstride, \
|
|
125 height + TAPNUMY - 1, \
|
|
126 mx, my); \
|
|
127 ff_put_vp8_epel ## SIZE ## _v ## TAPNUMY ## _ ## OPT(dst, dststride, \
|
|
128 tmpptr, SIZE, \
|
|
129 height, mx, my); \
|
|
130 }
|
|
131
|
|
132 #define HVTAPMMX(x, y) \
|
|
133 HVTAP(mmxext, 8, x, y, 4, 8) \
|
|
134 HVTAP(mmxext, 8, x, y, 8, 16)
|
|
135
|
11976
|
136 #if HAVE_YASM
|
11975
|
137 HVTAPMMX(4, 4)
|
|
138 HVTAPMMX(4, 6)
|
|
139 HVTAPMMX(6, 4)
|
|
140 HVTAPMMX(6, 6)
|
|
141 HVTAP(mmxext, 8, 6, 6, 16, 16)
|
11976
|
142 #endif
|
11975
|
143
|
|
144 #define HVTAPSSE2(x, y, w) \
|
|
145 HVTAP(sse2, 16, x, y, w, 16) \
|
|
146 HVTAP(ssse3, 16, x, y, w, 16)
|
|
147
|
11976
|
148 #if HAVE_YASM
|
11975
|
149 HVTAPSSE2(4, 4, 8)
|
|
150 HVTAPSSE2(4, 6, 8)
|
|
151 HVTAPSSE2(6, 4, 8)
|
|
152 HVTAPSSE2(6, 6, 8)
|
|
153 HVTAPSSE2(6, 6, 16)
|
11976
|
154 #endif
|
11975
|
155
|
|
156 extern void ff_vp8_idct_dc_add_mmx(uint8_t *dst, DCTELEM block[16], int stride);
|
|
157 extern void ff_vp8_idct_dc_add_sse4(uint8_t *dst, DCTELEM block[16], int stride);
|
|
158
|
|
159 av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
|
|
160 {
|
|
161 mm_flags = mm_support();
|
|
162
|
11976
|
163 #if HAVE_YASM
|
11975
|
164 if (mm_flags & FF_MM_MMX) {
|
|
165 c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx;
|
|
166 }
|
|
167
|
|
168 /* note that 4-tap width=16 functions are missing because w=16
|
|
169 * is only used for luma, and luma is always a copy or sixtap. */
|
|
170 if (mm_flags & FF_MM_MMXEXT) {
|
|
171 c->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_mmxext;
|
|
172 c->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_mmxext;
|
|
173 c->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_mmxext;
|
|
174 c->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_mmxext;
|
|
175 c->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_mmxext;
|
|
176 c->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_mmxext;
|
|
177 c->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_mmxext;
|
|
178 c->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_mmxext;
|
|
179 c->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_mmxext;
|
|
180 c->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_mmxext;
|
|
181 c->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_mmxext;
|
|
182 c->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_mmxext;
|
|
183 c->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_mmxext;
|
|
184 c->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_mmxext;
|
|
185 c->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_mmxext;
|
|
186 c->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_mmxext;
|
|
187 c->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_mmxext;
|
|
188 c->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_mmxext;
|
|
189 c->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_mmxext;
|
|
190 }
|
|
191
|
|
192 if (mm_flags & FF_MM_SSE2) {
|
|
193 c->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_sse2;
|
|
194 c->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_sse2;
|
|
195 c->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_sse2;
|
|
196 c->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_sse2;
|
|
197 c->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_sse2;
|
|
198 c->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_sse2;
|
|
199 c->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_sse2;
|
|
200 c->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_sse2;
|
|
201 c->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_sse2;
|
|
202 c->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_sse2;
|
|
203 c->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_sse2;
|
|
204 }
|
|
205
|
|
206 if (mm_flags & FF_MM_SSSE3) {
|
|
207 c->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_ssse3;
|
|
208 c->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_ssse3;
|
|
209 c->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_ssse3;
|
|
210 c->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_ssse3;
|
|
211 c->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_ssse3;
|
|
212 c->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_ssse3;
|
|
213 c->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_ssse3;
|
|
214 c->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_ssse3;
|
|
215 c->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_ssse3;
|
|
216 c->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_ssse3;
|
|
217 c->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_ssse3;
|
|
218 }
|
|
219
|
|
220 if (mm_flags & FF_MM_SSE4) {
|
|
221 c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4;
|
|
222 }
|
11976
|
223 #endif
|
11975
|
224 }
|