FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hevcdsp.h
Go to the documentation of this file.
1 /*
2  * HEVC video decoder
3  *
4  * Copyright (C) 2012 - 2013 Guillaume Martres
5  * Copyright (C) 2013 - 2014 Pierre-Edouard Lepere
6  *
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 #ifndef AVCODEC_X86_HEVCDSP_H
26 #define AVCODEC_X86_HEVCDSP_H
27 
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 
32 #define idct_dc_proto(size, bitd, opt) \
33  void ff_hevc_idct##size##_dc_add_##bitd##_##opt(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
34 
35 #define PEL_LINK(dst, idx1, idx2, idx3, name, D, opt) \
36 dst[idx1][idx2][idx3] = ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt; \
37 dst ## _bi[idx1][idx2][idx3] = ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt; \
38 dst ## _uni[idx1][idx2][idx3] = ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt; \
39 dst ## _uni_w[idx1][idx2][idx3] = ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt; \
40 dst ## _bi_w[idx1][idx2][idx3] = ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt
41 
42 
43 #define PEL_PROTOTYPE(name, D, opt) \
44 void ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); \
45 void ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); \
46 void ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width); \
47 void ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width); \
48 void ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width)
49 
50 
51 ///////////////////////////////////////////////////////////////////////////////
52 // MC functions
53 ///////////////////////////////////////////////////////////////////////////////
54 
55 #define EPEL_PROTOTYPES(fname, bitd, opt) \
56  PEL_PROTOTYPE(fname##4, bitd, opt); \
57  PEL_PROTOTYPE(fname##6, bitd, opt); \
58  PEL_PROTOTYPE(fname##8, bitd, opt); \
59  PEL_PROTOTYPE(fname##12, bitd, opt); \
60  PEL_PROTOTYPE(fname##16, bitd, opt); \
61  PEL_PROTOTYPE(fname##24, bitd, opt); \
62  PEL_PROTOTYPE(fname##32, bitd, opt); \
63  PEL_PROTOTYPE(fname##48, bitd, opt); \
64  PEL_PROTOTYPE(fname##64, bitd, opt)
65 
66 #define QPEL_PROTOTYPES(fname, bitd, opt) \
67  PEL_PROTOTYPE(fname##4, bitd, opt); \
68  PEL_PROTOTYPE(fname##8, bitd, opt); \
69  PEL_PROTOTYPE(fname##12, bitd, opt); \
70  PEL_PROTOTYPE(fname##16, bitd, opt); \
71  PEL_PROTOTYPE(fname##24, bitd, opt); \
72  PEL_PROTOTYPE(fname##32, bitd, opt); \
73  PEL_PROTOTYPE(fname##48, bitd, opt); \
74  PEL_PROTOTYPE(fname##64, bitd, opt)
75 
76 #define WEIGHTING_PROTOTYPE(width, bitd, opt) \
77 void ff_hevc_put_hevc_uni_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, int height, int denom, int _wx, int _ox); \
78 void ff_hevc_put_hevc_bi_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, int16_t *_src2, int height, int denom, int _wx0, int _wx1, int _ox0, int _ox1)
79 
80 #define WEIGHTING_PROTOTYPES(bitd, opt) \
81  WEIGHTING_PROTOTYPE(2, bitd, opt); \
82  WEIGHTING_PROTOTYPE(4, bitd, opt); \
83  WEIGHTING_PROTOTYPE(6, bitd, opt); \
84  WEIGHTING_PROTOTYPE(8, bitd, opt); \
85  WEIGHTING_PROTOTYPE(12, bitd, opt); \
86  WEIGHTING_PROTOTYPE(16, bitd, opt); \
87  WEIGHTING_PROTOTYPE(24, bitd, opt); \
88  WEIGHTING_PROTOTYPE(32, bitd, opt); \
89  WEIGHTING_PROTOTYPE(48, bitd, opt); \
90  WEIGHTING_PROTOTYPE(64, bitd, opt)
91 
92 
93 ///////////////////////////////////////////////////////////////////////////////
94 // QPEL_PIXELS EPEL_PIXELS
95 ///////////////////////////////////////////////////////////////////////////////
96 EPEL_PROTOTYPES(pel_pixels , 8, sse4);
97 EPEL_PROTOTYPES(pel_pixels , 10, sse4);
98 EPEL_PROTOTYPES(pel_pixels , 12, sse4);
99 
100 void ff_hevc_put_hevc_pel_pixels16_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
101 void ff_hevc_put_hevc_pel_pixels24_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
102 void ff_hevc_put_hevc_pel_pixels32_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
103 void ff_hevc_put_hevc_pel_pixels48_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
104 void ff_hevc_put_hevc_pel_pixels64_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
105 
106 void ff_hevc_put_hevc_pel_pixels16_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
107 void ff_hevc_put_hevc_pel_pixels24_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
108 void ff_hevc_put_hevc_pel_pixels32_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
109 void ff_hevc_put_hevc_pel_pixels48_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
110 void ff_hevc_put_hevc_pel_pixels64_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
111 
112 
113 
114 void ff_hevc_put_hevc_uni_pel_pixels32_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
115 void ff_hevc_put_hevc_uni_pel_pixels48_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
116 void ff_hevc_put_hevc_uni_pel_pixels64_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
117 void ff_hevc_put_hevc_uni_pel_pixels96_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); //used for 10bit
118 void ff_hevc_put_hevc_uni_pel_pixels128_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);//used for 10bit
119 
120 
121 void ff_hevc_put_hevc_bi_pel_pixels16_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
122 void ff_hevc_put_hevc_bi_pel_pixels24_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
123 void ff_hevc_put_hevc_bi_pel_pixels32_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
124 void ff_hevc_put_hevc_bi_pel_pixels48_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
125 void ff_hevc_put_hevc_bi_pel_pixels64_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
126 
127 void ff_hevc_put_hevc_bi_pel_pixels16_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
128 void ff_hevc_put_hevc_bi_pel_pixels24_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
129 void ff_hevc_put_hevc_bi_pel_pixels32_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
130 void ff_hevc_put_hevc_bi_pel_pixels48_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
131 void ff_hevc_put_hevc_bi_pel_pixels64_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
132 
133 ///////////////////////////////////////////////////////////////////////////////
134 // EPEL
135 ///////////////////////////////////////////////////////////////////////////////
136 EPEL_PROTOTYPES(epel_h , 8, sse4);
137 EPEL_PROTOTYPES(epel_h , 10, sse4);
138 EPEL_PROTOTYPES(epel_h , 12, sse4);
139 
140 EPEL_PROTOTYPES(epel_v , 8, sse4);
141 EPEL_PROTOTYPES(epel_v , 10, sse4);
142 EPEL_PROTOTYPES(epel_v , 12, sse4);
143 
144 EPEL_PROTOTYPES(epel_hv , 8, sse4);
145 EPEL_PROTOTYPES(epel_hv , 10, sse4);
146 EPEL_PROTOTYPES(epel_hv , 12, sse4);
147 
148 PEL_PROTOTYPE(epel_h16, 8, avx2);
149 PEL_PROTOTYPE(epel_h24, 8, avx2);
150 PEL_PROTOTYPE(epel_h32, 8, avx2);
151 PEL_PROTOTYPE(epel_h48, 8, avx2);
152 PEL_PROTOTYPE(epel_h64, 8, avx2);
153 
154 PEL_PROTOTYPE(epel_h16,10, avx2);
155 PEL_PROTOTYPE(epel_h24,10, avx2);
156 PEL_PROTOTYPE(epel_h32,10, avx2);
157 PEL_PROTOTYPE(epel_h48,10, avx2);
158 PEL_PROTOTYPE(epel_h64,10, avx2);
159 
160 PEL_PROTOTYPE(epel_v16, 8, avx2);
161 PEL_PROTOTYPE(epel_v24, 8, avx2);
162 PEL_PROTOTYPE(epel_v32, 8, avx2);
163 PEL_PROTOTYPE(epel_v48, 8, avx2);
164 PEL_PROTOTYPE(epel_v64, 8, avx2);
165 
166 PEL_PROTOTYPE(epel_v16,10, avx2);
167 PEL_PROTOTYPE(epel_v24,10, avx2);
168 PEL_PROTOTYPE(epel_v32,10, avx2);
169 PEL_PROTOTYPE(epel_v48,10, avx2);
170 PEL_PROTOTYPE(epel_v64,10, avx2);
171 
172 PEL_PROTOTYPE(epel_hv16, 8, avx2);
173 PEL_PROTOTYPE(epel_hv24, 8, avx2);
174 PEL_PROTOTYPE(epel_hv32, 8, avx2);
175 PEL_PROTOTYPE(epel_hv48, 8, avx2);
176 PEL_PROTOTYPE(epel_hv64, 8, avx2);
177 
178 PEL_PROTOTYPE(epel_hv16,10, avx2);
179 PEL_PROTOTYPE(epel_hv24,10, avx2);
180 PEL_PROTOTYPE(epel_hv32,10, avx2);
181 PEL_PROTOTYPE(epel_hv48,10, avx2);
182 PEL_PROTOTYPE(epel_hv64,10, avx2);
183 
184 ///////////////////////////////////////////////////////////////////////////////
185 // QPEL
186 ///////////////////////////////////////////////////////////////////////////////
187 QPEL_PROTOTYPES(qpel_h , 8, sse4);
188 QPEL_PROTOTYPES(qpel_h , 10, sse4);
189 QPEL_PROTOTYPES(qpel_h , 12, sse4);
190 
191 QPEL_PROTOTYPES(qpel_v, 8, sse4);
192 QPEL_PROTOTYPES(qpel_v, 10, sse4);
193 QPEL_PROTOTYPES(qpel_v, 12, sse4);
194 
195 QPEL_PROTOTYPES(qpel_hv, 8, sse4);
196 QPEL_PROTOTYPES(qpel_hv, 10, sse4);
197 QPEL_PROTOTYPES(qpel_hv, 12, sse4);
198 
199 PEL_PROTOTYPE(qpel_h16, 8, avx2);
200 PEL_PROTOTYPE(qpel_h24, 8, avx2);
201 PEL_PROTOTYPE(qpel_h32, 8, avx2);
202 PEL_PROTOTYPE(qpel_h48, 8, avx2);
203 PEL_PROTOTYPE(qpel_h64, 8, avx2);
204 
205 PEL_PROTOTYPE(qpel_h16,10, avx2);
206 PEL_PROTOTYPE(qpel_h24,10, avx2);
207 PEL_PROTOTYPE(qpel_h32,10, avx2);
208 PEL_PROTOTYPE(qpel_h48,10, avx2);
209 PEL_PROTOTYPE(qpel_h64,10, avx2);
210 
211 PEL_PROTOTYPE(qpel_v16, 8, avx2);
212 PEL_PROTOTYPE(qpel_v24, 8, avx2);
213 PEL_PROTOTYPE(qpel_v32, 8, avx2);
214 PEL_PROTOTYPE(qpel_v48, 8, avx2);
215 PEL_PROTOTYPE(qpel_v64, 8, avx2);
216 
217 PEL_PROTOTYPE(qpel_v16,10, avx2);
218 PEL_PROTOTYPE(qpel_v24,10, avx2);
219 PEL_PROTOTYPE(qpel_v32,10, avx2);
220 PEL_PROTOTYPE(qpel_v48,10, avx2);
221 PEL_PROTOTYPE(qpel_v64,10, avx2);
222 
223 PEL_PROTOTYPE(qpel_hv16, 8, avx2);
224 PEL_PROTOTYPE(qpel_hv24, 8, avx2);
225 PEL_PROTOTYPE(qpel_hv32, 8, avx2);
226 PEL_PROTOTYPE(qpel_hv48, 8, avx2);
227 PEL_PROTOTYPE(qpel_hv64, 8, avx2);
228 
229 PEL_PROTOTYPE(qpel_hv16,10, avx2);
230 PEL_PROTOTYPE(qpel_hv24,10, avx2);
231 PEL_PROTOTYPE(qpel_hv32,10, avx2);
232 PEL_PROTOTYPE(qpel_hv48,10, avx2);
233 PEL_PROTOTYPE(qpel_hv64,10, avx2);
234 
235 WEIGHTING_PROTOTYPES(8, sse4);
236 WEIGHTING_PROTOTYPES(10, sse4);
237 WEIGHTING_PROTOTYPES(12, sse4);
238 
239 ///////////////////////////////////////////////////////////////////////////////
240 // TRANSFORM_ADD
241 ///////////////////////////////////////////////////////////////////////////////
242 void ff_hevc_transform_add4_8_mmxext(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
243 void ff_hevc_transform_add8_8_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
244 void ff_hevc_transform_add16_8_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
245 void ff_hevc_transform_add32_8_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
246 
247 void ff_hevc_transform_add8_8_avx(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
248 void ff_hevc_transform_add16_8_avx(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
249 void ff_hevc_transform_add32_8_avx(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
250 
251 void ff_hevc_transform_add32_8_avx2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
252 
253 void ff_hevc_transform_add4_10_mmxext(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
254 void ff_hevc_transform_add8_10_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
255 void ff_hevc_transform_add16_10_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
256 void ff_hevc_transform_add32_10_sse2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
257 
258 void ff_hevc_transform_add16_10_avx2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
259 void ff_hevc_transform_add32_10_avx2(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride);
260 
261 #endif // AVCODEC_X86_HEVCDSP_H