32 typedef void emu_edge_vfix_func(uint8_t *dst,
x86_reg dst_stride,
35 typedef void emu_edge_vvar_func(uint8_t *dst,
x86_reg dst_stride,
40 extern emu_edge_vfix_func ff_emu_edge_vfix1_mmx;
41 extern emu_edge_vfix_func ff_emu_edge_vfix2_mmx;
42 extern emu_edge_vfix_func ff_emu_edge_vfix3_mmx;
43 extern emu_edge_vfix_func ff_emu_edge_vfix4_mmx;
44 extern emu_edge_vfix_func ff_emu_edge_vfix5_mmx;
45 extern emu_edge_vfix_func ff_emu_edge_vfix6_mmx;
46 extern emu_edge_vfix_func ff_emu_edge_vfix7_mmx;
47 extern emu_edge_vfix_func ff_emu_edge_vfix8_mmx;
48 extern emu_edge_vfix_func ff_emu_edge_vfix9_mmx;
49 extern emu_edge_vfix_func ff_emu_edge_vfix10_mmx;
50 extern emu_edge_vfix_func ff_emu_edge_vfix11_mmx;
51 extern emu_edge_vfix_func ff_emu_edge_vfix12_mmx;
52 extern emu_edge_vfix_func ff_emu_edge_vfix13_mmx;
53 extern emu_edge_vfix_func ff_emu_edge_vfix14_mmx;
54 extern emu_edge_vfix_func ff_emu_edge_vfix15_mmx;
55 extern emu_edge_vfix_func ff_emu_edge_vfix16_mmx;
56 extern emu_edge_vfix_func ff_emu_edge_vfix17_mmx;
57 extern emu_edge_vfix_func ff_emu_edge_vfix18_mmx;
58 extern emu_edge_vfix_func ff_emu_edge_vfix19_mmx;
59 extern emu_edge_vfix_func ff_emu_edge_vfix20_mmx;
60 extern emu_edge_vfix_func ff_emu_edge_vfix21_mmx;
61 extern emu_edge_vfix_func ff_emu_edge_vfix22_mmx;
63 static emu_edge_vfix_func *
const vfixtbl_mmx[22] = {
64 &ff_emu_edge_vfix1_mmx, &ff_emu_edge_vfix2_mmx, &ff_emu_edge_vfix3_mmx,
65 &ff_emu_edge_vfix4_mmx, &ff_emu_edge_vfix5_mmx, &ff_emu_edge_vfix6_mmx,
66 &ff_emu_edge_vfix7_mmx, &ff_emu_edge_vfix8_mmx, &ff_emu_edge_vfix9_mmx,
67 &ff_emu_edge_vfix10_mmx, &ff_emu_edge_vfix11_mmx, &ff_emu_edge_vfix12_mmx,
68 &ff_emu_edge_vfix13_mmx, &ff_emu_edge_vfix14_mmx, &ff_emu_edge_vfix15_mmx,
69 &ff_emu_edge_vfix16_mmx, &ff_emu_edge_vfix17_mmx, &ff_emu_edge_vfix18_mmx,
70 &ff_emu_edge_vfix19_mmx, &ff_emu_edge_vfix20_mmx, &ff_emu_edge_vfix21_mmx,
71 &ff_emu_edge_vfix22_mmx
74 extern emu_edge_vvar_func ff_emu_edge_vvar_mmx;
75 extern emu_edge_vfix_func ff_emu_edge_vfix16_sse;
76 extern emu_edge_vfix_func ff_emu_edge_vfix17_sse;
77 extern emu_edge_vfix_func ff_emu_edge_vfix18_sse;
78 extern emu_edge_vfix_func ff_emu_edge_vfix19_sse;
79 extern emu_edge_vfix_func ff_emu_edge_vfix20_sse;
80 extern emu_edge_vfix_func ff_emu_edge_vfix21_sse;
81 extern emu_edge_vfix_func ff_emu_edge_vfix22_sse;
82 static emu_edge_vfix_func *
const vfixtbl_sse[22] = {
83 ff_emu_edge_vfix1_mmx, ff_emu_edge_vfix2_mmx, ff_emu_edge_vfix3_mmx,
84 ff_emu_edge_vfix4_mmx, ff_emu_edge_vfix5_mmx, ff_emu_edge_vfix6_mmx,
85 ff_emu_edge_vfix7_mmx, ff_emu_edge_vfix8_mmx, ff_emu_edge_vfix9_mmx,
86 ff_emu_edge_vfix10_mmx, ff_emu_edge_vfix11_mmx, ff_emu_edge_vfix12_mmx,
87 ff_emu_edge_vfix13_mmx, ff_emu_edge_vfix14_mmx, ff_emu_edge_vfix15_mmx,
88 ff_emu_edge_vfix16_sse, ff_emu_edge_vfix17_sse, ff_emu_edge_vfix18_sse,
89 ff_emu_edge_vfix19_sse, ff_emu_edge_vfix20_sse, ff_emu_edge_vfix21_sse,
90 ff_emu_edge_vfix22_sse
92 extern emu_edge_vvar_func ff_emu_edge_vvar_sse;
94 typedef void emu_edge_hfix_func(uint8_t *dst,
x86_reg dst_stride,
96 typedef void emu_edge_hvar_func(uint8_t *dst,
x86_reg dst_stride,
99 extern emu_edge_hfix_func ff_emu_edge_hfix2_mmx;
100 extern emu_edge_hfix_func ff_emu_edge_hfix4_mmx;
101 extern emu_edge_hfix_func ff_emu_edge_hfix6_mmx;
102 extern emu_edge_hfix_func ff_emu_edge_hfix8_mmx;
103 extern emu_edge_hfix_func ff_emu_edge_hfix10_mmx;
104 extern emu_edge_hfix_func ff_emu_edge_hfix12_mmx;
105 extern emu_edge_hfix_func ff_emu_edge_hfix14_mmx;
106 extern emu_edge_hfix_func ff_emu_edge_hfix16_mmx;
107 extern emu_edge_hfix_func ff_emu_edge_hfix18_mmx;
108 extern emu_edge_hfix_func ff_emu_edge_hfix20_mmx;
109 extern emu_edge_hfix_func ff_emu_edge_hfix22_mmx;
111 static emu_edge_hfix_func *
const hfixtbl_mmx[11] = {
112 ff_emu_edge_hfix2_mmx, ff_emu_edge_hfix4_mmx, ff_emu_edge_hfix6_mmx,
113 ff_emu_edge_hfix8_mmx, ff_emu_edge_hfix10_mmx, ff_emu_edge_hfix12_mmx,
114 ff_emu_edge_hfix14_mmx, ff_emu_edge_hfix16_mmx, ff_emu_edge_hfix18_mmx,
115 ff_emu_edge_hfix20_mmx, ff_emu_edge_hfix22_mmx
118 extern emu_edge_hvar_func ff_emu_edge_hvar_mmx;
119 extern emu_edge_hfix_func ff_emu_edge_hfix16_sse2;
120 extern emu_edge_hfix_func ff_emu_edge_hfix18_sse2;
121 extern emu_edge_hfix_func ff_emu_edge_hfix20_sse2;
122 extern emu_edge_hfix_func ff_emu_edge_hfix22_sse2;
123 static emu_edge_hfix_func *
const hfixtbl_sse2[11] = {
124 ff_emu_edge_hfix2_mmx, ff_emu_edge_hfix4_mmx, ff_emu_edge_hfix6_mmx,
125 ff_emu_edge_hfix8_mmx, ff_emu_edge_hfix10_mmx, ff_emu_edge_hfix12_mmx,
126 ff_emu_edge_hfix14_mmx, ff_emu_edge_hfix16_sse2, ff_emu_edge_hfix18_sse2,
127 ff_emu_edge_hfix20_sse2, ff_emu_edge_hfix22_sse2
129 extern emu_edge_hvar_func ff_emu_edge_hvar_sse2;
130 #if HAVE_AVX2_EXTERNAL
131 extern emu_edge_hfix_func ff_emu_edge_hfix8_avx2;
132 extern emu_edge_hfix_func ff_emu_edge_hfix10_avx2;
133 extern emu_edge_hfix_func ff_emu_edge_hfix12_avx2;
134 extern emu_edge_hfix_func ff_emu_edge_hfix14_avx2;
135 extern emu_edge_hfix_func ff_emu_edge_hfix16_avx2;
136 extern emu_edge_hfix_func ff_emu_edge_hfix18_avx2;
137 extern emu_edge_hfix_func ff_emu_edge_hfix20_avx2;
138 extern emu_edge_hfix_func ff_emu_edge_hfix22_avx2;
139 static emu_edge_hfix_func *
const hfixtbl_avx2[11] = {
140 ff_emu_edge_hfix2_mmx, ff_emu_edge_hfix4_mmx, ff_emu_edge_hfix6_mmx,
141 ff_emu_edge_hfix8_avx2, ff_emu_edge_hfix10_avx2, ff_emu_edge_hfix12_avx2,
142 ff_emu_edge_hfix14_avx2, ff_emu_edge_hfix16_avx2, ff_emu_edge_hfix18_avx2,
143 ff_emu_edge_hfix20_avx2, ff_emu_edge_hfix22_avx2
145 extern emu_edge_hvar_func ff_emu_edge_hvar_avx2;
149 ptrdiff_t dst_stride,
150 ptrdiff_t src_stride,
154 emu_edge_vfix_func *
const *vfix_tbl,
155 emu_edge_vvar_func *v_extend_var,
156 emu_edge_hfix_func *
const *hfix_tbl,
157 emu_edge_hvar_func *h_extend_var)
159 x86_reg start_y, start_x, end_y, end_x, src_y_add = 0, p;
167 src -= src_y*src_stride;
170 }
else if (src_y <= -block_h) {
171 src -= src_y*src_stride;
172 src_y_add = 1 - block_h;
176 src +=
w - 1 - src_x;
178 }
else if (src_x <= -block_w) {
179 src += 1 - block_w - src_x;
183 start_y =
FFMAX(0, -src_y);
184 start_x =
FFMAX(0, -src_x);
185 end_y =
FFMIN(block_h,
h-src_y);
186 end_x =
FFMIN(block_w,
w-src_x);
191 src += (src_y_add + start_y) * src_stride + start_x;
194 vfix_tbl[
w - 1](dst + start_x, dst_stride,
src, src_stride,
195 start_y, end_y, block_h);
197 v_extend_var(dst + start_x, dst_stride,
src, src_stride,
198 start_y, end_y, block_h,
w);
204 hfix_tbl[(start_x - 1) >> 1](dst, dst_stride, start_x, block_h);
206 h_extend_var(dst, dst_stride,
207 start_x, (start_x + 1) >> 1, block_h);
215 hfix_tbl[(p - 1) >> 1](dst + end_x - (p & 1), dst_stride,
218 h_extend_var(dst + end_x - (p & 1), dst_stride,
219 -!(p & 1), (p + 1) >> 1, block_h);
225 static av_noinline void emulated_edge_mc_mmx(uint8_t *buf,
const uint8_t *
src,
226 ptrdiff_t buf_stride,
227 ptrdiff_t src_stride,
228 int block_w,
int block_h,
229 int src_x,
int src_y,
int w,
int h)
231 emulated_edge_mc(buf,
src, buf_stride, src_stride, block_w, block_h,
232 src_x, src_y,
w,
h, vfixtbl_mmx, &ff_emu_edge_vvar_mmx,
233 hfixtbl_mmx, &ff_emu_edge_hvar_mmx);
236 static av_noinline void emulated_edge_mc_sse(uint8_t *buf,
const uint8_t *
src,
237 ptrdiff_t buf_stride,
238 ptrdiff_t src_stride,
239 int block_w,
int block_h,
240 int src_x,
int src_y,
int w,
int h)
242 emulated_edge_mc(buf,
src, buf_stride, src_stride, block_w, block_h,
243 src_x, src_y,
w,
h, vfixtbl_sse, &ff_emu_edge_vvar_sse,
244 hfixtbl_mmx, &ff_emu_edge_hvar_mmx);
248 static av_noinline void emulated_edge_mc_sse2(uint8_t *buf,
const uint8_t *
src,
249 ptrdiff_t buf_stride,
250 ptrdiff_t src_stride,
251 int block_w,
int block_h,
252 int src_x,
int src_y,
int w,
255 emulated_edge_mc(buf,
src, buf_stride, src_stride, block_w, block_h,
256 src_x, src_y,
w,
h, vfixtbl_sse, &ff_emu_edge_vvar_sse,
257 hfixtbl_sse2, &ff_emu_edge_hvar_sse2);
260 #if HAVE_AVX2_EXTERNAL
261 static av_noinline void emulated_edge_mc_avx2(uint8_t *buf,
const uint8_t *
src,
262 ptrdiff_t buf_stride,
263 ptrdiff_t src_stride,
264 int block_w,
int block_h,
265 int src_x,
int src_y,
int w,
268 emulated_edge_mc(buf,
src, buf_stride, src_stride, block_w, block_h,
269 src_x, src_y,
w,
h, vfixtbl_sse, &ff_emu_edge_vvar_sse,
270 hfixtbl_avx2, &ff_emu_edge_hvar_avx2);
285 ctx->emulated_edge_mc = emulated_edge_mc_mmx;
296 ctx->emulated_edge_mc = emulated_edge_mc_sse;
300 ctx->emulated_edge_mc = emulated_edge_mc_sse2;
302 #if HAVE_AVX2_EXTERNAL
304 ctx->emulated_edge_mc = emulated_edge_mc_avx2;