History

avfilter/vf_v360: x86 SIMD for interpolations

Paul B Mahol committed 7 years ago

Commit 058bbf41 parent f0d80055 files · +394 −155Browse files

Showing the changes to libavfilter (5 of 5 files). Show all

Unified · Split

5 files
  1. libavfilter/v360.h +113 −0
  2. libavfilter/vf_v360.c +87 −155
  3. libavfilter/x86/Makefile +2 −0
  4. libavfilter/x86/vf_v360.asm +142 −0
  5. libavfilter/x86/vf_v360_init.c +50 −0
libavfilter/v360.h+113−0
@@ -0,0 +1,113 @@
1+/*
2+ * Copyright (c) 2019 Eugene Lyapustin
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+#ifndef AVFILTER_V360_H
22+#define AVFILTER_V360_H
23+#include "avfilter.h"
24+
25+enum Projections {
26+ EQUIRECTANGULAR,
27+ CUBEMAP_3_2,
28+ CUBEMAP_6_1,
29+ EQUIANGULAR,
30+ FLAT,
31+ DUAL_FISHEYE,
32+ BARREL,
33+ CUBEMAP_1_6,
34+ NB_PROJECTIONS,
35+};
36+
37+enum InterpMethod {
38+ NEAREST,
39+ BILINEAR,
40+ BICUBIC,
41+ LANCZOS,
42+ NB_INTERP_METHODS,
43+};
44+
45+enum Faces {
46+ TOP_LEFT,
47+ TOP_MIDDLE,
48+ TOP_RIGHT,
49+ BOTTOM_LEFT,
50+ BOTTOM_MIDDLE,
51+ BOTTOM_RIGHT,
52+ NB_FACES,
53+};
54+
55+enum Direction {
56+ RIGHT, ///< Axis +X
57+ LEFT, ///< Axis -X
58+ UP, ///< Axis +Y
59+ DOWN, ///< Axis -Y
60+ FRONT, ///< Axis -Z
61+ BACK, ///< Axis +Z
62+ NB_DIRECTIONS,
63+};
64+
65+enum Rotation {
66+ ROT_0,
67+ ROT_90,
68+ ROT_180,
69+ ROT_270,
70+ NB_ROTATIONS,
71+};
72+
73+typedef struct V360Context {
74+ const AVClass *class;
75+ int in, out;
76+ int interp;
77+ int width, height;
78+ char* in_forder;
79+ char* out_forder;
80+ char* in_frot;
81+ char* out_frot;
82+
83+ int in_cubemap_face_order[6];
84+ int out_cubemap_direction_order[6];
85+ int in_cubemap_face_rotation[6];
86+ int out_cubemap_face_rotation[6];
87+
88+ float in_pad, out_pad;
89+
90+ float yaw, pitch, roll;
91+
92+ int h_flip, v_flip, d_flip;
93+
94+ float h_fov, v_fov;
95+ float flat_range[3];
96+
97+ int planewidth[4], planeheight[4];
98+ int inplanewidth[4], inplaneheight[4];
99+ int nb_planes;
100+
101+ uint16_t *u[4], *v[4];
102+ int16_t *ker[4];
103+
104+ int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
105+
106+ void (*remap_line)(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
107+ const uint16_t *u, const uint16_t *v, const int16_t *ker);
108+} V360Context;
109+
110+void ff_v360_init(V360Context *s, int depth);
111+void ff_v360_init_x86(V360Context *s, int depth);
112+
113+#endif /* AVFILTER_V360_H */
libavfilter/vf_v360.c+87−155
@@ -41,88 +41,7 @@ · 40 unmodified lines
4141 #include "formats.h"
4242 #include "internal.h"
4343 #include "video.h"
44−
45−enum Projections {
46− EQUIRECTANGULAR,
47− CUBEMAP_3_2,
48− CUBEMAP_6_1,
49− EQUIANGULAR,
50− FLAT,
51− DUAL_FISHEYE,
52− BARREL,
53− CUBEMAP_1_6,
54− NB_PROJECTIONS,
55−};
56−
57−enum InterpMethod {
58− NEAREST,
59− BILINEAR,
60− BICUBIC,
61− LANCZOS,
62− NB_INTERP_METHODS,
63−};
64−
65−enum Faces {
66− TOP_LEFT,
67− TOP_MIDDLE,
68− TOP_RIGHT,
69− BOTTOM_LEFT,
70− BOTTOM_MIDDLE,
71− BOTTOM_RIGHT,
72− NB_FACES,
73−};
74−
75−enum Direction {
76− RIGHT, ///< Axis +X
77− LEFT, ///< Axis -X
78− UP, ///< Axis +Y
79− DOWN, ///< Axis -Y
80− FRONT, ///< Axis -Z
81− BACK, ///< Axis +Z
82− NB_DIRECTIONS,
83−};
84−
85−enum Rotation {
86− ROT_0,
87− ROT_90,
88− ROT_180,
89− ROT_270,
90− NB_ROTATIONS,
91−};
92−
93−typedef struct V360Context {
94− const AVClass *class;
95− int in, out;
96− int interp;
97− int width, height;
98− char* in_forder;
99− char* out_forder;
100− char* in_frot;
101− char* out_frot;
102−
103− int in_cubemap_face_order[6];
104− int out_cubemap_direction_order[6];
105− int in_cubemap_face_rotation[6];
106− int out_cubemap_face_rotation[6];
107−
108− float in_pad, out_pad;
109−
110− float yaw, pitch, roll;
111−
112− int h_flip, v_flip, d_flip;
113−
114− float h_fov, v_fov;
115− float flat_range[3];
116−
117− int planewidth[4], planeheight[4];
118− int inplanewidth[4], inplaneheight[4];
119− int nb_planes;
120−
121− uint16_t *u[4], *v[4];
122− int16_t *ker[4];
123−
124− int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
125−} V360Context;
44+#include "v360.h"
12645
12746 typedef struct ThreadData {
12847 AVFrame *in;
@@ -251,47 +170,22 @@ static int query_formats(AVFilterContext *ctx) · 122 unmodified lines
251170 return ff_set_common_formats(ctx, fmts_list);
252171 }
253172
254−/**
255− * Generate no-interpolation remapping function with a given pixel depth.
256− *
257− * @param bits number of bits per pixel
258− * @param div number of bytes per pixel
259− */
260−#define DEFINE_REMAP1(bits, div) \
261−static int remap1_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
262−{ \
263− ThreadData *td = (ThreadData*)arg; \
264− const V360Context *s = ctx->priv; \
265− const AVFrame *in = td->in; \
266− AVFrame *out = td->out; \
267− \
268− int plane, x, y; \
269− \
270− for (plane = 0; plane < s->nb_planes; plane++) { \
271− const int in_linesize = in->linesize[plane] / div; \
272− const int out_linesize = out->linesize[plane] / div; \
273− const uint##bits##_t *src = (const uint##bits##_t *)in->data[plane]; \
274− uint##bits##_t *dst = (uint##bits##_t *)out->data[plane]; \
275− const int width = s->planewidth[plane]; \
276− const int height = s->planeheight[plane]; \
277− \
278− const int slice_start = (height * jobnr ) / nb_jobs; \
279− const int slice_end = (height * (jobnr + 1)) / nb_jobs; \
280− \
281− for (y = slice_start; y < slice_end; y++) { \
282− const uint16_t *u = s->u[plane] + y * width; \
283− const uint16_t *v = s->v[plane] + y * width; \
284− uint##bits##_t *d = dst + y * out_linesize; \
285− for (x = 0; x < width; x++) \
286− *d++ = src[v[x] * in_linesize + u[x]]; \
287− } \
288− } \
289− \
290− return 0; \
173+#define DEFINE_REMAP1_LINE(bits, div) \
174+static void remap1_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *src, \
175+ ptrdiff_t in_linesize, \
176+ const uint16_t *u, const uint16_t *v, const int16_t *ker) \
177+{ \
178+ const uint##bits##_t *s = (const uint##bits##_t *)src; \
179+ uint##bits##_t *d = (uint##bits##_t *)dst; \
180+ \
181+ in_linesize /= div; \
182+ \
183+ for (int x = 0; x < width; x++) \
184+ d[x] = s[v[x] * in_linesize + u[x]]; \
291185 }
292186
293−DEFINE_REMAP1( 8, 1)
294−DEFINE_REMAP1(16, 2)
187+DEFINE_REMAP1_LINE( 8, 1)
188+DEFINE_REMAP1_LINE(16, 2)
295189
296190 typedef struct XYRemap {
297191 uint16_t u[4][4];
@@ -304,9 +198,8 @@ typedef struct XYRemap { · 6 unmodified lines
304198 *
305199 * @param ws size of interpolation window
306200 * @param bits number of bits per pixel
307− * @param div number of bytes per pixel
308201 */
309−#define DEFINE_REMAP(ws, bits, div) \
202+#define DEFINE_REMAP(ws, bits) \
310203 static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
311204 { \
312205 ThreadData *td = (ThreadData*)arg; \
@@ -314,48 +207,85 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo · 1 unmodified line
314207 const AVFrame *in = td->in; \
315208 AVFrame *out = td->out; \
316209 \
317− int plane, x, y, i, j; \
318− \
319− for (plane = 0; plane < s->nb_planes; plane++) { \
320− const int in_linesize = in->linesize[plane] / div; \
321− const int out_linesize = out->linesize[plane] / div; \
322− const uint##bits##_t *src = (const uint##bits##_t *)in->data[plane]; \
323− uint##bits##_t *dst = (uint##bits##_t *)out->data[plane]; \
210+ for (int plane = 0; plane < s->nb_planes; plane++) { \
211+ const int in_linesize = in->linesize[plane]; \
212+ const int out_linesize = out->linesize[plane]; \
213+ const uint8_t *src = in->data[plane]; \
214+ uint8_t *dst = out->data[plane]; \
324215 const int width = s->planewidth[plane]; \
325216 const int height = s->planeheight[plane]; \
326217 \
327218 const int slice_start = (height * jobnr ) / nb_jobs; \
328219 const int slice_end = (height * (jobnr + 1)) / nb_jobs; \
329220 \
330− for (y = slice_start; y < slice_end; y++) { \
331− uint##bits##_t *d = dst + y * out_linesize; \
221+ for (int y = slice_start; y < slice_end; y++) { \
332222 const uint16_t *u = s->u[plane] + y * width * ws * ws; \
333223 const uint16_t *v = s->v[plane] + y * width * ws * ws; \
334224 const int16_t *ker = s->ker[plane] + y * width * ws * ws; \
335− for (x = 0; x < width; x++) { \
336− const uint16_t *uu = u + x * ws * ws; \
337− const uint16_t *vv = v + x * ws * ws; \
338− const int16_t *kker = ker + x * ws * ws; \
339− int tmp = 0; \
340− \
341− for (i = 0; i < ws; i++) { \
342− for (j = 0; j < ws; j++) { \
343− tmp += kker[i * ws + j] * src[vv[i * ws + j] * in_linesize + uu[i * ws + j]]; \
344− } \
345− } \
346225 \
347− *d++ = av_clip_uint##bits(tmp >> (15 - ws)); \
348− } \
226+ s->remap_line(dst + y * out_linesize, width, src, in_linesize, u, v, ker); \
349227 } \
350228 } \
351229 \
352230 return 0; \
353231 }
354232
355−DEFINE_REMAP(2, 8, 1)
356−DEFINE_REMAP(4, 8, 1)
357−DEFINE_REMAP(2, 16, 2)
358−DEFINE_REMAP(4, 16, 2)
233+DEFINE_REMAP(1, 8)
234+DEFINE_REMAP(2, 8)
235+DEFINE_REMAP(4, 8)
236+DEFINE_REMAP(1, 16)
237+DEFINE_REMAP(2, 16)
238+DEFINE_REMAP(4, 16)
239+
240+#define DEFINE_REMAP_LINE(ws, bits, div) \
241+static void remap##ws##_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *src, \
242+ ptrdiff_t in_linesize, \
243+ const uint16_t *u, const uint16_t *v, const int16_t *ker) \
244+{ \
245+ const uint##bits##_t *s = (const uint##bits##_t *)src; \
246+ uint##bits##_t *d = (uint##bits##_t *)dst; \
247+ \
248+ in_linesize /= div; \
249+ \
250+ for (int x = 0; x < width; x++) { \
251+ const uint16_t *uu = u + x * ws * ws; \
252+ const uint16_t *vv = v + x * ws * ws; \
253+ const int16_t *kker = ker + x * ws * ws; \
254+ int tmp = 0; \
255+ \
256+ for (int i = 0; i < ws; i++) { \
257+ for (int j = 0; j < ws; j++) { \
258+ tmp += kker[i * ws + j] * s[vv[i * ws + j] * in_linesize + uu[i * ws + j]]; \
259+ } \
260+ } \
261+ \
262+ d[x] = av_clip_uint##bits(tmp >> 14); \
263+ } \
264+}
265+
266+DEFINE_REMAP_LINE(2, 8, 1)
267+DEFINE_REMAP_LINE(4, 8, 1)
268+DEFINE_REMAP_LINE(2, 16, 2)
269+DEFINE_REMAP_LINE(4, 16, 2)
270+
271+void ff_v360_init(V360Context *s, int depth)
272+{
273+ switch (s->interp) {
274+ case NEAREST:
275+ s->remap_line = depth <= 8 ? remap1_8bit_line_c : remap1_16bit_line_c;
276+ break;
277+ case BILINEAR:
278+ s->remap_line = depth <= 8 ? remap2_8bit_line_c : remap2_16bit_line_c;
279+ break;
280+ case BICUBIC:
281+ case LANCZOS:
282+ s->remap_line = depth <= 8 ? remap4_8bit_line_c : remap4_16bit_line_c;
283+ break;
284+ }
285+
286+ if (ARCH_X86_64)
287+ ff_v360_init_x86(s, depth);
288+}
359289
360290 /**
361291 * Save nearest pixel coordinates for remapping.
@@ -399,10 +329,10 @@ static void bilinear_kernel(float du, float dv, const XYRemap *r_tmp, · 37 unmodified lines
399329 }
400330 }
401331
402− ker[0] = (1.f - du) * (1.f - dv) * 8192;
403− ker[1] = du * (1.f - dv) * 8192;
404− ker[2] = (1.f - du) * dv * 8192;
405− ker[3] = du * dv * 8192;
332+ ker[0] = (1.f - du) * (1.f - dv) * 16384;
333+ ker[1] = du * (1.f - dv) * 16384;
334+ ker[2] = (1.f - du) * dv * 16384;
335+ ker[3] = du * dv * 16384;
406336 }
407337
408338 /**
@@ -446,7 +376,7 @@ static void bicubic_kernel(float du, float dv, const XYRemap *r_tmp, · 37 unmodified lines
446376 for (j = 0; j < 4; j++) {
447377 u[i * 4 + j] = r_tmp->u[i][j];
448378 v[i * 4 + j] = r_tmp->v[i][j];
449− ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i] * 2048;
379+ ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i] * 16384;
450380 }
451381 }
452382 }
@@ -501,7 +431,7 @@ static void lanczos_kernel(float du, float dv, const XYRemap *r_tmp, · 48 unmodified lines
501431 for (j = 0; j < 4; j++) {
502432 u[i * 4 + j] = r_tmp->u[i][j];
503433 v[i * 4 + j] = r_tmp->v[i][j];
504− ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i] * 2048;
434+ ker[i * 4 + j] = du_coeffs[j] * dv_coeffs[i] * 16384;
505435 }
506436 }
507437 }
@@ -2038,6 +1968,8 @@ static int config_output(AVFilterLink *outlink) · 1530 unmodified lines
20381968 av_assert0(0);
20391969 }
20401970
1971+ ff_v360_init(s, depth);
1972+
20411973 switch (s->in) {
20421974 case EQUIRECTANGULAR:
20431975 in_transform = xyz_to_equirect;
libavfilter/x86/Makefile+2−0
@@ -31,6 +31,7 @@ OBJS-$(CONFIG_TBLEND_FILTER) += x86/vf_blend_init.o · 30 unmodified lines
3131 OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold_init.o
3232 OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_tinterlace_init.o
3333 OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o
34+OBJS-$(CONFIG_V360_FILTER) += x86/vf_v360_init.o
3435 OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif_init.o
3536 OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o
3637
@@ -66,5 +67,6 @@ X86ASM-OBJS-$(CONFIG_TBLEND_FILTER) += x86/vf_blend.o · 29 unmodified lines
6667 X86ASM-OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold.o
6768 X86ASM-OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_interlace.o
6869 X86ASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o
70+X86ASM-OBJS-$(CONFIG_V360_FILTER) += x86/vf_v360.o
6971 X86ASM-OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif.o
7072 X86ASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif.o x86/yadif-16.o x86/yadif-10.o
libavfilter/x86/vf_v360.asm+142−0
@@ -0,0 +1,142 @@
1+;*****************************************************************************
2+;* x86-optimized functions for v360 filter
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+%if HAVE_AVX2_EXTERNAL && ARCH_X86_64
22+
23+%include "libavutil/x86/x86util.asm"
24+
25+SECTION_RODATA
26+
27+pb_mask: db 0,4,8,12,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
28+pd_255: times 4 dd 255
29+
30+SECTION .text
31+
32+; void ff_remap2_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
33+; const uint16_t *u, const uint16_t *v, const int16_t *ker);
34+
35+INIT_YMM avx2
36+cglobal remap1_8bit_line, 6, 7, 6, dst, width, src, in_linesize, u, v, x
37+ movsxdifnidn widthq, widthd
38+ xor xq, xq
39+ movd xm0, in_linesized
40+ pcmpeqw m4, m4
41+ VBROADCASTI128 m3, [pb_mask]
42+ vpbroadcastd m0, xm0
43+
44+ .loop:
45+ pmovsxwd m1, [vq + xq * 2]
46+ pmovsxwd m2, [uq + xq * 2]
47+
48+ pmulld m1, m0
49+ paddd m1, m2
50+ mova m2, m4
51+ vpgatherdd m5, [srcq + m1], m2
52+ pshufb m1, m5, m3
53+ vextracti128 xm2, m1, 1
54+ movd [dstq+xq], xm1
55+ movd [dstq+xq+4], xm2
56+
57+ add xq, mmsize / 4
58+ cmp xq, widthq
59+ jl .loop
60+ RET
61+
62+INIT_YMM avx2
63+cglobal remap2_8bit_line, 7, 8, 8, dst, width, src, in_linesize, u, v, ker, x
64+ movsxdifnidn widthq, widthd
65+ xor xq, xq
66+ movd xm0, in_linesized
67+ pcmpeqw m7, m7
68+ vpbroadcastd m0, xm0
69+ vpbroadcastd m6, [pd_255]
70+
71+ .loop:
72+ pmovsxwd m1, [kerq + xq * 8]
73+ pmovsxwd m2, [vq + xq * 8]
74+ pmovsxwd m3, [uq + xq * 8]
75+
76+ pmulld m4, m2, m0
77+ paddd m4, m3
78+ mova m3, m7
79+ vpgatherdd m2, [srcq + m4], m3
80+ pand m2, m6
81+ pmulld m2, m1
82+ phaddd m2, m2
83+ phaddd m1, m2, m2
84+ psrld m1, m1, 0xe
85+ vextracti128 xm2, m1, 1
86+
87+ pextrb [dstq+xq], xm1, 0
88+ pextrb [dstq+xq+1], xm2, 0
89+
90+ add xq, mmsize / 16
91+ cmp xq, widthq
92+ jl .loop
93+ RET
94+
95+INIT_YMM avx2
96+cglobal remap4_8bit_line, 7, 9, 11, dst, width, src, in_linesize, u, v, ker, x, y
97+ movsxdifnidn widthq, widthd
98+ xor yq, yq
99+ xor xq, xq
100+ movd xm0, in_linesized
101+ pcmpeqw m7, m7
102+ vpbroadcastd m0, xm0
103+ vpbroadcastd m6, [pd_255]
104+
105+ .loop:
106+ pmovsxwd m1, [kerq + yq]
107+ pmovsxwd m5, [kerq + yq + 16]
108+ pmovsxwd m2, [vq + yq]
109+ pmovsxwd m8, [vq + yq + 16]
110+ pmovsxwd m3, [uq + yq]
111+ pmovsxwd m9, [uq + yq + 16]
112+
113+ pmulld m4, m2, m0
114+ pmulld m10, m8, m0
115+ paddd m4, m3
116+ paddd m10, m9
117+ mova m3, m7
118+ vpgatherdd m2, [srcq + m4], m3
119+ mova m3, m7
120+ vpgatherdd m4, [srcq + m10], m3
121+ pand m2, m6
122+ pand m4, m6
123+ pmulld m2, m1
124+ pmulld m4, m5
125+
126+ paddd m2, m4
127+ vextracti128 xm1, m2, 1
128+ paddd m1, m2
129+ phaddd m1, m1
130+ phaddd m1, m1
131+ psrld m1, m1, 0xe
132+ packuswb m1, m1
133+
134+ pextrb [dstq+xq], xm1, 0
135+
136+ add xq, 1
137+ add yq, 32
138+ cmp xq, widthq
139+ jl .loop
140+ RET
141+
142+%endif
libavfilter/x86/vf_v360_init.c+50−0
@@ -0,0 +1,50 @@
1+/*
2+ * This file is part of FFmpeg.
3+ *
4+ * FFmpeg is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * FFmpeg is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with FFmpeg; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+#include "config.h"
20+
21+#include "libavutil/attributes.h"
22+#include "libavutil/cpu.h"
23+#include "libavutil/x86/cpu.h"
24+#include "libavfilter/v360.h"
25+
26+void ff_remap1_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
27+ const uint16_t *u, const uint16_t *v, const int16_t *ker);
28+
29+void ff_remap2_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
30+ const uint16_t *u, const uint16_t *v, const int16_t *ker);
31+
32+void ff_remap4_8bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrdiff_t in_linesize,
33+ const uint16_t *u, const uint16_t *v, const int16_t *ker);
34+
35+av_cold void ff_v360_init_x86(V360Context *s, int depth)
36+{
37+#if ARCH_X86_64
38+ int cpu_flags = av_get_cpu_flags();
39+
40+ if (EXTERNAL_AVX2_FAST(cpu_flags) && s->interp == NEAREST && depth <= 8)
41+ s->remap_line = ff_remap1_8bit_line_avx2;
42+
43+ if (EXTERNAL_AVX2_FAST(cpu_flags) && s->interp == BILINEAR && depth <= 8)
44+ s->remap_line = ff_remap2_8bit_line_avx2;
45+
46+ if (EXTERNAL_AVX2_FAST(cpu_flags) && (s->interp == BICUBIC ||
47+ s->interp == LANCZOS) && depth <= 8)
48+ s->remap_line = ff_remap4_8bit_line_avx2;
49+#endif
50+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t