FFmpeg
Loading...
Searching...
No Matches
h264_intrapred_init.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Fiona Glaser <fiona@x264.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <stddef.h>
22#include <stdint.h>
23#include "config.h"
25#include "libavutil/cpu.h"
26#include "libavutil/x86/cpu.h"
27#include "libavcodec/codec_id.h"
28#include "libavcodec/h264pred.h"
29
30#define PRED4x4(TYPE, DEPTH, OPT) \
31void ff_pred4x4_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
32 const uint8_t *topright, \
33 ptrdiff_t stride);
34
35PRED4x4(dc, 10, sse2)
36PRED4x4(down_left, 10, sse2)
37PRED4x4(down_left, 10, avx)
38PRED4x4(down_right, 10, sse2)
39PRED4x4(down_right, 10, ssse3)
40PRED4x4(down_right, 10, avx)
41PRED4x4(vertical_left, 10, sse2)
42PRED4x4(vertical_left, 10, avx)
43PRED4x4(vertical_right, 10, sse2)
44PRED4x4(vertical_right, 10, ssse3)
45PRED4x4(vertical_right, 10, avx)
46PRED4x4(horizontal_up, 10, sse2)
47PRED4x4(horizontal_down, 10, sse2)
48PRED4x4(horizontal_down, 10, ssse3)
49PRED4x4(horizontal_down, 10, avx)
50
51#define PRED8x8(TYPE, DEPTH, OPT) \
52void ff_pred8x8_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
53 ptrdiff_t stride);
54
55PRED8x8(dc, 10, sse2)
56PRED8x8(top_dc, 10, sse2)
57PRED8x8(plane, 10, sse2)
58PRED8x8(vertical, 10, sse2)
59PRED8x8(horizontal, 10, sse2)
60
61#define PRED8x8L(TYPE, DEPTH, OPT)\
62void ff_pred8x8l_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
63 int has_topleft, \
64 int has_topright, \
65 ptrdiff_t stride);
66
67PRED8x8L(dc, 10, sse2)
68PRED8x8L(dc, 10, avx)
69PRED8x8L(128_dc, 10, sse2)
70PRED8x8L(top_dc, 10, sse2)
71PRED8x8L(top_dc, 10, avx)
72PRED8x8L(vertical, 10, sse2)
73PRED8x8L(vertical, 10, avx)
74PRED8x8L(horizontal, 10, sse2)
75PRED8x8L(horizontal, 10, ssse3)
76PRED8x8L(horizontal, 10, avx)
77PRED8x8L(down_left, 10, sse2)
78PRED8x8L(down_left, 10, ssse3)
79PRED8x8L(down_left, 10, avx)
80PRED8x8L(down_right, 10, sse2)
81PRED8x8L(down_right, 10, ssse3)
82PRED8x8L(down_right, 10, avx)
83PRED8x8L(vertical_right, 10, sse2)
84PRED8x8L(vertical_right, 10, ssse3)
85PRED8x8L(vertical_right, 10, avx)
86PRED8x8L(horizontal_up, 10, sse2)
87PRED8x8L(horizontal_up, 10, ssse3)
88PRED8x8L(horizontal_up, 10, avx)
89
90#define PRED16x16(TYPE, DEPTH, OPT)\
91void ff_pred16x16_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
92 ptrdiff_t stride);
93
94PRED16x16(dc, 10, sse2)
95PRED16x16(top_dc, 10, sse2)
96PRED16x16(128_dc, 10, sse2)
97PRED16x16(left_dc, 10, sse2)
98PRED16x16(vertical, 10, sse2)
99PRED16x16(horizontal, 10, sse2)
100
101/* 8-bit versions */
102PRED16x16(vertical, 8, sse)
103PRED16x16(horizontal, 8, sse2)
104PRED16x16(horizontal, 8, ssse3)
105PRED16x16(horizontal, 8, avx2)
106PRED16x16(dc, 8, sse2)
107PRED16x16(dc, 8, ssse3)
108PRED16x16(plane_h264, 8, sse2)
109PRED16x16(plane_h264, 8, ssse3)
110PRED16x16(plane_rv40, 8, sse2)
111PRED16x16(plane_rv40, 8, ssse3)
112PRED16x16(plane_svq3, 8, sse2)
113PRED16x16(plane_svq3, 8, ssse3)
114PRED16x16(tm_vp8, 8, sse2)
115PRED16x16(tm_vp8, 8, avx2)
116
117PRED8x8(top_dc, 8, sse2)
118PRED8x8(dc_rv40, 8, sse2)
119PRED8x8(dc, 8, sse2)
120PRED8x8(vertical, 8, sse2)
121PRED8x8(horizontal, 8, sse2)
122PRED8x8(horizontal, 8, ssse3)
123PRED8x8(horizontal, 8, avx2)
124PRED8x8(plane, 8, sse2)
125PRED8x8(plane, 8, ssse3)
126PRED8x8(tm_vp8, 8, sse2)
127PRED8x8(tm_vp8, 8, ssse3)
128
129PRED8x8L(top_dc, 8, sse2)
130PRED8x8L(dc, 8, sse2)
131PRED8x8L(horizontal, 8, sse2)
132PRED8x8L(vertical, 8, sse2)
133PRED8x8L(down_left, 8, sse2)
134PRED8x8L(down_right, 8, sse2)
135PRED8x8L(vertical_right, 8, sse2)
136PRED8x8L(vertical_left, 8, sse2)
137PRED8x8L(horizontal_up, 8, sse2)
138PRED8x8L(horizontal_down, 8, sse2)
139PRED8x8L(horizontal_down, 8, ssse3)
140
141PRED4x4(dc, 8, sse2)
142PRED4x4(down_left, 8, sse2)
143PRED4x4(down_right, 8, sse2)
144PRED4x4(vertical_left, 8, sse2)
145PRED4x4(vertical_right, 8, sse2)
146PRED4x4(horizontal_up, 8, sse2)
147PRED4x4(horizontal_down, 8, sse2)
148PRED4x4(tm_vp8, 8, sse2)
149PRED4x4(tm_vp8, 8, ssse3)
150PRED4x4(vertical_vp8, 8, sse2)
151
153 const int bit_depth,
154 const int chroma_format_idc)
155{
157
158 if (bit_depth == 8) {
159 if (EXTERNAL_SSE(cpu_flags)) {
160 h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_sse;
161 }
162
164 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_sse2;
165 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_sse2;
166 h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_8_sse2;
167 h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_8_sse2;
168 h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_sse2;
169 h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_8_sse2;
170 h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_8_sse2;
171 h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_8_sse2;
172 h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_8_sse2;
173 h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_8_sse2;
174 h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_8_sse2;
175 h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_8_sse2;
176 h->pred4x4 [DIAG_DOWN_RIGHT_PRED ] = ff_pred4x4_down_right_8_sse2;
177 h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_8_sse2;
178 h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_8_sse2;
179 h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_8_sse2;
180 if (chroma_format_idc <= 1) {
181 h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_sse2;
182 h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_8_sse2;
184 h->pred8x8 [TOP_DC_PRED8x8] = ff_pred8x8_top_dc_8_sse2;
185 h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_8_sse2;
186 }
187 }
189 h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_8_sse2;
190 }
191 if (codec_id != AV_CODEC_ID_RV40) {
192 h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_8_sse2;
193 }
196 h->pred4x4[DIAG_DOWN_LEFT_PRED] = ff_pred4x4_down_left_8_sse2;
197 }
199 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_sse2;
200 h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_sse2;
201 h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_8_sse2;
202 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_sse2;
203 h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_8_sse2;
204 } else {
205 if (chroma_format_idc <= 1)
206 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_sse2;
207 if (codec_id == AV_CODEC_ID_SVQ3) {
208 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_8_sse2;
209 } else if (codec_id == AV_CODEC_ID_RV40) {
210 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_8_sse2;
211 } else {
212 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_sse2;
213 }
214 }
215 }
216
218 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_ssse3;
219 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_ssse3;
220 if (chroma_format_idc <= 1)
221 h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_ssse3;
222 h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_8_ssse3;
224 h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_ssse3;
225 h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_ssse3;
226 } else {
227 if (chroma_format_idc <= 1)
228 h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_ssse3;
229 if (codec_id == AV_CODEC_ID_SVQ3) {
230 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_8_ssse3;
231 } else if (codec_id == AV_CODEC_ID_RV40) {
232 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_8_ssse3;
233 } else {
234 h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_ssse3;
235 }
236 }
237 }
238
240 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_avx2;
241 if (chroma_format_idc <= 1)
242 h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_avx2;
243 if (codec_id == AV_CODEC_ID_VP8) {
244 h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_avx2;
245 }
246 }
247 } else if (bit_depth == 10) {
249 h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_sse2;
250 h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_sse2;
251 h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_sse2;
252 h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_sse2;
253 h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_sse2;
254 h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_sse2;
255 h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_sse2;
256
257 if (chroma_format_idc <= 1) {
258 h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_sse2;
259 h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_10_sse2;
260 h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_10_sse2;
261 h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2;
262 h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2;
263 }
264
265 h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2;
266 h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_sse2;
267 h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_sse2;
268 h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_sse2;
269 h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_sse2;
270 h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_sse2;
271 h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_sse2;
272 h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_sse2;
273 h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_sse2;
274
275 h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_10_sse2;
276 h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_10_sse2;
277 h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_10_sse2;
278 h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_sse2;
279 h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_sse2;
280 h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_sse2;
281 }
283 h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_ssse3;
284 h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_ssse3;
285 h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3;
286
287 h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_ssse3;
288 h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_ssse3;
289 h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_ssse3;
290 h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_ssse3;
291 h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_ssse3;
292 }
293 if (EXTERNAL_AVX(cpu_flags)) {
294 h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx;
295 h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx;
296 h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_avx;
297 h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx;
298 h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx;
299
300 h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_avx;
301 h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_avx;
302 h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_avx;
303 h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_avx;
304 h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_avx;
305 h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_avx;
306 h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_avx;
307 h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx;
308 }
309 }
310}
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
@ AV_CODEC_ID_SVQ3
Definition codec_id.h:73
@ AV_CODEC_ID_H264
Definition codec_id.h:77
@ AV_CODEC_ID_VP7
Definition codec_id.h:230
@ AV_CODEC_ID_VP8
Definition codec_id.h:190
@ AV_CODEC_ID_RV40
Definition codec_id.h:119
H.264 / AVC / MPEG-4 prediction functions.
#define TOP_DC_PRED
Definition h264pred.h:50
#define TOP_DC_PRED8x8
Definition h264pred.h:75
void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc)
#define VERT_PRED
Prediction types.
Definition h264pred.h:38
#define HOR_PRED8x8
Definition h264pred.h:69
#define DC_128_PRED
Definition h264pred.h:51
#define VERT_LEFT_PRED
Definition h264pred.h:45
#define HOR_DOWN_PRED
Definition h264pred.h:44
#define VERT_PRED8x8
Definition h264pred.h:70
#define DIAG_DOWN_LEFT_PRED
Definition h264pred.h:41
#define TM_VP8_PRED
"True Motion", used instead of plane
Definition h264pred.h:59
#define DC_PRED8x8
Definition h264pred.h:68
#define HOR_UP_PRED
Definition h264pred.h:46
#define LEFT_DC_PRED8x8
Definition h264pred.h:74
#define DIAG_DOWN_RIGHT_PRED
Definition h264pred.h:42
#define HOR_PRED
Definition h264pred.h:39
#define DC_PRED
Definition h264pred.h:40
#define PLANE_PRED8x8
Definition h264pred.h:71
#define DC_128_PRED8x8
Definition h264pred.h:76
#define VERT_RIGHT_PRED
Definition h264pred.h:43
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define EXTERNAL_SSE(flags)
Definition cpu.h:52
#define EXTERNAL_AVX(flags)
Definition cpu.h:64
#define EXTERNAL_SSSE3(flags)
Definition cpu.h:59
#define EXTERNAL_AVX2(flags)
Definition cpu.h:72
#define EXTERNAL_SSE2(flags)
Definition cpu.h:53
static int sse(const MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride)
#define PRED8x8(TYPE, DEPTH, SUFFIX)
#define PRED16x16(TYPE, DEPTH, SUFFIX)
Context for storing H.264 prediction functions.
Definition h264pred.h:94
enum AVCodecID codec_id
#define PRED8x8L(TYPE, DEPTH, OPT)
#define PRED4x4(TYPE, DEPTH, OPT)