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_sse2;
41 extern emu_edge_vfix_func ff_emu_edge_vfix2_sse2;
42 extern emu_edge_vfix_func ff_emu_edge_vfix3_sse2;
43 extern emu_edge_vfix_func ff_emu_edge_vfix4_sse2;
44 extern emu_edge_vfix_func ff_emu_edge_vfix5_sse2;
45 extern emu_edge_vfix_func ff_emu_edge_vfix6_sse2;
46 extern emu_edge_vfix_func ff_emu_edge_vfix7_sse2;
47 extern emu_edge_vfix_func ff_emu_edge_vfix8_sse2;
48 extern emu_edge_vfix_func ff_emu_edge_vfix9_sse2;
49 extern emu_edge_vfix_func ff_emu_edge_vfix10_sse2;
50 extern emu_edge_vfix_func ff_emu_edge_vfix11_sse2;
51 extern emu_edge_vfix_func ff_emu_edge_vfix12_sse2;
52 extern emu_edge_vfix_func ff_emu_edge_vfix13_sse2;
53 extern emu_edge_vfix_func ff_emu_edge_vfix14_sse2;
54 extern emu_edge_vfix_func ff_emu_edge_vfix15_sse2;
55 extern emu_edge_vfix_func ff_emu_edge_vfix16_sse2;
56 extern emu_edge_vfix_func ff_emu_edge_vfix17_sse2;
57 extern emu_edge_vfix_func ff_emu_edge_vfix18_sse2;
58 extern emu_edge_vfix_func ff_emu_edge_vfix19_sse2;
59 extern emu_edge_vfix_func ff_emu_edge_vfix20_sse2;
60 extern emu_edge_vfix_func ff_emu_edge_vfix21_sse2;
61 extern emu_edge_vfix_func ff_emu_edge_vfix22_sse2;
62 static emu_edge_vfix_func *
const vfixtbl_sse2[22] = {
63 ff_emu_edge_vfix1_sse2, ff_emu_edge_vfix2_sse2, ff_emu_edge_vfix3_sse2,
64 ff_emu_edge_vfix4_sse2, ff_emu_edge_vfix5_sse2, ff_emu_edge_vfix6_sse2,
65 ff_emu_edge_vfix7_sse2, ff_emu_edge_vfix8_sse2, ff_emu_edge_vfix9_sse2,
66 ff_emu_edge_vfix10_sse2, ff_emu_edge_vfix11_sse2, ff_emu_edge_vfix12_sse2,
67 ff_emu_edge_vfix13_sse2, ff_emu_edge_vfix14_sse2, ff_emu_edge_vfix15_sse2,
68 ff_emu_edge_vfix16_sse2, ff_emu_edge_vfix17_sse2, ff_emu_edge_vfix18_sse2,
69 ff_emu_edge_vfix19_sse2, ff_emu_edge_vfix20_sse2, ff_emu_edge_vfix21_sse2,
70 ff_emu_edge_vfix22_sse2
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_sse2;
80 extern emu_edge_hfix_func ff_emu_edge_hfix4_sse2;
81 extern emu_edge_hfix_func ff_emu_edge_hfix6_sse2;
82 extern emu_edge_hfix_func ff_emu_edge_hfix8_sse2;
83 extern emu_edge_hfix_func ff_emu_edge_hfix10_sse2;
84 extern emu_edge_hfix_func ff_emu_edge_hfix12_sse2;
85 extern emu_edge_hfix_func ff_emu_edge_hfix14_sse2;
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_sse2, ff_emu_edge_hfix4_sse2, ff_emu_edge_hfix6_sse2,
92 ff_emu_edge_hfix8_sse2, ff_emu_edge_hfix10_sse2, ff_emu_edge_hfix12_sse2,
93 ff_emu_edge_hfix14_sse2, 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_sse2, ff_emu_edge_hfix4_sse2, ff_emu_edge_hfix6_sse2,
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_sse2, &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_sse2, &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;