]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/hevcdsp_init.c
Merge commit '4885bde3187a2bb0cae85b67796e07db233bf77f'
[ffmpeg] / libavcodec / x86 / hevcdsp_init.c
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) \
32 void 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) \
35 void 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
45 LFC_FUNCS(uint8_t,   8, sse2)
46 LFC_FUNCS(uint8_t,  10, sse2)
47 LFC_FUNCS(uint8_t,  12, sse2)
48 LFC_FUNCS(uint8_t,   8, avx)
49 LFC_FUNCS(uint8_t,  10, avx)
50 LFC_FUNCS(uint8_t,  12, avx)
51 LFL_FUNCS(uint8_t,   8, sse2)
52 LFL_FUNCS(uint8_t,  10, sse2)
53 LFL_FUNCS(uint8_t,  12, sse2)
54 LFL_FUNCS(uint8_t,   8, ssse3)
55 LFL_FUNCS(uint8_t,  10, ssse3)
56 LFL_FUNCS(uint8_t,  12, ssse3)
57 LFL_FUNCS(uint8_t,   8, avx)
58 LFL_FUNCS(uint8_t,  10, avx)
59 LFL_FUNCS(uint8_t,  12, avx)
60
61 #define IDCT_FUNCS(W, opt) \
62 void ff_hevc_idct##W##_dc_8_##opt(int16_t *coeffs); \
63 void ff_hevc_idct##W##_dc_10_##opt(int16_t *coeffs); \
64 void ff_hevc_idct##W##_dc_12_##opt(int16_t *coeffs)
65
66 IDCT_FUNCS(4x4,   mmxext);
67 IDCT_FUNCS(8x8,   mmxext);
68 IDCT_FUNCS(8x8,   sse2);
69 IDCT_FUNCS(16x16, sse2);
70 IDCT_FUNCS(32x32, sse2);
71 IDCT_FUNCS(16x16, avx2);
72 IDCT_FUNCS(32x32, avx2);
73
74 #define mc_rep_func(name, bitd, step, W, opt) \
75 void 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) \
89 void 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) \
104 void 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) \
127 void 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) \
136 void 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) \
146 void 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
168 #define mc_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)                                       \
169 void ff_hevc_put_hevc_##name##width1##_10_##opt1(int16_t *dst, uint8_t *src, ptrdiff_t _srcstride,            \
170                                                  int height, intptr_t mx, intptr_t my, int width)             \
171                                                                                                               \
172 {                                                                                                             \
173     ff_hevc_put_hevc_##name##width2##_10_##opt1(dst, src, _srcstride, height, mx, my, width);                 \
174     ff_hevc_put_hevc_##name##width3##_10_##opt2(dst+ width2, src+ width4, _srcstride, height, mx, my, width); \
175 }
176
177 #define mc_bi_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)                                    \
178 void ff_hevc_put_hevc_bi_##name##width1##_10_##opt1(uint8_t *dst, ptrdiff_t dststride, uint8_t *src,          \
179                                                     ptrdiff_t _srcstride, int16_t *src2,                      \
180                                                     int height, intptr_t mx, intptr_t my, int width)          \
181 {                                                                                                             \
182     ff_hevc_put_hevc_bi_##name##width2##_10_##opt1(dst, dststride, src, _srcstride, src2,                     \
183                                                    height, mx, my, width);                                    \
184     ff_hevc_put_hevc_bi_##name##width3##_10_##opt2(dst+width4, dststride, src+width4, _srcstride, src2+width2,\
185                                                    height, mx, my, width);                                    \
186 }
187
188 #define mc_uni_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)                                   \
189 void ff_hevc_put_hevc_uni_##name##width1##_10_##opt1(uint8_t *dst, ptrdiff_t dststride,                       \
190                                                      uint8_t *src, ptrdiff_t _srcstride, int height,          \
191                                                      intptr_t mx, intptr_t my, int width)                     \
192 {                                                                                                             \
193     ff_hevc_put_hevc_uni_##name##width2##_10_##opt1(dst, dststride, src, _srcstride,                          \
194                                                       height, mx, my, width);                                 \
195     ff_hevc_put_hevc_uni_##name##width3##_10_##opt2(dst+width4, dststride, src+width4, _srcstride,            \
196                                                       height, mx, my, width);                                 \
197 }
198
199 #define mc_rep_mixs_10(name, width1, width2, width3, opt1, opt2, width4)    \
200 mc_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4);            \
201 mc_bi_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4);         \
202 mc_uni_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)
203
204 #define mc_rep_mix_8(name, width1, width2, width3, opt1, opt2)                                                \
205 void ff_hevc_put_hevc_##name##width1##_8_##opt1(int16_t *dst, uint8_t *src, ptrdiff_t _srcstride,             \
206                                                 int height, intptr_t mx, intptr_t my, int width)              \
207                                                                                                               \
208 {                                                                                                             \
209     ff_hevc_put_hevc_##name##width2##_8_##opt1(dst, src, _srcstride, height, mx, my, width);                  \
210     ff_hevc_put_hevc_##name##width3##_8_##opt2(dst+ width2, src+ width2, _srcstride, height, mx, my, width);  \
211 }
212
213 #define mc_bi_rep_mix_8(name, width1, width2, width3, opt1, opt2)                                             \
214 void ff_hevc_put_hevc_bi_##name##width1##_8_##opt1(uint8_t *dst, ptrdiff_t dststride, uint8_t *src,           \
215                                                    ptrdiff_t _srcstride, int16_t* src2,                       \
216                                                    int height, intptr_t mx, intptr_t my, int width)           \
217 {                                                                                                             \
218     ff_hevc_put_hevc_bi_##name##width2##_8_##opt1(dst, dststride, src, _srcstride,                            \
219                                                   src2, height, mx, my, width);                               \
220     ff_hevc_put_hevc_bi_##name##width3##_8_##opt2(dst+width2, dststride, src+width2, _srcstride,              \
221                                                   src2+width2, height, mx, my, width);                        \
222 }
223
224 #define mc_uni_rep_mix_8(name, width1, width2, width3, opt1, opt2)                                            \
225 void ff_hevc_put_hevc_uni_##name##width1##_8_##opt1(uint8_t *dst, ptrdiff_t dststride,                        \
226                                                     uint8_t *src, ptrdiff_t _srcstride, int height,           \
227                                                     intptr_t mx, intptr_t my, int width)                      \
228 {                                                                                                             \
229     ff_hevc_put_hevc_uni_##name##width2##_8_##opt1(dst, dststride, src, _srcstride,                           \
230                                                    height, mx, my, width);                                    \
231     ff_hevc_put_hevc_uni_##name##width3##_8_##opt2(dst+width2, dststride, src+width2, _srcstride,             \
232                                                    height, mx, my, width);                                    \
233 }
234
235 #define mc_rep_mixs_8(name, width1, width2, width3, opt1, opt2)    \
236 mc_rep_mix_8(name, width1, width2, width3, opt1, opt2);            \
237 mc_bi_rep_mix_8(name, width1, width2, width3, opt1, opt2);         \
238 mc_uni_rep_mix_8(name, width1, width2, width3, opt1, opt2)
239
240 #if HAVE_AVX2_EXTERNAL
241
242 mc_rep_mixs_8(pel_pixels, 48, 32, 16, avx2, sse4);
243 mc_rep_mixs_8(epel_hv,    48, 32, 16, avx2, sse4);
244 mc_rep_mixs_8(epel_h ,    48, 32, 16, avx2, sse4);
245 mc_rep_mixs_8(epel_v ,    48, 32, 16, avx2, sse4);
246
247 mc_rep_mix_10(pel_pixels, 24, 16, 8, avx2, sse4, 32);
248 mc_bi_rep_mix_10(pel_pixels,24, 16, 8, avx2, sse4, 32);
249 mc_rep_mixs_10(epel_hv,   24, 16, 8, avx2, sse4, 32);
250 mc_rep_mixs_10(epel_h ,   24, 16, 8, avx2, sse4, 32);
251 mc_rep_mixs_10(epel_v ,   24, 16, 8, avx2, sse4, 32);
252
253
254 mc_rep_mixs_10(qpel_h ,   24, 16, 8, avx2, sse4, 32);
255 mc_rep_mixs_10(qpel_v ,   24, 16, 8, avx2, sse4, 32);
256 mc_rep_mixs_10(qpel_hv,   24, 16, 8, avx2, sse4, 32);
257
258
259 mc_rep_uni_func(pel_pixels, 8, 64, 128, avx2);//used for 10bit
260 mc_rep_uni_func(pel_pixels, 8, 32, 96, avx2); //used for 10bit
261
262 mc_rep_funcs(pel_pixels, 8, 32, 64, avx2);
263
264 mc_rep_func(pel_pixels, 10, 16, 32, avx2);
265 mc_rep_func(pel_pixels, 10, 16, 48, avx2);
266 mc_rep_func(pel_pixels, 10, 32, 64, avx2);
267
268 mc_rep_bi_func(pel_pixels, 10, 16, 32, avx2);
269 mc_rep_bi_func(pel_pixels, 10, 16, 48, avx2);
270 mc_rep_bi_func(pel_pixels, 10, 32, 64, avx2);
271
272 mc_rep_funcs(epel_h, 8, 32, 64, avx2);
273
274 mc_rep_funcs(epel_v, 8, 32, 64, avx2);
275
276 mc_rep_funcs(epel_h, 10, 16, 32, avx2);
277 mc_rep_funcs(epel_h, 10, 16, 48, avx2);
278 mc_rep_funcs(epel_h, 10, 32, 64, avx2);
279
280 mc_rep_funcs(epel_v, 10, 16, 32, avx2);
281 mc_rep_funcs(epel_v, 10, 16, 48, avx2);
282 mc_rep_funcs(epel_v, 10, 32, 64, avx2);
283
284
285 mc_rep_funcs(epel_hv,  8, 32, 64, avx2);
286
287 mc_rep_funcs(epel_hv, 10, 16, 32, avx2);
288 mc_rep_funcs(epel_hv, 10, 16, 48, avx2);
289 mc_rep_funcs(epel_hv, 10, 32, 64, avx2);
290
291 mc_rep_funcs(qpel_h, 8, 32, 64, avx2);
292 mc_rep_mixs_8(qpel_h ,  48, 32, 16, avx2, sse4);
293
294 mc_rep_funcs(qpel_v, 8, 32, 64, avx2);
295 mc_rep_mixs_8(qpel_v,  48, 32, 16, avx2, sse4);
296
297 mc_rep_funcs(qpel_h, 10, 16, 32, avx2);
298 mc_rep_funcs(qpel_h, 10, 16, 48, avx2);
299 mc_rep_funcs(qpel_h, 10, 32, 64, avx2);
300
301 mc_rep_funcs(qpel_v, 10, 16, 32, avx2);
302 mc_rep_funcs(qpel_v, 10, 16, 48, avx2);
303 mc_rep_funcs(qpel_v, 10, 32, 64, avx2);
304
305 mc_rep_funcs(qpel_hv, 10, 16, 32, avx2);
306 mc_rep_funcs(qpel_hv, 10, 16, 48, avx2);
307 mc_rep_funcs(qpel_hv, 10, 32, 64, avx2);
308
309 #endif //AVX2
310
311 mc_rep_funcs(pel_pixels, 8, 16, 64, sse4);
312 mc_rep_funcs(pel_pixels, 8, 16, 48, sse4);
313 mc_rep_funcs(pel_pixels, 8, 16, 32, sse4);
314 mc_rep_funcs(pel_pixels, 8,  8, 24, sse4);
315 mc_rep_funcs(pel_pixels,10,  8, 64, sse4);
316 mc_rep_funcs(pel_pixels,10,  8, 48, sse4);
317 mc_rep_funcs(pel_pixels,10,  8, 32, sse4);
318 mc_rep_funcs(pel_pixels,10,  8, 24, sse4);
319 mc_rep_funcs(pel_pixels,10,  8, 16, sse4);
320 mc_rep_funcs(pel_pixels,10,  4, 12, sse4);
321 mc_rep_funcs(pel_pixels,12,  8, 64, sse4);
322 mc_rep_funcs(pel_pixels,12,  8, 48, sse4);
323 mc_rep_funcs(pel_pixels,12,  8, 32, sse4);
324 mc_rep_funcs(pel_pixels,12,  8, 24, sse4);
325 mc_rep_funcs(pel_pixels,12,  8, 16, sse4);
326 mc_rep_funcs(pel_pixels,12,  4, 12, sse4);
327
328 mc_rep_funcs(epel_h, 8, 16, 64, sse4);
329 mc_rep_funcs(epel_h, 8, 16, 48, sse4);
330 mc_rep_funcs(epel_h, 8, 16, 32, sse4);
331 mc_rep_funcs(epel_h, 8,  8, 24, sse4);
332 mc_rep_funcs(epel_h,10,  8, 64, sse4);
333 mc_rep_funcs(epel_h,10,  8, 48, sse4);
334 mc_rep_funcs(epel_h,10,  8, 32, sse4);
335 mc_rep_funcs(epel_h,10,  8, 24, sse4);
336 mc_rep_funcs(epel_h,10,  8, 16, sse4);
337 mc_rep_funcs(epel_h,10,  4, 12, sse4);
338 mc_rep_funcs(epel_h,12,  8, 64, sse4);
339 mc_rep_funcs(epel_h,12,  8, 48, sse4);
340 mc_rep_funcs(epel_h,12,  8, 32, sse4);
341 mc_rep_funcs(epel_h,12,  8, 24, sse4);
342 mc_rep_funcs(epel_h,12,  8, 16, sse4);
343 mc_rep_funcs(epel_h,12,  4, 12, sse4);
344 mc_rep_funcs(epel_v, 8, 16, 64, sse4);
345 mc_rep_funcs(epel_v, 8, 16, 48, sse4);
346 mc_rep_funcs(epel_v, 8, 16, 32, sse4);
347 mc_rep_funcs(epel_v, 8,  8, 24, sse4);
348 mc_rep_funcs(epel_v,10,  8, 64, sse4);
349 mc_rep_funcs(epel_v,10,  8, 48, sse4);
350 mc_rep_funcs(epel_v,10,  8, 32, sse4);
351 mc_rep_funcs(epel_v,10,  8, 24, sse4);
352 mc_rep_funcs(epel_v,10,  8, 16, sse4);
353 mc_rep_funcs(epel_v,10,  4, 12, sse4);
354 mc_rep_funcs(epel_v,12,  8, 64, sse4);
355 mc_rep_funcs(epel_v,12,  8, 48, sse4);
356 mc_rep_funcs(epel_v,12,  8, 32, sse4);
357 mc_rep_funcs(epel_v,12,  8, 24, sse4);
358 mc_rep_funcs(epel_v,12,  8, 16, sse4);
359 mc_rep_funcs(epel_v,12,  4, 12, sse4);
360 mc_rep_funcs(epel_hv, 8, 16, 64, sse4);
361 mc_rep_funcs(epel_hv, 8, 16, 48, sse4);
362 mc_rep_funcs(epel_hv, 8, 16, 32, sse4);
363 mc_rep_funcs(epel_hv, 8,  8, 24, sse4);
364 mc_rep_funcs2(epel_hv,8,  8,  4, 12, sse4);
365 mc_rep_funcs(epel_hv,10,  8, 64, sse4);
366 mc_rep_funcs(epel_hv,10,  8, 48, sse4);
367 mc_rep_funcs(epel_hv,10,  8, 32, sse4);
368 mc_rep_funcs(epel_hv,10,  8, 24, sse4);
369 mc_rep_funcs(epel_hv,10,  8, 16, sse4);
370 mc_rep_funcs(epel_hv,10,  4, 12, sse4);
371 mc_rep_funcs(epel_hv,12,  8, 64, sse4);
372 mc_rep_funcs(epel_hv,12,  8, 48, sse4);
373 mc_rep_funcs(epel_hv,12,  8, 32, sse4);
374 mc_rep_funcs(epel_hv,12,  8, 24, sse4);
375 mc_rep_funcs(epel_hv,12,  8, 16, sse4);
376 mc_rep_funcs(epel_hv,12,  4, 12, sse4);
377
378 mc_rep_funcs(qpel_h, 8, 16, 64, sse4);
379 mc_rep_funcs(qpel_h, 8, 16, 48, sse4);
380 mc_rep_funcs(qpel_h, 8, 16, 32, sse4);
381 mc_rep_funcs(qpel_h, 8,  8, 24, sse4);
382 mc_rep_funcs(qpel_h,10,  8, 64, sse4);
383 mc_rep_funcs(qpel_h,10,  8, 48, sse4);
384 mc_rep_funcs(qpel_h,10,  8, 32, sse4);
385 mc_rep_funcs(qpel_h,10,  8, 24, sse4);
386 mc_rep_funcs(qpel_h,10,  8, 16, sse4);
387 mc_rep_funcs(qpel_h,10,  4, 12, sse4);
388 mc_rep_funcs(qpel_h,12,  8, 64, sse4);
389 mc_rep_funcs(qpel_h,12,  8, 48, sse4);
390 mc_rep_funcs(qpel_h,12,  8, 32, sse4);
391 mc_rep_funcs(qpel_h,12,  8, 24, sse4);
392 mc_rep_funcs(qpel_h,12,  8, 16, sse4);
393 mc_rep_funcs(qpel_h,12,  4, 12, sse4);
394 mc_rep_funcs(qpel_v, 8, 16, 64, sse4);
395 mc_rep_funcs(qpel_v, 8, 16, 48, sse4);
396 mc_rep_funcs(qpel_v, 8, 16, 32, sse4);
397 mc_rep_funcs(qpel_v, 8,  8, 24, sse4);
398 mc_rep_funcs(qpel_v,10,  8, 64, sse4);
399 mc_rep_funcs(qpel_v,10,  8, 48, sse4);
400 mc_rep_funcs(qpel_v,10,  8, 32, sse4);
401 mc_rep_funcs(qpel_v,10,  8, 24, sse4);
402 mc_rep_funcs(qpel_v,10,  8, 16, sse4);
403 mc_rep_funcs(qpel_v,10,  4, 12, sse4);
404 mc_rep_funcs(qpel_v,12,  8, 64, sse4);
405 mc_rep_funcs(qpel_v,12,  8, 48, sse4);
406 mc_rep_funcs(qpel_v,12,  8, 32, sse4);
407 mc_rep_funcs(qpel_v,12,  8, 24, sse4);
408 mc_rep_funcs(qpel_v,12,  8, 16, sse4);
409 mc_rep_funcs(qpel_v,12,  4, 12, sse4);
410 mc_rep_funcs(qpel_hv, 8,  8, 64, sse4);
411 mc_rep_funcs(qpel_hv, 8,  8, 48, sse4);
412 mc_rep_funcs(qpel_hv, 8,  8, 32, sse4);
413 mc_rep_funcs(qpel_hv, 8,  8, 24, sse4);
414 mc_rep_funcs(qpel_hv, 8,  8, 16, sse4);
415 mc_rep_funcs2(qpel_hv,8,  8,  4, 12, sse4);
416 mc_rep_funcs(qpel_hv,10,  8, 64, sse4);
417 mc_rep_funcs(qpel_hv,10,  8, 48, sse4);
418 mc_rep_funcs(qpel_hv,10,  8, 32, sse4);
419 mc_rep_funcs(qpel_hv,10,  8, 24, sse4);
420 mc_rep_funcs(qpel_hv,10,  8, 16, sse4);
421 mc_rep_funcs(qpel_hv,10,  4, 12, sse4);
422 mc_rep_funcs(qpel_hv,12,  8, 64, sse4);
423 mc_rep_funcs(qpel_hv,12,  8, 48, sse4);
424 mc_rep_funcs(qpel_hv,12,  8, 32, sse4);
425 mc_rep_funcs(qpel_hv,12,  8, 24, sse4);
426 mc_rep_funcs(qpel_hv,12,  8, 16, sse4);
427 mc_rep_funcs(qpel_hv,12,  4, 12, sse4);
428
429 #define mc_rep_uni_w(bitd, step, W, opt) \
430 void ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, \
431                                                int height, int denom,  int _wx, int _ox)                                \
432 {                                                                                                                       \
433     int i;                                                                                                              \
434     int16_t *src;                                                                                                       \
435     uint8_t *dst;                                                                                                       \
436     for (i = 0; i < W; i += step) {                                                                                     \
437         src= _src + i;                                                                                                  \
438         dst= _dst + (i * ((bitd + 7) / 8));                                                                             \
439         ff_hevc_put_hevc_uni_w##step##_##bitd##_##opt(dst, dststride, src,                                   \
440                                                      height, denom, _wx, _ox);                                          \
441     }                                                                                                                   \
442 }
443
444 mc_rep_uni_w(8, 6, 12, sse4);
445 mc_rep_uni_w(8, 8, 16, sse4);
446 mc_rep_uni_w(8, 8, 24, sse4);
447 mc_rep_uni_w(8, 8, 32, sse4);
448 mc_rep_uni_w(8, 8, 48, sse4);
449 mc_rep_uni_w(8, 8, 64, sse4);
450
451 mc_rep_uni_w(10, 6, 12, sse4);
452 mc_rep_uni_w(10, 8, 16, sse4);
453 mc_rep_uni_w(10, 8, 24, sse4);
454 mc_rep_uni_w(10, 8, 32, sse4);
455 mc_rep_uni_w(10, 8, 48, sse4);
456 mc_rep_uni_w(10, 8, 64, sse4);
457
458 mc_rep_uni_w(12, 6, 12, sse4);
459 mc_rep_uni_w(12, 8, 16, sse4);
460 mc_rep_uni_w(12, 8, 24, sse4);
461 mc_rep_uni_w(12, 8, 32, sse4);
462 mc_rep_uni_w(12, 8, 48, sse4);
463 mc_rep_uni_w(12, 8, 64, sse4);
464
465 #define mc_rep_bi_w(bitd, step, W, opt) \
466 void ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, \
467                                               int16_t *_src2, int height,                                               \
468                                               int denom,  int _wx0,  int _wx1, int _ox0, int _ox1)                      \
469 {                                                                                                                       \
470     int i;                                                                                                              \
471     int16_t *src;                                                                                                       \
472     int16_t *src2;                                                                                                      \
473     uint8_t *dst;                                                                                                       \
474     for (i = 0; i < W; i += step) {                                                                                     \
475         src  = _src  + i;                                                                                               \
476         src2 = _src2 + i;                                                                                               \
477         dst  = _dst  + (i * ((bitd + 7) / 8));                                                                          \
478         ff_hevc_put_hevc_bi_w##step##_##bitd##_##opt(dst, dststride, src, src2,                             \
479                                                      height, denom, _wx0, _wx1, _ox0, _ox1);                             \
480     }                                                                                                                   \
481 }
482
483 mc_rep_bi_w(8, 6, 12, sse4);
484 mc_rep_bi_w(8, 8, 16, sse4);
485 mc_rep_bi_w(8, 8, 24, sse4);
486 mc_rep_bi_w(8, 8, 32, sse4);
487 mc_rep_bi_w(8, 8, 48, sse4);
488 mc_rep_bi_w(8, 8, 64, sse4);
489
490 mc_rep_bi_w(10, 6, 12, sse4);
491 mc_rep_bi_w(10, 8, 16, sse4);
492 mc_rep_bi_w(10, 8, 24, sse4);
493 mc_rep_bi_w(10, 8, 32, sse4);
494 mc_rep_bi_w(10, 8, 48, sse4);
495 mc_rep_bi_w(10, 8, 64, sse4);
496
497 mc_rep_bi_w(12, 6, 12, sse4);
498 mc_rep_bi_w(12, 8, 16, sse4);
499 mc_rep_bi_w(12, 8, 24, sse4);
500 mc_rep_bi_w(12, 8, 32, sse4);
501 mc_rep_bi_w(12, 8, 48, sse4);
502 mc_rep_bi_w(12, 8, 64, sse4);
503
504 #define mc_uni_w_func(name, bitd, W, opt) \
505 void ff_hevc_put_hevc_uni_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride,         \
506                                                       uint8_t *_src, ptrdiff_t _srcstride,          \
507                                                       int height, int denom,                        \
508                                                       int _wx, int _ox,                             \
509                                                       intptr_t mx, intptr_t my, int width)          \
510 {                                                                                                   \
511     LOCAL_ALIGNED_16(int16_t, temp, [71 * MAX_PB_SIZE]);                                            \
512     ff_hevc_put_hevc_##name##W##_##bitd##_##opt(temp, _src, _srcstride, height, mx, my, width);     \
513     ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(_dst, _dststride, temp, height, denom, _wx, _ox);\
514 }
515
516 #define mc_uni_w_funcs(name, bitd, opt)       \
517         mc_uni_w_func(name, bitd, 4, opt);    \
518         mc_uni_w_func(name, bitd, 8, opt);    \
519         mc_uni_w_func(name, bitd, 12, opt);   \
520         mc_uni_w_func(name, bitd, 16, opt);   \
521         mc_uni_w_func(name, bitd, 24, opt);   \
522         mc_uni_w_func(name, bitd, 32, opt);   \
523         mc_uni_w_func(name, bitd, 48, opt);   \
524         mc_uni_w_func(name, bitd, 64, opt)
525
526 mc_uni_w_funcs(pel_pixels, 8, sse4);
527 mc_uni_w_func(pel_pixels, 8, 6, sse4);
528 mc_uni_w_funcs(epel_h, 8, sse4);
529 mc_uni_w_func(epel_h, 8, 6, sse4);
530 mc_uni_w_funcs(epel_v, 8, sse4);
531 mc_uni_w_func(epel_v, 8, 6, sse4);
532 mc_uni_w_funcs(epel_hv, 8, sse4);
533 mc_uni_w_func(epel_hv, 8, 6, sse4);
534 mc_uni_w_funcs(qpel_h, 8, sse4);
535 mc_uni_w_funcs(qpel_v, 8, sse4);
536 mc_uni_w_funcs(qpel_hv, 8, sse4);
537
538 mc_uni_w_funcs(pel_pixels, 10, sse4);
539 mc_uni_w_func(pel_pixels, 10, 6, sse4);
540 mc_uni_w_funcs(epel_h, 10, sse4);
541 mc_uni_w_func(epel_h, 10, 6, sse4);
542 mc_uni_w_funcs(epel_v, 10, sse4);
543 mc_uni_w_func(epel_v, 10, 6, sse4);
544 mc_uni_w_funcs(epel_hv, 10, sse4);
545 mc_uni_w_func(epel_hv, 10, 6, sse4);
546 mc_uni_w_funcs(qpel_h, 10, sse4);
547 mc_uni_w_funcs(qpel_v, 10, sse4);
548 mc_uni_w_funcs(qpel_hv, 10, sse4);
549
550 mc_uni_w_funcs(pel_pixels, 12, sse4);
551 mc_uni_w_func(pel_pixels, 12, 6, sse4);
552 mc_uni_w_funcs(epel_h, 12, sse4);
553 mc_uni_w_func(epel_h, 12, 6, sse4);
554 mc_uni_w_funcs(epel_v, 12, sse4);
555 mc_uni_w_func(epel_v, 12, 6, sse4);
556 mc_uni_w_funcs(epel_hv, 12, sse4);
557 mc_uni_w_func(epel_hv, 12, 6, sse4);
558 mc_uni_w_funcs(qpel_h, 12, sse4);
559 mc_uni_w_funcs(qpel_v, 12, sse4);
560 mc_uni_w_funcs(qpel_hv, 12, sse4);
561
562 #define mc_bi_w_func(name, bitd, W, opt) \
563 void ff_hevc_put_hevc_bi_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride,           \
564                                                      uint8_t *_src, ptrdiff_t _srcstride,            \
565                                                      int16_t *_src2,                                 \
566                                                      int height, int denom,                          \
567                                                      int _wx0, int _wx1, int _ox0, int _ox1,         \
568                                                      intptr_t mx, intptr_t my, int width)            \
569 {                                                                                                    \
570     LOCAL_ALIGNED_16(int16_t, temp, [71 * MAX_PB_SIZE]);                                             \
571     ff_hevc_put_hevc_##name##W##_##bitd##_##opt(temp, _src, _srcstride, height, mx, my, width);      \
572     ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(_dst, _dststride, temp, _src2,                         \
573                                               height, denom, _wx0, _wx1, _ox0, _ox1);                \
574 }
575
576 #define mc_bi_w_funcs(name, bitd, opt)       \
577         mc_bi_w_func(name, bitd, 4, opt);    \
578         mc_bi_w_func(name, bitd, 8, opt);    \
579         mc_bi_w_func(name, bitd, 12, opt);   \
580         mc_bi_w_func(name, bitd, 16, opt);   \
581         mc_bi_w_func(name, bitd, 24, opt);   \
582         mc_bi_w_func(name, bitd, 32, opt);   \
583         mc_bi_w_func(name, bitd, 48, opt);   \
584         mc_bi_w_func(name, bitd, 64, opt)
585
586 mc_bi_w_funcs(pel_pixels, 8, sse4);
587 mc_bi_w_func(pel_pixels, 8, 6, sse4);
588 mc_bi_w_funcs(epel_h, 8, sse4);
589 mc_bi_w_func(epel_h, 8, 6, sse4);
590 mc_bi_w_funcs(epel_v, 8, sse4);
591 mc_bi_w_func(epel_v, 8, 6, sse4);
592 mc_bi_w_funcs(epel_hv, 8, sse4);
593 mc_bi_w_func(epel_hv, 8, 6, sse4);
594 mc_bi_w_funcs(qpel_h, 8, sse4);
595 mc_bi_w_funcs(qpel_v, 8, sse4);
596 mc_bi_w_funcs(qpel_hv, 8, sse4);
597
598 mc_bi_w_funcs(pel_pixels, 10, sse4);
599 mc_bi_w_func(pel_pixels, 10, 6, sse4);
600 mc_bi_w_funcs(epel_h, 10, sse4);
601 mc_bi_w_func(epel_h, 10, 6, sse4);
602 mc_bi_w_funcs(epel_v, 10, sse4);
603 mc_bi_w_func(epel_v, 10, 6, sse4);
604 mc_bi_w_funcs(epel_hv, 10, sse4);
605 mc_bi_w_func(epel_hv, 10, 6, sse4);
606 mc_bi_w_funcs(qpel_h, 10, sse4);
607 mc_bi_w_funcs(qpel_v, 10, sse4);
608 mc_bi_w_funcs(qpel_hv, 10, sse4);
609
610 mc_bi_w_funcs(pel_pixels, 12, sse4);
611 mc_bi_w_func(pel_pixels, 12, 6, sse4);
612 mc_bi_w_funcs(epel_h, 12, sse4);
613 mc_bi_w_func(epel_h, 12, 6, sse4);
614 mc_bi_w_funcs(epel_v, 12, sse4);
615 mc_bi_w_func(epel_v, 12, 6, sse4);
616 mc_bi_w_funcs(epel_hv, 12, sse4);
617 mc_bi_w_func(epel_hv, 12, 6, sse4);
618 mc_bi_w_funcs(qpel_h, 12, sse4);
619 mc_bi_w_funcs(qpel_v, 12, sse4);
620 mc_bi_w_funcs(qpel_hv, 12, sse4);
621 #endif //ARCH_X86_64 && HAVE_SSE4_EXTERNAL
622
623 #define SAO_BAND_FILTER_FUNCS(bitd, opt)                                                                                   \
624 void ff_hevc_sao_band_filter_8_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,  \
625                                             int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
626 void ff_hevc_sao_band_filter_16_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
627                                             int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
628 void ff_hevc_sao_band_filter_32_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
629                                             int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
630 void ff_hevc_sao_band_filter_48_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
631                                             int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
632 void ff_hevc_sao_band_filter_64_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
633                                              int16_t *sao_offset_val, int sao_left_class, int width, int height)
634
635 SAO_BAND_FILTER_FUNCS(8,  sse2);
636 SAO_BAND_FILTER_FUNCS(10, sse2);
637 SAO_BAND_FILTER_FUNCS(12, sse2);
638 SAO_BAND_FILTER_FUNCS(8,   avx);
639 SAO_BAND_FILTER_FUNCS(10,  avx);
640 SAO_BAND_FILTER_FUNCS(12,  avx);
641 SAO_BAND_FILTER_FUNCS(8,  avx2);
642 SAO_BAND_FILTER_FUNCS(10, avx2);
643 SAO_BAND_FILTER_FUNCS(12, avx2);
644
645 #define SAO_BAND_INIT(bitd, opt) do {                                       \
646     c->sao_band_filter[0]      = ff_hevc_sao_band_filter_8_##bitd##_##opt;  \
647     c->sao_band_filter[1]      = ff_hevc_sao_band_filter_16_##bitd##_##opt; \
648     c->sao_band_filter[2]      = ff_hevc_sao_band_filter_32_##bitd##_##opt; \
649     c->sao_band_filter[3]      = ff_hevc_sao_band_filter_48_##bitd##_##opt; \
650     c->sao_band_filter[4]      = ff_hevc_sao_band_filter_64_##bitd##_##opt; \
651 } while (0)
652
653 #define SAO_EDGE_FILTER_FUNCS(bitd, opt)                                                                                    \
654 void ff_hevc_sao_edge_filter_8_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val,  \
655                                               int eo, int width, int height);                                               \
656 void ff_hevc_sao_edge_filter_16_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
657                                                int eo, int width, int height);                                              \
658 void ff_hevc_sao_edge_filter_32_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
659                                                int eo, int width, int height);                                              \
660 void ff_hevc_sao_edge_filter_48_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
661                                                int eo, int width, int height);                                              \
662 void ff_hevc_sao_edge_filter_64_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
663                                                int eo, int width, int height);                                              \
664
665 SAO_EDGE_FILTER_FUNCS(8, ssse3);
666 SAO_EDGE_FILTER_FUNCS(8, avx2);
667 SAO_EDGE_FILTER_FUNCS(10, sse2);
668 SAO_EDGE_FILTER_FUNCS(10, avx2);
669 SAO_EDGE_FILTER_FUNCS(12, sse2);
670 SAO_EDGE_FILTER_FUNCS(12, avx2);
671
672 #define SAO_EDGE_INIT(bitd, opt) do {                                       \
673     c->sao_edge_filter[0]      = ff_hevc_sao_edge_filter_8_##bitd##_##opt;  \
674     c->sao_edge_filter[1]      = ff_hevc_sao_edge_filter_16_##bitd##_##opt; \
675     c->sao_edge_filter[2]      = ff_hevc_sao_edge_filter_32_##bitd##_##opt; \
676     c->sao_edge_filter[3]      = ff_hevc_sao_edge_filter_48_##bitd##_##opt; \
677     c->sao_edge_filter[4]      = ff_hevc_sao_edge_filter_64_##bitd##_##opt; \
678 } while (0)
679
680 #define EPEL_LINKS(pointer, my, mx, fname, bitd, opt )           \
681         PEL_LINK(pointer, 1, my , mx , fname##4 ,  bitd, opt ); \
682         PEL_LINK(pointer, 2, my , mx , fname##6 ,  bitd, opt ); \
683         PEL_LINK(pointer, 3, my , mx , fname##8 ,  bitd, opt ); \
684         PEL_LINK(pointer, 4, my , mx , fname##12,  bitd, opt ); \
685         PEL_LINK(pointer, 5, my , mx , fname##16,  bitd, opt ); \
686         PEL_LINK(pointer, 6, my , mx , fname##24,  bitd, opt ); \
687         PEL_LINK(pointer, 7, my , mx , fname##32,  bitd, opt ); \
688         PEL_LINK(pointer, 8, my , mx , fname##48,  bitd, opt ); \
689         PEL_LINK(pointer, 9, my , mx , fname##64,  bitd, opt )
690 #define QPEL_LINKS(pointer, my, mx, fname, bitd, opt)           \
691         PEL_LINK(pointer, 1, my , mx , fname##4 ,  bitd, opt ); \
692         PEL_LINK(pointer, 3, my , mx , fname##8 ,  bitd, opt ); \
693         PEL_LINK(pointer, 4, my , mx , fname##12,  bitd, opt ); \
694         PEL_LINK(pointer, 5, my , mx , fname##16,  bitd, opt ); \
695         PEL_LINK(pointer, 6, my , mx , fname##24,  bitd, opt ); \
696         PEL_LINK(pointer, 7, my , mx , fname##32,  bitd, opt ); \
697         PEL_LINK(pointer, 8, my , mx , fname##48,  bitd, opt ); \
698         PEL_LINK(pointer, 9, my , mx , fname##64,  bitd, opt )
699
700 void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth)
701 {
702     int cpu_flags = av_get_cpu_flags();
703
704     if (bit_depth == 8) {
705         if (EXTERNAL_MMXEXT(cpu_flags)) {
706             c->idct_dc[0] = ff_hevc_idct4x4_dc_8_mmxext;
707             c->idct_dc[1] = ff_hevc_idct8x8_dc_8_mmxext;
708             c->transform_add[0]    =  ff_hevc_transform_add4_8_mmxext;
709         }
710         if (EXTERNAL_SSE2(cpu_flags)) {
711             c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_sse2;
712             c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_sse2;
713             if (ARCH_X86_64) {
714                 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_sse2;
715                 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_sse2;
716
717             }
718             SAO_BAND_INIT(8, sse2);
719
720             c->idct_dc[1] = ff_hevc_idct8x8_dc_8_sse2;
721             c->idct_dc[2] = ff_hevc_idct16x16_dc_8_sse2;
722             c->idct_dc[3] = ff_hevc_idct32x32_dc_8_sse2;
723
724             c->transform_add[1]    = ff_hevc_transform_add8_8_sse2;
725             c->transform_add[2]    = ff_hevc_transform_add16_8_sse2;
726             c->transform_add[3]    = ff_hevc_transform_add32_8_sse2;
727         }
728         if (EXTERNAL_SSSE3(cpu_flags)) {
729             if(ARCH_X86_64) {
730                 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_ssse3;
731                 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_ssse3;
732             }
733             SAO_EDGE_INIT(8, ssse3);
734         }
735         if (EXTERNAL_SSE4(cpu_flags) && ARCH_X86_64) {
736
737             EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels,  8, sse4);
738             EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h,      8, sse4);
739             EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v,      8, sse4);
740             EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv,     8, sse4);
741
742             QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 8, sse4);
743             QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h,     8, sse4);
744             QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v,     8, sse4);
745             QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv,    8, sse4);
746         }
747         if (EXTERNAL_AVX(cpu_flags)) {
748             c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_avx;
749             c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_avx;
750             if (ARCH_X86_64) {
751                 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_avx;
752                 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_avx;
753             }
754             SAO_BAND_INIT(8, avx);
755
756             c->transform_add[1]    = ff_hevc_transform_add8_8_avx;
757             c->transform_add[2]    = ff_hevc_transform_add16_8_avx;
758             c->transform_add[3]    = ff_hevc_transform_add32_8_avx;
759         }
760         if (EXTERNAL_AVX2(cpu_flags)) {
761             c->idct_dc[2] = ff_hevc_idct16x16_dc_8_avx2;
762             c->idct_dc[3] = ff_hevc_idct32x32_dc_8_avx2;
763             if (ARCH_X86_64) {
764                 c->put_hevc_epel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_8_avx2;
765                 c->put_hevc_epel[8][0][0] = ff_hevc_put_hevc_pel_pixels48_8_avx2;
766                 c->put_hevc_epel[9][0][0] = ff_hevc_put_hevc_pel_pixels64_8_avx2;
767
768                 c->put_hevc_qpel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_8_avx2;
769                 c->put_hevc_qpel[8][0][0] = ff_hevc_put_hevc_pel_pixels48_8_avx2;
770                 c->put_hevc_qpel[9][0][0] = ff_hevc_put_hevc_pel_pixels64_8_avx2;
771
772                 c->put_hevc_epel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_avx2;
773                 c->put_hevc_epel_uni[8][0][0] = ff_hevc_put_hevc_uni_pel_pixels48_8_avx2;
774                 c->put_hevc_epel_uni[9][0][0] = ff_hevc_put_hevc_uni_pel_pixels64_8_avx2;
775
776                 c->put_hevc_qpel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_avx2;
777                 c->put_hevc_qpel_uni[8][0][0] = ff_hevc_put_hevc_uni_pel_pixels48_8_avx2;
778                 c->put_hevc_qpel_uni[9][0][0] = ff_hevc_put_hevc_uni_pel_pixels64_8_avx2;
779
780                 c->put_hevc_qpel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_8_avx2;
781                 c->put_hevc_qpel_bi[8][0][0] = ff_hevc_put_hevc_bi_pel_pixels48_8_avx2;
782                 c->put_hevc_qpel_bi[9][0][0] = ff_hevc_put_hevc_bi_pel_pixels64_8_avx2;
783
784                 c->put_hevc_epel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_8_avx2;
785                 c->put_hevc_epel_bi[8][0][0] = ff_hevc_put_hevc_bi_pel_pixels48_8_avx2;
786                 c->put_hevc_epel_bi[9][0][0] = ff_hevc_put_hevc_bi_pel_pixels64_8_avx2;
787
788                 c->put_hevc_epel[7][0][1] = ff_hevc_put_hevc_epel_h32_8_avx2;
789                 c->put_hevc_epel[8][0][1] = ff_hevc_put_hevc_epel_h48_8_avx2;
790                 c->put_hevc_epel[9][0][1] = ff_hevc_put_hevc_epel_h64_8_avx2;
791
792                 c->put_hevc_epel_uni[7][0][1] = ff_hevc_put_hevc_uni_epel_h32_8_avx2;
793                 c->put_hevc_epel_uni[8][0][1] = ff_hevc_put_hevc_uni_epel_h48_8_avx2;
794                 c->put_hevc_epel_uni[9][0][1] = ff_hevc_put_hevc_uni_epel_h64_8_avx2;
795
796                 c->put_hevc_epel_bi[7][0][1] = ff_hevc_put_hevc_bi_epel_h32_8_avx2;
797                 c->put_hevc_epel_bi[8][0][1] = ff_hevc_put_hevc_bi_epel_h48_8_avx2;
798                 c->put_hevc_epel_bi[9][0][1] = ff_hevc_put_hevc_bi_epel_h64_8_avx2;
799
800                 c->put_hevc_epel[7][1][0] = ff_hevc_put_hevc_epel_v32_8_avx2;
801                 c->put_hevc_epel[8][1][0] = ff_hevc_put_hevc_epel_v48_8_avx2;
802                 c->put_hevc_epel[9][1][0] = ff_hevc_put_hevc_epel_v64_8_avx2;
803
804                 c->put_hevc_epel_uni[7][1][0] = ff_hevc_put_hevc_uni_epel_v32_8_avx2;
805                 c->put_hevc_epel_uni[8][1][0] = ff_hevc_put_hevc_uni_epel_v48_8_avx2;
806                 c->put_hevc_epel_uni[9][1][0] = ff_hevc_put_hevc_uni_epel_v64_8_avx2;
807
808                 c->put_hevc_epel_bi[7][1][0] = ff_hevc_put_hevc_bi_epel_v32_8_avx2;
809                 c->put_hevc_epel_bi[8][1][0] = ff_hevc_put_hevc_bi_epel_v48_8_avx2;
810                 c->put_hevc_epel_bi[9][1][0] = ff_hevc_put_hevc_bi_epel_v64_8_avx2;
811
812                 c->put_hevc_epel[7][1][1] = ff_hevc_put_hevc_epel_hv32_8_avx2;
813                 c->put_hevc_epel[8][1][1] = ff_hevc_put_hevc_epel_hv48_8_avx2;
814                 c->put_hevc_epel[9][1][1] = ff_hevc_put_hevc_epel_hv64_8_avx2;
815
816                 c->put_hevc_epel_uni[7][1][1] = ff_hevc_put_hevc_uni_epel_hv32_8_avx2;
817                 c->put_hevc_epel_uni[8][1][1] = ff_hevc_put_hevc_uni_epel_hv48_8_avx2;
818                 c->put_hevc_epel_uni[9][1][1] = ff_hevc_put_hevc_uni_epel_hv64_8_avx2;
819
820                 c->put_hevc_epel_bi[7][1][1] = ff_hevc_put_hevc_bi_epel_hv32_8_avx2;
821                 c->put_hevc_epel_bi[8][1][1] = ff_hevc_put_hevc_bi_epel_hv48_8_avx2;
822                 c->put_hevc_epel_bi[9][1][1] = ff_hevc_put_hevc_bi_epel_hv64_8_avx2;
823
824                 c->put_hevc_qpel[7][0][1] = ff_hevc_put_hevc_qpel_h32_8_avx2;
825                 c->put_hevc_qpel[8][0][1] = ff_hevc_put_hevc_qpel_h48_8_avx2;
826                 c->put_hevc_qpel[9][0][1] = ff_hevc_put_hevc_qpel_h64_8_avx2;
827
828                 c->put_hevc_qpel[7][1][0] = ff_hevc_put_hevc_qpel_v32_8_avx2;
829                 c->put_hevc_qpel[8][1][0] = ff_hevc_put_hevc_qpel_v48_8_avx2;
830                 c->put_hevc_qpel[9][1][0] = ff_hevc_put_hevc_qpel_v64_8_avx2;
831
832                 c->put_hevc_qpel_uni[7][0][1] = ff_hevc_put_hevc_uni_qpel_h32_8_avx2;
833                 c->put_hevc_qpel_uni[8][0][1] = ff_hevc_put_hevc_uni_qpel_h48_8_avx2;
834                 c->put_hevc_qpel_uni[9][0][1] = ff_hevc_put_hevc_uni_qpel_h64_8_avx2;
835
836                 c->put_hevc_qpel_uni[7][1][0] = ff_hevc_put_hevc_uni_qpel_v32_8_avx2;
837                 c->put_hevc_qpel_uni[8][1][0] = ff_hevc_put_hevc_uni_qpel_v48_8_avx2;
838                 c->put_hevc_qpel_uni[9][1][0] = ff_hevc_put_hevc_uni_qpel_v64_8_avx2;
839
840                 c->put_hevc_qpel_bi[7][0][1] = ff_hevc_put_hevc_bi_qpel_h32_8_avx2;
841                 c->put_hevc_qpel_bi[8][0][1] = ff_hevc_put_hevc_bi_qpel_h48_8_avx2;
842                 c->put_hevc_qpel_bi[9][0][1] = ff_hevc_put_hevc_bi_qpel_h64_8_avx2;
843
844                 c->put_hevc_qpel_bi[7][1][0] = ff_hevc_put_hevc_bi_qpel_v32_8_avx2;
845                 c->put_hevc_qpel_bi[8][1][0] = ff_hevc_put_hevc_bi_qpel_v48_8_avx2;
846                 c->put_hevc_qpel_bi[9][1][0] = ff_hevc_put_hevc_bi_qpel_v64_8_avx2;
847             }
848             SAO_BAND_INIT(8, avx2);
849
850             c->sao_edge_filter[2] = ff_hevc_sao_edge_filter_32_8_avx2;
851             c->sao_edge_filter[3] = ff_hevc_sao_edge_filter_48_8_avx2;
852             c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_64_8_avx2;
853
854             c->transform_add[3]    = ff_hevc_transform_add32_8_avx2;
855         }
856     } else if (bit_depth == 10) {
857         if (EXTERNAL_MMXEXT(cpu_flags)) {
858             c->transform_add[0] = ff_hevc_transform_add4_10_mmxext;
859             c->idct_dc[0] = ff_hevc_idct4x4_dc_10_mmxext;
860             c->idct_dc[1] = ff_hevc_idct8x8_dc_10_mmxext;
861         }
862         if (EXTERNAL_SSE2(cpu_flags)) {
863             c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_sse2;
864             c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_sse2;
865             if (ARCH_X86_64) {
866                 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_sse2;
867                 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_sse2;
868             }
869             SAO_BAND_INIT(10, sse2);
870             SAO_EDGE_INIT(10, sse2);
871
872             c->idct_dc[1] = ff_hevc_idct8x8_dc_10_sse2;
873             c->idct_dc[2] = ff_hevc_idct16x16_dc_10_sse2;
874             c->idct_dc[3] = ff_hevc_idct32x32_dc_10_sse2;
875
876             c->transform_add[1]    = ff_hevc_transform_add8_10_sse2;
877             c->transform_add[2]    = ff_hevc_transform_add16_10_sse2;
878             c->transform_add[3]    = ff_hevc_transform_add32_10_sse2;
879         }
880         if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) {
881             c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_ssse3;
882             c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_ssse3;
883         }
884         if (EXTERNAL_SSE4(cpu_flags) && ARCH_X86_64) {
885             EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 10, sse4);
886             EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h,     10, sse4);
887             EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v,     10, sse4);
888             EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv,    10, sse4);
889
890             QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 10, sse4);
891             QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h,     10, sse4);
892             QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v,     10, sse4);
893             QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv,    10, sse4);
894         }
895         if (EXTERNAL_AVX(cpu_flags)) {
896             c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_avx;
897             c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_avx;
898             if (ARCH_X86_64) {
899                 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_avx;
900                 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_avx;
901             }
902             SAO_BAND_INIT(10, avx);
903         }
904         if (EXTERNAL_AVX2(cpu_flags)) {
905
906             c->idct_dc[2] = ff_hevc_idct16x16_dc_10_avx2;
907             c->idct_dc[3] = ff_hevc_idct32x32_dc_10_avx2;
908             if (ARCH_X86_64) {
909                 c->put_hevc_epel[5][0][0] = ff_hevc_put_hevc_pel_pixels16_10_avx2;
910                 c->put_hevc_epel[6][0][0] = ff_hevc_put_hevc_pel_pixels24_10_avx2;
911                 c->put_hevc_epel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_10_avx2;
912                 c->put_hevc_epel[8][0][0] = ff_hevc_put_hevc_pel_pixels48_10_avx2;
913                 c->put_hevc_epel[9][0][0] = ff_hevc_put_hevc_pel_pixels64_10_avx2;
914
915                 c->put_hevc_qpel[5][0][0] = ff_hevc_put_hevc_pel_pixels16_10_avx2;
916                 c->put_hevc_qpel[6][0][0] = ff_hevc_put_hevc_pel_pixels24_10_avx2;
917                 c->put_hevc_qpel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_10_avx2;
918                 c->put_hevc_qpel[8][0][0] = ff_hevc_put_hevc_pel_pixels48_10_avx2;
919                 c->put_hevc_qpel[9][0][0] = ff_hevc_put_hevc_pel_pixels64_10_avx2;
920
921                 c->put_hevc_epel_uni[5][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_avx2;
922                 c->put_hevc_epel_uni[6][0][0] = ff_hevc_put_hevc_uni_pel_pixels48_8_avx2;
923                 c->put_hevc_epel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels64_8_avx2;
924                 c->put_hevc_epel_uni[8][0][0] = ff_hevc_put_hevc_uni_pel_pixels96_8_avx2;
925                 c->put_hevc_epel_uni[9][0][0] = ff_hevc_put_hevc_uni_pel_pixels128_8_avx2;
926
927                 c->put_hevc_qpel_uni[5][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_avx2;
928                 c->put_hevc_qpel_uni[6][0][0] = ff_hevc_put_hevc_uni_pel_pixels48_8_avx2;
929                 c->put_hevc_qpel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels64_8_avx2;
930                 c->put_hevc_qpel_uni[8][0][0] = ff_hevc_put_hevc_uni_pel_pixels96_8_avx2;
931                 c->put_hevc_qpel_uni[9][0][0] = ff_hevc_put_hevc_uni_pel_pixels128_8_avx2;
932
933                 c->put_hevc_epel_bi[5][0][0] = ff_hevc_put_hevc_bi_pel_pixels16_10_avx2;
934                 c->put_hevc_epel_bi[6][0][0] = ff_hevc_put_hevc_bi_pel_pixels24_10_avx2;
935                 c->put_hevc_epel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_10_avx2;
936                 c->put_hevc_epel_bi[8][0][0] = ff_hevc_put_hevc_bi_pel_pixels48_10_avx2;
937                 c->put_hevc_epel_bi[9][0][0] = ff_hevc_put_hevc_bi_pel_pixels64_10_avx2;
938                 c->put_hevc_qpel_bi[5][0][0] = ff_hevc_put_hevc_bi_pel_pixels16_10_avx2;
939                 c->put_hevc_qpel_bi[6][0][0] = ff_hevc_put_hevc_bi_pel_pixels24_10_avx2;
940                 c->put_hevc_qpel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_10_avx2;
941                 c->put_hevc_qpel_bi[8][0][0] = ff_hevc_put_hevc_bi_pel_pixels48_10_avx2;
942                 c->put_hevc_qpel_bi[9][0][0] = ff_hevc_put_hevc_bi_pel_pixels64_10_avx2;
943
944                 c->put_hevc_epel[5][0][1] = ff_hevc_put_hevc_epel_h16_10_avx2;
945                 c->put_hevc_epel[6][0][1] = ff_hevc_put_hevc_epel_h24_10_avx2;
946                 c->put_hevc_epel[7][0][1] = ff_hevc_put_hevc_epel_h32_10_avx2;
947                 c->put_hevc_epel[8][0][1] = ff_hevc_put_hevc_epel_h48_10_avx2;
948                 c->put_hevc_epel[9][0][1] = ff_hevc_put_hevc_epel_h64_10_avx2;
949
950                 c->put_hevc_epel_uni[5][0][1] = ff_hevc_put_hevc_uni_epel_h16_10_avx2;
951                 c->put_hevc_epel_uni[6][0][1] = ff_hevc_put_hevc_uni_epel_h24_10_avx2;
952                 c->put_hevc_epel_uni[7][0][1] = ff_hevc_put_hevc_uni_epel_h32_10_avx2;
953                 c->put_hevc_epel_uni[8][0][1] = ff_hevc_put_hevc_uni_epel_h48_10_avx2;
954                 c->put_hevc_epel_uni[9][0][1] = ff_hevc_put_hevc_uni_epel_h64_10_avx2;
955
956                 c->put_hevc_epel_bi[5][0][1] = ff_hevc_put_hevc_bi_epel_h16_10_avx2;
957                 c->put_hevc_epel_bi[6][0][1] = ff_hevc_put_hevc_bi_epel_h24_10_avx2;
958                 c->put_hevc_epel_bi[7][0][1] = ff_hevc_put_hevc_bi_epel_h32_10_avx2;
959                 c->put_hevc_epel_bi[8][0][1] = ff_hevc_put_hevc_bi_epel_h48_10_avx2;
960                 c->put_hevc_epel_bi[9][0][1] = ff_hevc_put_hevc_bi_epel_h64_10_avx2;
961
962                 c->put_hevc_epel[5][1][0] = ff_hevc_put_hevc_epel_v16_10_avx2;
963                 c->put_hevc_epel[6][1][0] = ff_hevc_put_hevc_epel_v24_10_avx2;
964                 c->put_hevc_epel[7][1][0] = ff_hevc_put_hevc_epel_v32_10_avx2;
965                 c->put_hevc_epel[8][1][0] = ff_hevc_put_hevc_epel_v48_10_avx2;
966                 c->put_hevc_epel[9][1][0] = ff_hevc_put_hevc_epel_v64_10_avx2;
967
968                 c->put_hevc_epel_uni[5][1][0] = ff_hevc_put_hevc_uni_epel_v16_10_avx2;
969                 c->put_hevc_epel_uni[6][1][0] = ff_hevc_put_hevc_uni_epel_v24_10_avx2;
970                 c->put_hevc_epel_uni[7][1][0] = ff_hevc_put_hevc_uni_epel_v32_10_avx2;
971                 c->put_hevc_epel_uni[8][1][0] = ff_hevc_put_hevc_uni_epel_v48_10_avx2;
972                 c->put_hevc_epel_uni[9][1][0] = ff_hevc_put_hevc_uni_epel_v64_10_avx2;
973
974                 c->put_hevc_epel_bi[5][1][0] = ff_hevc_put_hevc_bi_epel_v16_10_avx2;
975                 c->put_hevc_epel_bi[6][1][0] = ff_hevc_put_hevc_bi_epel_v24_10_avx2;
976                 c->put_hevc_epel_bi[7][1][0] = ff_hevc_put_hevc_bi_epel_v32_10_avx2;
977                 c->put_hevc_epel_bi[8][1][0] = ff_hevc_put_hevc_bi_epel_v48_10_avx2;
978                 c->put_hevc_epel_bi[9][1][0] = ff_hevc_put_hevc_bi_epel_v64_10_avx2;
979
980                 c->put_hevc_epel[5][1][1] = ff_hevc_put_hevc_epel_hv16_10_avx2;
981                 c->put_hevc_epel[6][1][1] = ff_hevc_put_hevc_epel_hv24_10_avx2;
982                 c->put_hevc_epel[7][1][1] = ff_hevc_put_hevc_epel_hv32_10_avx2;
983                 c->put_hevc_epel[8][1][1] = ff_hevc_put_hevc_epel_hv48_10_avx2;
984                 c->put_hevc_epel[9][1][1] = ff_hevc_put_hevc_epel_hv64_10_avx2;
985
986                 c->put_hevc_epel_uni[5][1][1] = ff_hevc_put_hevc_uni_epel_hv16_10_avx2;
987                 c->put_hevc_epel_uni[6][1][1] = ff_hevc_put_hevc_uni_epel_hv24_10_avx2;
988                 c->put_hevc_epel_uni[7][1][1] = ff_hevc_put_hevc_uni_epel_hv32_10_avx2;
989                 c->put_hevc_epel_uni[8][1][1] = ff_hevc_put_hevc_uni_epel_hv48_10_avx2;
990                 c->put_hevc_epel_uni[9][1][1] = ff_hevc_put_hevc_uni_epel_hv64_10_avx2;
991
992                 c->put_hevc_epel_bi[5][1][1] = ff_hevc_put_hevc_bi_epel_hv16_10_avx2;
993                 c->put_hevc_epel_bi[6][1][1] = ff_hevc_put_hevc_bi_epel_hv24_10_avx2;
994                 c->put_hevc_epel_bi[7][1][1] = ff_hevc_put_hevc_bi_epel_hv32_10_avx2;
995                 c->put_hevc_epel_bi[8][1][1] = ff_hevc_put_hevc_bi_epel_hv48_10_avx2;
996                 c->put_hevc_epel_bi[9][1][1] = ff_hevc_put_hevc_bi_epel_hv64_10_avx2;
997
998                 c->put_hevc_qpel[5][0][1] = ff_hevc_put_hevc_qpel_h16_10_avx2;
999                 c->put_hevc_qpel[6][0][1] = ff_hevc_put_hevc_qpel_h24_10_avx2;
1000                 c->put_hevc_qpel[7][0][1] = ff_hevc_put_hevc_qpel_h32_10_avx2;
1001                 c->put_hevc_qpel[8][0][1] = ff_hevc_put_hevc_qpel_h48_10_avx2;
1002                 c->put_hevc_qpel[9][0][1] = ff_hevc_put_hevc_qpel_h64_10_avx2;
1003
1004                 c->put_hevc_qpel_uni[5][0][1] = ff_hevc_put_hevc_uni_qpel_h16_10_avx2;
1005                 c->put_hevc_qpel_uni[6][0][1] = ff_hevc_put_hevc_uni_qpel_h24_10_avx2;
1006                 c->put_hevc_qpel_uni[7][0][1] = ff_hevc_put_hevc_uni_qpel_h32_10_avx2;
1007                 c->put_hevc_qpel_uni[8][0][1] = ff_hevc_put_hevc_uni_qpel_h48_10_avx2;
1008                 c->put_hevc_qpel_uni[9][0][1] = ff_hevc_put_hevc_uni_qpel_h64_10_avx2;
1009
1010                 c->put_hevc_qpel_bi[5][0][1] = ff_hevc_put_hevc_bi_qpel_h16_10_avx2;
1011                 c->put_hevc_qpel_bi[6][0][1] = ff_hevc_put_hevc_bi_qpel_h24_10_avx2;
1012                 c->put_hevc_qpel_bi[7][0][1] = ff_hevc_put_hevc_bi_qpel_h32_10_avx2;
1013                 c->put_hevc_qpel_bi[8][0][1] = ff_hevc_put_hevc_bi_qpel_h48_10_avx2;
1014                 c->put_hevc_qpel_bi[9][0][1] = ff_hevc_put_hevc_bi_qpel_h64_10_avx2;
1015
1016                 c->put_hevc_qpel[5][1][0] = ff_hevc_put_hevc_qpel_v16_10_avx2;
1017                 c->put_hevc_qpel[6][1][0] = ff_hevc_put_hevc_qpel_v24_10_avx2;
1018                 c->put_hevc_qpel[7][1][0] = ff_hevc_put_hevc_qpel_v32_10_avx2;
1019                 c->put_hevc_qpel[8][1][0] = ff_hevc_put_hevc_qpel_v48_10_avx2;
1020                 c->put_hevc_qpel[9][1][0] = ff_hevc_put_hevc_qpel_v64_10_avx2;
1021
1022                 c->put_hevc_qpel_uni[5][1][0] = ff_hevc_put_hevc_uni_qpel_v16_10_avx2;
1023                 c->put_hevc_qpel_uni[6][1][0] = ff_hevc_put_hevc_uni_qpel_v24_10_avx2;
1024                 c->put_hevc_qpel_uni[7][1][0] = ff_hevc_put_hevc_uni_qpel_v32_10_avx2;
1025                 c->put_hevc_qpel_uni[8][1][0] = ff_hevc_put_hevc_uni_qpel_v48_10_avx2;
1026                 c->put_hevc_qpel_uni[9][1][0] = ff_hevc_put_hevc_uni_qpel_v64_10_avx2;
1027
1028                 c->put_hevc_qpel_bi[5][1][0] = ff_hevc_put_hevc_bi_qpel_v16_10_avx2;
1029                 c->put_hevc_qpel_bi[6][1][0] = ff_hevc_put_hevc_bi_qpel_v24_10_avx2;
1030                 c->put_hevc_qpel_bi[7][1][0] = ff_hevc_put_hevc_bi_qpel_v32_10_avx2;
1031                 c->put_hevc_qpel_bi[8][1][0] = ff_hevc_put_hevc_bi_qpel_v48_10_avx2;
1032                 c->put_hevc_qpel_bi[9][1][0] = ff_hevc_put_hevc_bi_qpel_v64_10_avx2;
1033
1034                 c->put_hevc_qpel[5][1][1] = ff_hevc_put_hevc_qpel_hv16_10_avx2;
1035                 c->put_hevc_qpel[6][1][1] = ff_hevc_put_hevc_qpel_hv24_10_avx2;
1036                 c->put_hevc_qpel[7][1][1] = ff_hevc_put_hevc_qpel_hv32_10_avx2;
1037                 c->put_hevc_qpel[8][1][1] = ff_hevc_put_hevc_qpel_hv48_10_avx2;
1038                 c->put_hevc_qpel[9][1][1] = ff_hevc_put_hevc_qpel_hv64_10_avx2;
1039
1040                 c->put_hevc_qpel_uni[5][1][1] = ff_hevc_put_hevc_uni_qpel_hv16_10_avx2;
1041                 c->put_hevc_qpel_uni[6][1][1] = ff_hevc_put_hevc_uni_qpel_hv24_10_avx2;
1042                 c->put_hevc_qpel_uni[7][1][1] = ff_hevc_put_hevc_uni_qpel_hv32_10_avx2;
1043                 c->put_hevc_qpel_uni[8][1][1] = ff_hevc_put_hevc_uni_qpel_hv48_10_avx2;
1044                 c->put_hevc_qpel_uni[9][1][1] = ff_hevc_put_hevc_uni_qpel_hv64_10_avx2;
1045
1046                 c->put_hevc_qpel_bi[5][1][1] = ff_hevc_put_hevc_bi_qpel_hv16_10_avx2;
1047                 c->put_hevc_qpel_bi[6][1][1] = ff_hevc_put_hevc_bi_qpel_hv24_10_avx2;
1048                 c->put_hevc_qpel_bi[7][1][1] = ff_hevc_put_hevc_bi_qpel_hv32_10_avx2;
1049                 c->put_hevc_qpel_bi[8][1][1] = ff_hevc_put_hevc_bi_qpel_hv48_10_avx2;
1050                 c->put_hevc_qpel_bi[9][1][1] = ff_hevc_put_hevc_bi_qpel_hv64_10_avx2;
1051             }
1052             SAO_BAND_INIT(10, avx2);
1053             c->sao_edge_filter[2] = ff_hevc_sao_edge_filter_32_10_avx2;
1054             c->sao_edge_filter[3] = ff_hevc_sao_edge_filter_48_10_avx2;
1055             c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_64_10_avx2;
1056
1057             c->transform_add[2] = ff_hevc_transform_add16_10_avx2;
1058             c->transform_add[3] = ff_hevc_transform_add32_10_avx2;
1059
1060         }
1061     } else if (bit_depth == 12) {
1062         if (EXTERNAL_MMXEXT(cpu_flags)) {
1063             c->idct_dc[0] = ff_hevc_idct4x4_dc_12_mmxext;
1064             c->idct_dc[1] = ff_hevc_idct8x8_dc_12_mmxext;
1065         }
1066         if (EXTERNAL_SSE2(cpu_flags)) {
1067             c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_sse2;
1068             c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_sse2;
1069             if (ARCH_X86_64) {
1070                 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2;
1071                 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2;
1072             }
1073             SAO_BAND_INIT(12, sse2);
1074             SAO_EDGE_INIT(12, sse2);
1075
1076             c->idct_dc[1] = ff_hevc_idct8x8_dc_12_sse2;
1077             c->idct_dc[2] = ff_hevc_idct16x16_dc_12_sse2;
1078             c->idct_dc[3] = ff_hevc_idct32x32_dc_12_sse2;
1079         }
1080         if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) {
1081             c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_ssse3;
1082             c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_ssse3;
1083         }
1084         if (EXTERNAL_SSE4(cpu_flags) && ARCH_X86_64) {
1085             EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 12, sse4);
1086             EPEL_LINKS(c->put_hevc_epel, 0, 1, epel_h,     12, sse4);
1087             EPEL_LINKS(c->put_hevc_epel, 1, 0, epel_v,     12, sse4);
1088             EPEL_LINKS(c->put_hevc_epel, 1, 1, epel_hv,    12, sse4);
1089
1090             QPEL_LINKS(c->put_hevc_qpel, 0, 0, pel_pixels, 12, sse4);
1091             QPEL_LINKS(c->put_hevc_qpel, 0, 1, qpel_h,     12, sse4);
1092             QPEL_LINKS(c->put_hevc_qpel, 1, 0, qpel_v,     12, sse4);
1093             QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv,    12, sse4);
1094         }
1095         if (EXTERNAL_AVX(cpu_flags)) {
1096             c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_avx;
1097             c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_avx;
1098             if (ARCH_X86_64) {
1099                 c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_avx;
1100                 c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_avx;
1101             }
1102             SAO_BAND_INIT(12, avx);
1103         }
1104         if (EXTERNAL_AVX2(cpu_flags)) {
1105             c->idct_dc[2] = ff_hevc_idct16x16_dc_12_avx2;
1106             c->idct_dc[3] = ff_hevc_idct32x32_dc_12_avx2;
1107
1108             SAO_BAND_INIT(12, avx2);
1109             c->sao_edge_filter[2] = ff_hevc_sao_edge_filter_32_12_avx2;
1110             c->sao_edge_filter[3] = ff_hevc_sao_edge_filter_48_12_avx2;
1111             c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_64_12_avx2;
1112         }
1113     }
1114 }