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_sse;
56 extern emu_edge_vfix_func ff_emu_edge_vfix17_sse;
57 extern emu_edge_vfix_func ff_emu_edge_vfix18_sse;
58 extern emu_edge_vfix_func ff_emu_edge_vfix19_sse;
59 extern emu_edge_vfix_func ff_emu_edge_vfix20_sse;
60 extern emu_edge_vfix_func ff_emu_edge_vfix21_sse;
61 extern emu_edge_vfix_func ff_emu_edge_vfix22_sse;
62 static emu_edge_vfix_func *
const vfixtbl_sse[22] = {
63 ff_emu_edge_vfix1_mmx, ff_emu_edge_vfix2_mmx, ff_emu_edge_vfix3_mmx,
64 ff_emu_edge_vfix4_mmx, ff_emu_edge_vfix5_mmx, ff_emu_edge_vfix6_mmx,
65 ff_emu_edge_vfix7_mmx, ff_emu_edge_vfix8_mmx, ff_emu_edge_vfix9_mmx,
66 ff_emu_edge_vfix10_mmx, ff_emu_edge_vfix11_mmx, ff_emu_edge_vfix12_mmx,
67 ff_emu_edge_vfix13_mmx, ff_emu_edge_vfix14_mmx, ff_emu_edge_vfix15_mmx,
68 ff_emu_edge_vfix16_sse, ff_emu_edge_vfix17_sse, ff_emu_edge_vfix18_sse,
69 ff_emu_edge_vfix19_sse, ff_emu_edge_vfix20_sse, ff_emu_edge_vfix21_sse,
70 ff_emu_edge_vfix22_sse
72 extern emu_edge_vvar_func ff_emu_edge_vvar_sse;
74 typedef void emu_edge_hfix_func(uint8_t *
dst,
x86_reg dst_stride,
76 typedef void emu_edge_hvar_func(uint8_t *
dst,
x86_reg dst_stride,
79 extern emu_edge_hfix_func ff_emu_edge_hfix2_mmx;
80 extern emu_edge_hfix_func ff_emu_edge_hfix4_mmx;
81 extern emu_edge_hfix_func ff_emu_edge_hfix6_mmx;
82 extern emu_edge_hfix_func ff_emu_edge_hfix8_mmx;
83 extern emu_edge_hfix_func ff_emu_edge_hfix10_mmx;
84 extern emu_edge_hfix_func ff_emu_edge_hfix12_mmx;
85 extern emu_edge_hfix_func ff_emu_edge_hfix14_mmx;
86 extern emu_edge_hfix_func ff_emu_edge_hfix16_sse2;
87 extern emu_edge_hfix_func ff_emu_edge_hfix18_sse2;
88 extern emu_edge_hfix_func ff_emu_edge_hfix20_sse2;
89 extern emu_edge_hfix_func ff_emu_edge_hfix22_sse2;
90 static emu_edge_hfix_func *
const hfixtbl_sse2[11] = {
91 ff_emu_edge_hfix2_mmx, ff_emu_edge_hfix4_mmx, ff_emu_edge_hfix6_mmx,
92 ff_emu_edge_hfix8_mmx, ff_emu_edge_hfix10_mmx, ff_emu_edge_hfix12_mmx,
93 ff_emu_edge_hfix14_mmx, ff_emu_edge_hfix16_sse2, ff_emu_edge_hfix18_sse2,
94 ff_emu_edge_hfix20_sse2, ff_emu_edge_hfix22_sse2
96 extern emu_edge_hvar_func ff_emu_edge_hvar_sse2;
97 #if HAVE_AVX2_EXTERNAL
98 extern emu_edge_hfix_func ff_emu_edge_hfix8_avx2;
99 extern emu_edge_hfix_func ff_emu_edge_hfix10_avx2;
100 extern emu_edge_hfix_func ff_emu_edge_hfix12_avx2;
101 extern emu_edge_hfix_func ff_emu_edge_hfix14_avx2;
102 extern emu_edge_hfix_func ff_emu_edge_hfix16_avx2;
103 extern emu_edge_hfix_func ff_emu_edge_hfix18_avx2;
104 extern emu_edge_hfix_func ff_emu_edge_hfix20_avx2;
105 extern emu_edge_hfix_func ff_emu_edge_hfix22_avx2;
106 static emu_edge_hfix_func *
const hfixtbl_avx2[11] = {
107 ff_emu_edge_hfix2_mmx, ff_emu_edge_hfix4_mmx, ff_emu_edge_hfix6_mmx,
108 ff_emu_edge_hfix8_avx2, ff_emu_edge_hfix10_avx2, ff_emu_edge_hfix12_avx2,
109 ff_emu_edge_hfix14_avx2, ff_emu_edge_hfix16_avx2, ff_emu_edge_hfix18_avx2,
110 ff_emu_edge_hfix20_avx2, ff_emu_edge_hfix22_avx2
112 extern emu_edge_hvar_func ff_emu_edge_hvar_avx2;
116 ptrdiff_t dst_stride,
117 ptrdiff_t src_stride,
121 emu_edge_vfix_func *
const *vfix_tbl,
122 emu_edge_vvar_func *v_extend_var,
123 emu_edge_hfix_func *
const *hfix_tbl,
124 emu_edge_hvar_func *h_extend_var)
126 x86_reg start_y, start_x, end_y, end_x, src_y_add = 0, p;
134 src -= src_y*src_stride;
137 }
else if (src_y <= -block_h) {
138 src -= src_y*src_stride;
139 src_y_add = 1 - block_h;
143 src +=
w - 1 - src_x;
145 }
else if (src_x <= -block_w) {
146 src += 1 - block_w - src_x;
150 start_y =
FFMAX(0, -src_y);
151 start_x =
FFMAX(0, -src_x);
152 end_y =
FFMIN(block_h,
h-src_y);
153 end_x =
FFMIN(block_w,
w-src_x);
158 src += (src_y_add + start_y) * src_stride + start_x;
161 vfix_tbl[
w - 1](
dst + start_x, dst_stride,
src, src_stride,
162 start_y, end_y, block_h);
164 v_extend_var(
dst + start_x, dst_stride,
src, src_stride,
165 start_y, end_y, block_h,
w);
171 hfix_tbl[(start_x - 1) >> 1](
dst, dst_stride, start_x, block_h);
173 h_extend_var(
dst, dst_stride,
174 start_x, (start_x + 1) >> 1, block_h);
182 hfix_tbl[(p - 1) >> 1](
dst + end_x - (p & 1), dst_stride,
185 h_extend_var(
dst + end_x - (p & 1), dst_stride,
186 -!(p & 1), (p + 1) >> 1, block_h);
191 static av_noinline void emulated_edge_mc_sse2(uint8_t *buf,
const uint8_t *
src,
192 ptrdiff_t buf_stride,
193 ptrdiff_t src_stride,
194 int block_w,
int block_h,
195 int src_x,
int src_y,
int w,
198 emulated_edge_mc(buf,
src, buf_stride, src_stride, block_w, block_h,
199 src_x, src_y,
w,
h, vfixtbl_sse, &ff_emu_edge_vvar_sse,
200 hfixtbl_sse2, &ff_emu_edge_hvar_sse2);
203 #if HAVE_AVX2_EXTERNAL
204 static av_noinline void emulated_edge_mc_avx2(uint8_t *buf,
const uint8_t *
src,
205 ptrdiff_t buf_stride,
206 ptrdiff_t src_stride,
207 int block_w,
int block_h,
208 int src_x,
int src_y,
int w,
211 emulated_edge_mc(buf,
src, buf_stride, src_stride, block_w, block_h,
212 src_x, src_y,
w,
h, vfixtbl_sse, &ff_emu_edge_vvar_sse,
213 hfixtbl_avx2, &ff_emu_edge_hvar_avx2);
229 ctx->emulated_edge_mc = emulated_edge_mc_sse2;
231 #if HAVE_AVX2_EXTERNAL
233 ctx->emulated_edge_mc = emulated_edge_mc_avx2;