Imported Debian version 2.4.3~trusty1
[deb_ffmpeg.git] / ffmpeg / libavcodec / x86 / hevcdsp_init.c
CommitLineData
2ba45a60
DM
1/*
2 * Copyright (c) 2013 Seppo Tomperi
3 * Copyright (c) 2013 - 2014 Pierre-Edouard Lepere
4 *
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 "config.h"
24#include "libavutil/cpu.h"
25#include "libavutil/x86/asm.h"
26#include "libavutil/x86/cpu.h"
27#include "libavcodec/get_bits.h" /* required for hevcdsp.h GetBitContext */
28#include "libavcodec/hevcdsp.h"
29#include "libavcodec/x86/hevcdsp.h"
30
31#define LFC_FUNC(DIR, DEPTH, OPT) \
32void ff_hevc_ ## DIR ## _loop_filter_chroma_ ## DEPTH ## _ ## OPT(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q);
33
34#define LFL_FUNC(DIR, DEPTH, OPT) \
35void ff_hevc_ ## DIR ## _loop_filter_luma_ ## DEPTH ## _ ## OPT(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q);
36
37#define LFC_FUNCS(type, depth, opt) \
38 LFC_FUNC(h, depth, opt) \
39 LFC_FUNC(v, depth, opt)
40
41#define LFL_FUNCS(type, depth, opt) \
42 LFL_FUNC(h, depth, opt) \
43 LFL_FUNC(v, depth, opt)
44
45LFC_FUNCS(uint8_t, 8, sse2)
46LFC_FUNCS(uint8_t, 10, sse2)
47LFC_FUNCS(uint8_t, 12, sse2)
48LFC_FUNCS(uint8_t, 8, avx)
49LFC_FUNCS(uint8_t, 10, avx)
50LFC_FUNCS(uint8_t, 12, avx)
51LFL_FUNCS(uint8_t, 8, sse2)
52LFL_FUNCS(uint8_t, 10, sse2)
53LFL_FUNCS(uint8_t, 12, sse2)
54LFL_FUNCS(uint8_t, 8, ssse3)
55LFL_FUNCS(uint8_t, 10, ssse3)
56LFL_FUNCS(uint8_t, 12, ssse3)
57LFL_FUNCS(uint8_t, 8, avx)
58LFL_FUNCS(uint8_t, 10, avx)
59LFL_FUNCS(uint8_t, 12, avx)
60
61#define IDCT_FUNCS(W, opt) \
62void ff_hevc_idct##W##_dc_8_##opt(int16_t *coeffs); \
63void ff_hevc_idct##W##_dc_10_##opt(int16_t *coeffs); \
64void ff_hevc_idct##W##_dc_12_##opt(int16_t *coeffs)
65
66IDCT_FUNCS(4x4, mmxext);
67IDCT_FUNCS(8x8, mmxext);
68IDCT_FUNCS(8x8, sse2);
69IDCT_FUNCS(16x16, sse2);
70IDCT_FUNCS(32x32, sse2);
71IDCT_FUNCS(16x16, avx2);
72IDCT_FUNCS(32x32, avx2);
73
74#define mc_rep_func(name, bitd, step, W, opt) \
75void ff_hevc_put_hevc_##name##W##_##bitd##_##opt(int16_t *_dst, \
76 uint8_t *_src, ptrdiff_t _srcstride, int height, \
77 intptr_t mx, intptr_t my, int width) \
78{ \
79 int i; \
80 uint8_t *src; \
81 int16_t *dst; \
82 for (i = 0; i < W; i += step) { \
83 src = _src + (i * ((bitd + 7) / 8)); \
84 dst = _dst + i; \
85 ff_hevc_put_hevc_##name##step##_##bitd##_##opt(dst, src, _srcstride, height, mx, my, width); \
86 } \
87}
88#define mc_rep_uni_func(name, bitd, step, W, opt) \
89void ff_hevc_put_hevc_uni_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, \
90 uint8_t *_src, ptrdiff_t _srcstride, int height, \
91 intptr_t mx, intptr_t my, int width) \
92{ \
93 int i; \
94 uint8_t *src; \
95 uint8_t *dst; \
96 for (i = 0; i < W; i += step) { \
97 src = _src + (i * ((bitd + 7) / 8)); \
98 dst = _dst + (i * ((bitd + 7) / 8)); \
99 ff_hevc_put_hevc_uni_##name##step##_##bitd##_##opt(dst, dststride, src, _srcstride, \
100 height, mx, my, width); \
101 } \
102}
103#define mc_rep_bi_func(name, bitd, step, W, opt) \
104void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, uint8_t *_src, \
105 ptrdiff_t _srcstride, int16_t* _src2, \
106 int height, intptr_t mx, intptr_t my, int width) \
107{ \
108 int i; \
109 uint8_t *src; \
110 uint8_t *dst; \
111 int16_t *src2; \
112 for (i = 0; i < W ; i += step) { \
113 src = _src + (i * ((bitd + 7) / 8)); \
114 dst = _dst + (i * ((bitd + 7) / 8)); \
115 src2 = _src2 + i; \
116 ff_hevc_put_hevc_bi_##name##step##_##bitd##_##opt(dst, dststride, src, _srcstride, src2, \
117 height, mx, my, width); \
118 } \
119}
120
121#define mc_rep_funcs(name, bitd, step, W, opt) \
122 mc_rep_func(name, bitd, step, W, opt); \
123 mc_rep_uni_func(name, bitd, step, W, opt); \
124 mc_rep_bi_func(name, bitd, step, W, opt)
125
126#define mc_rep_func2(name, bitd, step1, step2, W, opt) \
127void ff_hevc_put_hevc_##name##W##_##bitd##_##opt(int16_t *dst, \
128 uint8_t *src, ptrdiff_t _srcstride, int height, \
129 intptr_t mx, intptr_t my, int width) \
130{ \
131 ff_hevc_put_hevc_##name##step1##_##bitd##_##opt(dst, src, _srcstride, height, mx, my, width); \
132 ff_hevc_put_hevc_##name##step2##_##bitd##_##opt(dst + step1, src + (step1 * ((bitd + 7) / 8)), \
133 _srcstride, height, mx, my, width); \
134}
135#define mc_rep_uni_func2(name, bitd, step1, step2, W, opt) \
136void ff_hevc_put_hevc_uni_##name##W##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, \
137 uint8_t *src, ptrdiff_t _srcstride, int height, \
138 intptr_t mx, intptr_t my, int width) \
139{ \
140 ff_hevc_put_hevc_uni_##name##step1##_##bitd##_##opt(dst, dststride, src, _srcstride, height, mx, my, width);\
141 ff_hevc_put_hevc_uni_##name##step2##_##bitd##_##opt(dst + (step1 * ((bitd + 7) / 8)), dststride, \
142 src + (step1 * ((bitd + 7) / 8)), _srcstride, \
143 height, mx, my, width); \
144}
145#define mc_rep_bi_func2(name, bitd, step1, step2, W, opt) \
146void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
147 ptrdiff_t _srcstride, int16_t* src2, \
148 int height, intptr_t mx, intptr_t my, int width) \
149{ \
150 ff_hevc_put_hevc_bi_##name##step1##_##bitd##_##opt(dst, dststride, src, _srcstride, src2, height, mx, my, width);\
151 ff_hevc_put_hevc_bi_##name##step2##_##bitd##_##opt(dst + (step1 * ((bitd + 7) / 8)), dststride, \
152 src + (step1 * ((bitd + 7) / 8)), _srcstride, \
153 src2 + step1, height, mx, my, width); \
154}
155
156#define mc_rep_funcs(name, bitd, step, W, opt) \
157 mc_rep_func(name, bitd, step, W, opt); \
158 mc_rep_uni_func(name, bitd, step, W, opt); \
159 mc_rep_bi_func(name, bitd, step, W, opt)
160
161#define mc_rep_funcs2(name, bitd, step1, step2, W, opt) \
162 mc_rep_func2(name, bitd, step1, step2, W, opt); \
163 mc_rep_uni_func2(name, bitd, step1, step2, W, opt); \
164 mc_rep_bi_func2(name, bitd, step1, step2, W, opt)
165
166#if ARCH_X86_64 && HAVE_SSE4_EXTERNAL
167
168mc_rep_funcs(pel_pixels, 8, 16, 64, sse4);
169mc_rep_funcs(pel_pixels, 8, 16, 48, sse4);
170mc_rep_funcs(pel_pixels, 8, 16, 32, sse4);
171mc_rep_funcs(pel_pixels, 8, 8, 24, sse4);
172mc_rep_funcs(pel_pixels,10, 8, 64, sse4);
173mc_rep_funcs(pel_pixels,10, 8, 48, sse4);
174mc_rep_funcs(pel_pixels,10, 8, 32, sse4);
175mc_rep_funcs(pel_pixels,10, 8, 24, sse4);
176mc_rep_funcs(pel_pixels,10, 8, 16, sse4);
177mc_rep_funcs(pel_pixels,10, 4, 12, sse4);
178mc_rep_funcs(pel_pixels,12, 8, 64, sse4);
179mc_rep_funcs(pel_pixels,12, 8, 48, sse4);
180mc_rep_funcs(pel_pixels,12, 8, 32, sse4);
181mc_rep_funcs(pel_pixels,12, 8, 24, sse4);
182mc_rep_funcs(pel_pixels,12, 8, 16, sse4);
183mc_rep_funcs(pel_pixels,12, 4, 12, sse4);
184
185mc_rep_funcs(epel_h, 8, 16, 64, sse4);
186mc_rep_funcs(epel_h, 8, 16, 48, sse4);
187mc_rep_funcs(epel_h, 8, 16, 32, sse4);
188mc_rep_funcs(epel_h, 8, 8, 24, sse4);
189mc_rep_funcs(epel_h,10, 8, 64, sse4);
190mc_rep_funcs(epel_h,10, 8, 48, sse4);
191mc_rep_funcs(epel_h,10, 8, 32, sse4);
192mc_rep_funcs(epel_h,10, 8, 24, sse4);
193mc_rep_funcs(epel_h,10, 8, 16, sse4);
194mc_rep_funcs(epel_h,10, 4, 12, sse4);
195mc_rep_funcs(epel_h,12, 8, 64, sse4);
196mc_rep_funcs(epel_h,12, 8, 48, sse4);
197mc_rep_funcs(epel_h,12, 8, 32, sse4);
198mc_rep_funcs(epel_h,12, 8, 24, sse4);
199mc_rep_funcs(epel_h,12, 8, 16, sse4);
200mc_rep_funcs(epel_h,12, 4, 12, sse4);
201mc_rep_funcs(epel_v, 8, 16, 64, sse4);
202mc_rep_funcs(epel_v, 8, 16, 48, sse4);
203mc_rep_funcs(epel_v, 8, 16, 32, sse4);
204mc_rep_funcs(epel_v, 8, 8, 24, sse4);
205mc_rep_funcs(epel_v,10, 8, 64, sse4);
206mc_rep_funcs(epel_v,10, 8, 48, sse4);
207mc_rep_funcs(epel_v,10, 8, 32, sse4);
208mc_rep_funcs(epel_v,10, 8, 24, sse4);
209mc_rep_funcs(epel_v,10, 8, 16, sse4);
210mc_rep_funcs(epel_v,10, 4, 12, sse4);
211mc_rep_funcs(epel_v,12, 8, 64, sse4);
212mc_rep_funcs(epel_v,12, 8, 48, sse4);
213mc_rep_funcs(epel_v,12, 8, 32, sse4);
214mc_rep_funcs(epel_v,12, 8, 24, sse4);
215mc_rep_funcs(epel_v,12, 8, 16, sse4);
216mc_rep_funcs(epel_v,12, 4, 12, sse4);
217mc_rep_funcs(epel_hv, 8, 8, 64, sse4);
218mc_rep_funcs(epel_hv, 8, 8, 48, sse4);
219mc_rep_funcs(epel_hv, 8, 8, 32, sse4);
220mc_rep_funcs(epel_hv, 8, 8, 24, sse4);
221mc_rep_funcs(epel_hv, 8, 8, 16, sse4);
222mc_rep_funcs2(epel_hv,8, 8, 4, 12, sse4);
223mc_rep_funcs(epel_hv,10, 8, 64, sse4);
224mc_rep_funcs(epel_hv,10, 8, 48, sse4);
225mc_rep_funcs(epel_hv,10, 8, 32, sse4);
226mc_rep_funcs(epel_hv,10, 8, 24, sse4);
227mc_rep_funcs(epel_hv,10, 8, 16, sse4);
228mc_rep_funcs(epel_hv,10, 4, 12, sse4);
229mc_rep_funcs(epel_hv,12, 8, 64, sse4);
230mc_rep_funcs(epel_hv,12, 8, 48, sse4);
231mc_rep_funcs(epel_hv,12, 8, 32, sse4);
232mc_rep_funcs(epel_hv,12, 8, 24, sse4);
233mc_rep_funcs(epel_hv,12, 8, 16, sse4);
234mc_rep_funcs(epel_hv,12, 4, 12, sse4);
235
236mc_rep_funcs(qpel_h, 8, 16, 64, sse4);
237mc_rep_funcs(qpel_h, 8, 16, 48, sse4);
238mc_rep_funcs(qpel_h, 8, 16, 32, sse4);
239mc_rep_funcs(qpel_h, 8, 8, 24, sse4);
240mc_rep_funcs(qpel_h,10, 8, 64, sse4);
241mc_rep_funcs(qpel_h,10, 8, 48, sse4);
242mc_rep_funcs(qpel_h,10, 8, 32, sse4);
243mc_rep_funcs(qpel_h,10, 8, 24, sse4);
244mc_rep_funcs(qpel_h,10, 8, 16, sse4);
245mc_rep_funcs(qpel_h,10, 4, 12, sse4);
246mc_rep_funcs(qpel_h,12, 8, 64, sse4);
247mc_rep_funcs(qpel_h,12, 8, 48, sse4);
248mc_rep_funcs(qpel_h,12, 8, 32, sse4);
249mc_rep_funcs(qpel_h,12, 8, 24, sse4);
250mc_rep_funcs(qpel_h,12, 8, 16, sse4);
251mc_rep_funcs(qpel_h,12, 4, 12, sse4);
252mc_rep_funcs(qpel_v, 8, 16, 64, sse4);
253mc_rep_funcs(qpel_v, 8, 16, 48, sse4);
254mc_rep_funcs(qpel_v, 8, 16, 32, sse4);
255mc_rep_funcs(qpel_v, 8, 8, 24, sse4);
256mc_rep_funcs(qpel_v,10, 8, 64, sse4);
257mc_rep_funcs(qpel_v,10, 8, 48, sse4);
258mc_rep_funcs(qpel_v,10, 8, 32, sse4);
259mc_rep_funcs(qpel_v,10, 8, 24, sse4);
260mc_rep_funcs(qpel_v,10, 8, 16, sse4);
261mc_rep_funcs(qpel_v,10, 4, 12, sse4);
262mc_rep_funcs(qpel_v,12, 8, 64, sse4);
263mc_rep_funcs(qpel_v,12, 8, 48, sse4);
264mc_rep_funcs(qpel_v,12, 8, 32, sse4);
265mc_rep_funcs(qpel_v,12, 8, 24, sse4);
266mc_rep_funcs(qpel_v,12, 8, 16, sse4);
267mc_rep_funcs(qpel_v,12, 4, 12, sse4);
268mc_rep_funcs(qpel_hv, 8, 8, 64, sse4);
269mc_rep_funcs(qpel_hv, 8, 8, 48, sse4);
270mc_rep_funcs(qpel_hv, 8, 8, 32, sse4);
271mc_rep_funcs(qpel_hv, 8, 8, 24, sse4);
272mc_rep_funcs(qpel_hv, 8, 8, 16, sse4);
273mc_rep_funcs2(qpel_hv,8, 8, 4, 12, sse4);
274mc_rep_funcs(qpel_hv,10, 8, 64, sse4);
275mc_rep_funcs(qpel_hv,10, 8, 48, sse4);
276mc_rep_funcs(qpel_hv,10, 8, 32, sse4);
277mc_rep_funcs(qpel_hv,10, 8, 24, sse4);
278mc_rep_funcs(qpel_hv,10, 8, 16, sse4);
279mc_rep_funcs(qpel_hv,10, 4, 12, sse4);
280mc_rep_funcs(qpel_hv,12, 8, 64, sse4);
281mc_rep_funcs(qpel_hv,12, 8, 48, sse4);
282mc_rep_funcs(qpel_hv,12, 8, 32, sse4);
283mc_rep_funcs(qpel_hv,12, 8, 24, sse4);
284mc_rep_funcs(qpel_hv,12, 8, 16, sse4);
285mc_rep_funcs(qpel_hv,12, 4, 12, sse4);
286
287#define mc_rep_uni_w(bitd, step, W, opt) \
288void ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, ptrdiff_t _srcstride,\
289 int height, int denom, int _wx, int _ox) \
290{ \
291 int i; \
292 int16_t *src; \
293 uint8_t *dst; \
294 for (i = 0; i < W; i += step) { \
295 src= _src + i; \
296 dst= _dst + (i * ((bitd + 7) / 8)); \
297 ff_hevc_put_hevc_uni_w##step##_##bitd##_##opt(dst, dststride, src, _srcstride, \
298 height, denom, _wx, _ox); \
299 } \
300}
301
302mc_rep_uni_w(8, 6, 12, sse4);
303mc_rep_uni_w(8, 8, 16, sse4);
304mc_rep_uni_w(8, 8, 24, sse4);
305mc_rep_uni_w(8, 8, 32, sse4);
306mc_rep_uni_w(8, 8, 48, sse4);
307mc_rep_uni_w(8, 8, 64, sse4);
308
309mc_rep_uni_w(10, 6, 12, sse4);
310mc_rep_uni_w(10, 8, 16, sse4);
311mc_rep_uni_w(10, 8, 24, sse4);
312mc_rep_uni_w(10, 8, 32, sse4);
313mc_rep_uni_w(10, 8, 48, sse4);
314mc_rep_uni_w(10, 8, 64, sse4);
315
316mc_rep_uni_w(12, 6, 12, sse4);
317mc_rep_uni_w(12, 8, 16, sse4);
318mc_rep_uni_w(12, 8, 24, sse4);
319mc_rep_uni_w(12, 8, 32, sse4);
320mc_rep_uni_w(12, 8, 48, sse4);
321mc_rep_uni_w(12, 8, 64, sse4);
322
323#define mc_rep_bi_w(bitd, step, W, opt) \
324void ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, ptrdiff_t _srcstride, \
325 int16_t *_src2, int height, \
326 int denom, int _wx0, int _wx1, int _ox0, int _ox1) \
327{ \
328 int i; \
329 int16_t *src; \
330 int16_t *src2; \
331 uint8_t *dst; \
332 for (i = 0; i < W; i += step) { \
333 src = _src + i; \
334 src2 = _src2 + i; \
335 dst = _dst + (i * ((bitd + 7) / 8)); \
336 ff_hevc_put_hevc_bi_w##step##_##bitd##_##opt(dst, dststride, src, _srcstride, src2, \
337 height, denom, _wx0, _wx1, _ox0, _ox1); \
338 } \
339}
340
341mc_rep_bi_w(8, 6, 12, sse4);
342mc_rep_bi_w(8, 8, 16, sse4);
343mc_rep_bi_w(8, 8, 24, sse4);
344mc_rep_bi_w(8, 8, 32, sse4);
345mc_rep_bi_w(8, 8, 48, sse4);
346mc_rep_bi_w(8, 8, 64, sse4);
347
348mc_rep_bi_w(10, 6, 12, sse4);
349mc_rep_bi_w(10, 8, 16, sse4);
350mc_rep_bi_w(10, 8, 24, sse4);
351mc_rep_bi_w(10, 8, 32, sse4);
352mc_rep_bi_w(10, 8, 48, sse4);
353mc_rep_bi_w(10, 8, 64, sse4);
354
355mc_rep_bi_w(12, 6, 12, sse4);
356mc_rep_bi_w(12, 8, 16, sse4);
357mc_rep_bi_w(12, 8, 24, sse4);
358mc_rep_bi_w(12, 8, 32, sse4);
359mc_rep_bi_w(12, 8, 48, sse4);
360mc_rep_bi_w(12, 8, 64, sse4);
361
362#define mc_uni_w_func(name, bitd, W, opt) \
363void ff_hevc_put_hevc_uni_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride, \
364 uint8_t *_src, ptrdiff_t _srcstride, \
365 int height, int denom, \
366 int _wx, int _ox, \
367 intptr_t mx, intptr_t my, int width) \
368{ \
369 LOCAL_ALIGNED_16(int16_t, temp, [71 * MAX_PB_SIZE]); \
370 ff_hevc_put_hevc_##name##W##_##bitd##_##opt(temp, _src, _srcstride, height, mx, my, width); \
371 ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(_dst, _dststride, temp, MAX_PB_SIZE, height, denom, _wx, _ox);\
372}
373
374#define mc_uni_w_funcs(name, bitd, opt) \
375 mc_uni_w_func(name, bitd, 4, opt); \
376 mc_uni_w_func(name, bitd, 8, opt); \
377 mc_uni_w_func(name, bitd, 12, opt); \
378 mc_uni_w_func(name, bitd, 16, opt); \
379 mc_uni_w_func(name, bitd, 24, opt); \
380 mc_uni_w_func(name, bitd, 32, opt); \
381 mc_uni_w_func(name, bitd, 48, opt); \
382 mc_uni_w_func(name, bitd, 64, opt)
383
384mc_uni_w_funcs(pel_pixels, 8, sse4);
385mc_uni_w_func(pel_pixels, 8, 6, sse4);
386mc_uni_w_funcs(epel_h, 8, sse4);
387mc_uni_w_func(epel_h, 8, 6, sse4);
388mc_uni_w_funcs(epel_v, 8, sse4);
389mc_uni_w_func(epel_v, 8, 6, sse4);
390mc_uni_w_funcs(epel_hv, 8, sse4);
391mc_uni_w_func(epel_hv, 8, 6, sse4);
392mc_uni_w_funcs(qpel_h, 8, sse4);
393mc_uni_w_funcs(qpel_v, 8, sse4);
394mc_uni_w_funcs(qpel_hv, 8, sse4);
395
396mc_uni_w_funcs(pel_pixels, 10, sse4);
397mc_uni_w_func(pel_pixels, 10, 6, sse4);
398mc_uni_w_funcs(epel_h, 10, sse4);
399mc_uni_w_func(epel_h, 10, 6, sse4);
400mc_uni_w_funcs(epel_v, 10, sse4);
401mc_uni_w_func(epel_v, 10, 6, sse4);
402mc_uni_w_funcs(epel_hv, 10, sse4);
403mc_uni_w_func(epel_hv, 10, 6, sse4);
404mc_uni_w_funcs(qpel_h, 10, sse4);
405mc_uni_w_funcs(qpel_v, 10, sse4);
406mc_uni_w_funcs(qpel_hv, 10, sse4);
407
408mc_uni_w_funcs(pel_pixels, 12, sse4);
409mc_uni_w_func(pel_pixels, 12, 6, sse4);
410mc_uni_w_funcs(epel_h, 12, sse4);
411mc_uni_w_func(epel_h, 12, 6, sse4);
412mc_uni_w_funcs(epel_v, 12, sse4);
413mc_uni_w_func(epel_v, 12, 6, sse4);
414mc_uni_w_funcs(epel_hv, 12, sse4);
415mc_uni_w_func(epel_hv, 12, 6, sse4);
416mc_uni_w_funcs(qpel_h, 12, sse4);
417mc_uni_w_funcs(qpel_v, 12, sse4);
418mc_uni_w_funcs(qpel_hv, 12, sse4);
419
420#define mc_bi_w_func(name, bitd, W, opt) \
421void ff_hevc_put_hevc_bi_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride, \
422 uint8_t *_src, ptrdiff_t _srcstride, \
423 int16_t *_src2, \
424 int height, int denom, \
425 int _wx0, int _wx1, int _ox0, int _ox1, \
426 intptr_t mx, intptr_t my, int width) \
427{ \
428 LOCAL_ALIGNED_16(int16_t, temp, [71 * MAX_PB_SIZE]); \
429 ff_hevc_put_hevc_##name##W##_##bitd##_##opt(temp, _src, _srcstride, height, mx, my, width); \
430 ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(_dst, _dststride, temp, MAX_PB_SIZE, _src2, \
431 height, denom, _wx0, _wx1, _ox0, _ox1); \
432}
433
434#define mc_bi_w_funcs(name, bitd, opt) \
435 mc_bi_w_func(name, bitd, 4, opt); \
436 mc_bi_w_func(name, bitd, 8, opt); \
437 mc_bi_w_func(name, bitd, 12, opt); \
438 mc_bi_w_func(name, bitd, 16, opt); \
439 mc_bi_w_func(name, bitd, 24, opt); \
440 mc_bi_w_func(name, bitd, 32, opt); \
441 mc_bi_w_func(name, bitd, 48, opt); \
442 mc_bi_w_func(name, bitd, 64, opt)
443
444mc_bi_w_funcs(pel_pixels, 8, sse4);
445mc_bi_w_func(pel_pixels, 8, 6, sse4);
446mc_bi_w_funcs(epel_h, 8, sse4);
447mc_bi_w_func(epel_h, 8, 6, sse4);
448mc_bi_w_funcs(epel_v, 8, sse4);
449mc_bi_w_func(epel_v, 8, 6, sse4);
450mc_bi_w_funcs(epel_hv, 8, sse4);
451mc_bi_w_func(epel_hv, 8, 6, sse4);
452mc_bi_w_funcs(qpel_h, 8, sse4);
453mc_bi_w_funcs(qpel_v, 8, sse4);
454mc_bi_w_funcs(qpel_hv, 8, sse4);
455
456mc_bi_w_funcs(pel_pixels, 10, sse4);
457mc_bi_w_func(pel_pixels, 10, 6, sse4);
458mc_bi_w_funcs(epel_h, 10, sse4);
459mc_bi_w_func(epel_h, 10, 6, sse4);
460mc_bi_w_funcs(epel_v, 10, sse4);
461mc_bi_w_func(epel_v, 10, 6, sse4);
462mc_bi_w_funcs(epel_hv, 10, sse4);
463mc_bi_w_func(epel_hv, 10, 6, sse4);
464mc_bi_w_funcs(qpel_h, 10, sse4);
465mc_bi_w_funcs(qpel_v, 10, sse4);
466mc_bi_w_funcs(qpel_hv, 10, sse4);
467
468mc_bi_w_funcs(pel_pixels, 12, sse4);
469mc_bi_w_func(pel_pixels, 12, 6, sse4);
470mc_bi_w_funcs(epel_h, 12, sse4);
471mc_bi_w_func(epel_h, 12, 6, sse4);
472mc_bi_w_funcs(epel_v, 12, sse4);
473mc_bi_w_func(epel_v, 12, 6, sse4);
474mc_bi_w_funcs(epel_hv, 12, sse4);
475mc_bi_w_func(epel_hv, 12, 6, sse4);
476mc_bi_w_funcs(qpel_h, 12, sse4);
477mc_bi_w_funcs(qpel_v, 12, sse4);
478mc_bi_w_funcs(qpel_hv, 12, sse4);
479#endif //ARCH_X86_64 && HAVE_SSE4_EXTERNAL
480
481
482#define EPEL_LINKS(pointer, my, mx, fname, bitd, opt ) \
483 PEL_LINK(pointer, 1, my , mx , fname##4 , bitd, opt ); \
484 PEL_LINK(pointer, 2, my , mx , fname##6 , bitd, opt ); \
485 PEL_LINK(pointer, 3, my , mx , fname##8 , bitd, opt ); \
486 PEL_LINK(pointer, 4, my , mx , fname##12, bitd, opt ); \
487 PEL_LINK(pointer, 5, my , mx , fname##16, bitd, opt ); \
488 PEL_LINK(pointer, 6, my , mx , fname##24, bitd, opt ); \
489 PEL_LINK(pointer, 7, my , mx , fname##32, bitd, opt ); \
490 PEL_LINK(pointer, 8, my , mx , fname##48, bitd, opt ); \
491 PEL_LINK(pointer, 9, my , mx , fname##64, bitd, opt )
492#define QPEL_LINKS(pointer, my, mx, fname, bitd, opt) \
493 PEL_LINK(pointer, 1, my , mx , fname##4 , bitd, opt ); \
494 PEL_LINK(pointer, 3, my , mx , fname##8 , bitd, opt ); \
495 PEL_LINK(pointer, 4, my , mx , fname##12, bitd, opt ); \
496 PEL_LINK(pointer, 5, my , mx , fname##16, bitd, opt ); \
497 PEL_LINK(pointer, 6, my , mx , fname##24, bitd, opt ); \
498 PEL_LINK(pointer, 7, my , mx , fname##32, bitd, opt ); \
499 PEL_LINK(pointer, 8, my , mx , fname##48, bitd, opt ); \
500 PEL_LINK(pointer, 9, my , mx , fname##64, bitd, opt )
501
502
503void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
504{
505 int cpu_flags = av_get_cpu_flags();
506
507 if (bit_depth == 8) {
508 if (EXTERNAL_MMXEXT(cpu_flags)) {
509 c->idct_dc[0] = ff_hevc_idct4x4_dc_8_mmxext;
510 c->idct_dc[1] = ff_hevc_idct8x8_dc_8_mmxext;
511 c->transform_add[0] = ff_hevc_transform_add4_8_mmxext;
512 }
513 if (EXTERNAL_SSE2(cpu_flags)) {
514 c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_sse2;
515 c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_sse2;
516 if (ARCH_X86_64) {
517 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_sse2;
518 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_sse2;
519 }
520 c->idct_dc[1] = ff_hevc_idct8x8_dc_8_sse2;
521 c->idct_dc[2] = ff_hevc_idct16x16_dc_8_sse2;
522 c->idct_dc[3] = ff_hevc_idct32x32_dc_8_sse2;
523
524 c->transform_add[1] = ff_hevc_transform_add8_8_sse2;
525 c->transform_add[2] = ff_hevc_transform_add16_8_sse2;
526 c->transform_add[3] = ff_hevc_transform_add32_8_sse2;
527 }
528 if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) {
529 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_ssse3;
530 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_ssse3;
531 }
532 if (EXTERNAL_SSE4(cpu_flags) && ARCH_X86_64) {
533
534 EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 8, sse4);
535 EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 8, sse4);
536 EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 8, sse4);
537 EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 8, sse4);
538
539 QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 8, sse4);
540 QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 8, sse4);
541 QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 8, sse4);
542 QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 8, sse4);
543 }
544 if (EXTERNAL_AVX(cpu_flags)) {
545 c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_avx;
546 c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_avx;
547 if (ARCH_X86_64) {
548 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_avx;
549 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_avx;
550 }
551 c->transform_add[1] = ff_hevc_transform_add8_8_avx;
552 c->transform_add[2] = ff_hevc_transform_add16_8_avx;
553 c->transform_add[3] = ff_hevc_transform_add32_8_avx;
554 }
555 if (EXTERNAL_AVX2(cpu_flags)) {
556 c->idct_dc[2] = ff_hevc_idct16x16_dc_8_avx2;
557 c->idct_dc[3] = ff_hevc_idct32x32_dc_8_avx2;
558
559 c->transform_add[3] = ff_hevc_transform_add32_8_avx2;
560 }
561 } else if (bit_depth == 10) {
562 if (EXTERNAL_MMXEXT(cpu_flags)) {
563 c->transform_add[0] = ff_hevc_transform_add4_10_mmxext;
564 c->idct_dc[0] = ff_hevc_idct4x4_dc_10_mmxext;
565 c->idct_dc[1] = ff_hevc_idct8x8_dc_10_mmxext;
566 }
567 if (EXTERNAL_SSE2(cpu_flags)) {
568 c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_sse2;
569 c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_sse2;
570 if (ARCH_X86_64) {
571 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_sse2;
572 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_sse2;
573 }
574
575 c->idct_dc[1] = ff_hevc_idct8x8_dc_10_sse2;
576 c->idct_dc[2] = ff_hevc_idct16x16_dc_10_sse2;
577 c->idct_dc[3] = ff_hevc_idct32x32_dc_10_sse2;
578
579 c->transform_add[1] = ff_hevc_transform_add8_10_sse2;
580 c->transform_add[2] = ff_hevc_transform_add16_10_sse2;
581 c->transform_add[3] = ff_hevc_transform_add32_10_sse2;
582 }
583 if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) {
584 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_ssse3;
585 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_ssse3;
586 }
587 if (EXTERNAL_SSE4(cpu_flags) && ARCH_X86_64) {
588 EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 10, sse4);
589 EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 10, sse4);
590 EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 10, sse4);
591 EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 10, sse4);
592
593 QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 10, sse4);
594 QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 10, sse4);
595 QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 10, sse4);
596 QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 10, sse4);
597 }
598 if (EXTERNAL_AVX(cpu_flags)) {
599 c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_avx;
600 c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_avx;
601 if (ARCH_X86_64) {
602 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_avx;
603 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_avx;
604 }
605 }
606 if (EXTERNAL_AVX2(cpu_flags)) {
607
608 c->idct_dc[2] = ff_hevc_idct16x16_dc_10_avx2;
609 c->idct_dc[3] = ff_hevc_idct32x32_dc_10_avx2;
610
611 c->transform_add[2] = ff_hevc_transform_add16_10_avx2;
612 c->transform_add[3] = ff_hevc_transform_add32_10_avx2;
613
614 }
615 } else if (bit_depth == 12) {
616 if (EXTERNAL_MMXEXT(cpu_flags)) {
617 c->idct_dc[0] = ff_hevc_idct4x4_dc_12_mmxext;
618 c->idct_dc[1] = ff_hevc_idct8x8_dc_12_mmxext;
619 }
620 if (EXTERNAL_SSE2(cpu_flags)) {
621 c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_sse2;
622 c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_sse2;
623 if (ARCH_X86_64) {
624 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
625 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
626 }
627
628 c->idct_dc[1] = ff_hevc_idct8x8_dc_12_sse2;
629 c->idct_dc[2] = ff_hevc_idct16x16_dc_12_sse2;
630 c->idct_dc[3] = ff_hevc_idct32x32_dc_12_sse2;
631 }
632 if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) {
633 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_ssse3;
634 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_ssse3;
635 }
636 if (EXTERNAL_SSE4(cpu_flags) && ARCH_X86_64) {
637 EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 12, sse4);
638 EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h, 12, sse4);
639 EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v, 12, sse4);
640 EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv, 12, sse4);
641
642 QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 12, sse4);
643 QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h, 12, sse4);
644 QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v, 12, sse4);
645 QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 12, sse4);
646 }
647 if (EXTERNAL_AVX(cpu_flags)) {
648 c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_avx;
649 c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_avx;
650 if (ARCH_X86_64) {
651 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_avx;
652 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_avx;
653 }
654 }
655 if (EXTERNAL_AVX2(cpu_flags)) {
656 c->idct_dc[2] = ff_hevc_idct16x16_dc_12_avx2;
657 c->idct_dc[3] = ff_hevc_idct32x32_dc_12_avx2;
658 }
659 }
660}