History

avfilter/vf_v360: x86 SIMD for interpolations

Paul B Mahol committed 7 years ago

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

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
25enum 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
37enum InterpMethod {
38 NEAREST,
39 BILINEAR,
40 BICUBIC,
41 LANCZOS,
42 NB_INTERP_METHODS,
43};
44
45enum Faces {
46 TOP_LEFT,
47 TOP_MIDDLE,
48 TOP_RIGHT,
49 BOTTOM_LEFT,
50 BOTTOM_MIDDLE,
51 BOTTOM_RIGHT,
52 NB_FACES,
53};
54
55enum 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
65enum Rotation {
66 ROT_0,
67 ROT_90,
68 ROT_180,
69 ROT_270,
70 NB_ROTATIONS,
71};
72
73typedef 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
110void ff_v360_init(V360Context *s, int depth);
111void 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
41#include "formats.h"41#include "formats.h"
42#include "internal.h"42#include "internal.h"
43#include "video.h"43#include "video.h"
44 44#include "v360.h"
45enum 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
57enum InterpMethod {
58 NEAREST,
59 BILINEAR,
60 BICUBIC,
61 LANCZOS,
62 NB_INTERP_METHODS,
63};
64
65enum Faces {
66 TOP_LEFT,
67 TOP_MIDDLE,
68 TOP_RIGHT,
69 BOTTOM_LEFT,
70 BOTTOM_MIDDLE,
71 BOTTOM_RIGHT,
72 NB_FACES,
73};
74
75enum 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
85enum Rotation {
86 ROT_0,
87 ROT_90,
88 ROT_180,
89 ROT_270,
90 NB_ROTATIONS,
91};
92
93typedef 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;
126 45
127typedef struct ThreadData {46typedef struct ThreadData {
128 AVFrame *in;47 AVFrame *in;
@@ -251,47 +170,22 @@ static int query_formats(AVFilterContext *ctx) · 122 unmodified lines
251 return ff_set_common_formats(ctx, fmts_list);170 return ff_set_common_formats(ctx, fmts_list);
252}171}
253 172
254/**173#define DEFINE_REMAP1_LINE(bits, div) \
255 * Generate no-interpolation remapping function with a given pixel depth.174static void remap1_##bits##bit_line_c(uint8_t *dst, int width, const uint8_t *src, \
256 *175 ptrdiff_t in_linesize, \
257 * @param bits number of bits per pixel176 const uint16_t *u, const uint16_t *v, const int16_t *ker) \
258 * @param div number of bytes per pixel177{ \
259 */178 const uint##bits##_t *s = (const uint##bits##_t *)src; \
260#define DEFINE_REMAP1(bits, div) \179 uint##bits##_t *d = (uint##bits##_t *)dst; \
261static int remap1_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \180 \
262{ \181 in_linesize /= div; \
263 ThreadData *td = (ThreadData*)arg; \182 \
264 const V360Context *s = ctx->priv; \183 for (int x = 0; x < width; x++) \
265 const AVFrame *in = td->in; \184 d[x] = s[v[x] * in_linesize + u[x]]; \
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; \
291}185}
292 186
293DEFINE_REMAP1( 8, 1)187DEFINE_REMAP1_LINE( 8, 1)
294DEFINE_REMAP1(16, 2)188DEFINE_REMAP1_LINE(16, 2)
295 189
296typedef struct XYRemap {190typedef struct XYRemap {
297 uint16_t u[4][4];191 uint16_t u[4][4];
@@ -304,9 +198,8 @@ typedef struct XYRemap { · 6 unmodified lines
304 *198 *
305 * @param ws size of interpolation window199 * @param ws size of interpolation window
306 * @param bits number of bits per pixel200 * @param bits number of bits per pixel
307 * @param div number of bytes per pixel
308 */201 */
309#define DEFINE_REMAP(ws, bits, div) \202#define DEFINE_REMAP(ws, bits) \
310static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \203static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
311{ \204{ \
312 ThreadData *td = (ThreadData*)arg; \205 ThreadData *td = (ThreadData*)arg; \
@@ -314,48 +207,85 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo · 1 unmodified line
314 const AVFrame *in = td->in; \207 const AVFrame *in = td->in; \
315 AVFrame *out = td->out; \208 AVFrame *out = td->out; \
316 \209 \
317 int plane, x, y, i, j; \210 for (int plane = 0; plane < s->nb_planes; plane++) { \
318 \211 const int in_linesize = in->linesize[plane]; \
319 for (plane = 0; plane < s->nb_planes; plane++) { \212 const int out_linesize = out->linesize[plane]; \
320 const int in_linesize = in->linesize[plane] / div; \213 const uint8_t *src = in->data[plane]; \
321 const int out_linesize = out->linesize[plane] / div; \214 uint8_t *dst = out->data[plane]; \
322 const uint##bits##_t *src = (const uint##bits##_t *)in->data[plane]; \
323 uint##bits##_t *dst = (uint##bits##_t *)out->data[plane]; \
324 const int width = s->planewidth[plane]; \215 const int width = s->planewidth[plane]; \
325 const int height = s->planeheight[plane]; \216 const int height = s->planeheight[plane]; \
326 \217 \
327 const int slice_start = (height * jobnr ) / nb_jobs; \218 const int slice_start = (height * jobnr ) / nb_jobs; \
328 const int slice_end = (height * (jobnr + 1)) / nb_jobs; \219 const int slice_end = (height * (jobnr + 1)) / nb_jobs; \
329 \220 \
330 for (y = slice_start; y < slice_end; y++) { \221 for (int y = slice_start; y < slice_end; y++) { \
331 uint##bits##_t *d = dst + y * out_linesize; \
332 const uint16_t *u = s->u[plane] + y * width * ws * ws; \222 const uint16_t *u = s->u[plane] + y * width * ws * ws; \
333 const uint16_t *v = s->v[plane] + y * width * ws * ws; \223 const uint16_t *v = s->v[plane] + y * width * ws * ws; \
334 const int16_t *ker = s->ker[plane] + y * width * ws * ws; \224 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 } \
346 \225 \
347 *d++ = av_clip_uint##bits(tmp >> (15 - ws)); \226 s->remap_line(dst + y * out_linesize, width, src, in_linesize, u, v, ker); \
348 } \
349 } \227 } \
350 } \228 } \
351 \229 \
352 return 0; \230 return 0; \
353}231}
354 232
355DEFINE_REMAP(2, 8, 1)233DEFINE_REMAP(1, 8)
356DEFINE_REMAP(4, 8, 1)234DEFINE_REMAP(2, 8)
357DEFINE_REMAP(2, 16, 2)235DEFINE_REMAP(4, 8)
358DEFINE_REMAP(4, 16, 2)236DEFINE_REMAP(1, 16)
237DEFINE_REMAP(2, 16)
238DEFINE_REMAP(4, 16)
239
240#define DEFINE_REMAP_LINE(ws, bits, div) \
241static 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
266DEFINE_REMAP_LINE(2, 8, 1)
267DEFINE_REMAP_LINE(4, 8, 1)
268DEFINE_REMAP_LINE(2, 16, 2)
269DEFINE_REMAP_LINE(4, 16, 2)
270
271void 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}
359 289
360/**290/**
361 * Save nearest pixel coordinates for remapping.291 * 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
399 }329 }
400 }330 }
401 331
402 ker[0] = (1.f - du) * (1.f - dv) * 8192;332 ker[0] = (1.f - du) * (1.f - dv) * 16384;
403 ker[1] = du * (1.f - dv) * 8192;333 ker[1] = du * (1.f - dv) * 16384;
404 ker[2] = (1.f - du) * dv * 8192;334 ker[2] = (1.f - du) * dv * 16384;
405 ker[3] = du * dv * 8192;335 ker[3] = du * dv * 16384;
406}336}
407 337
408/**338/**
@@ -446,7 +376,7 @@ static void bicubic_kernel(float du, float dv, const XYRemap *r_tmp, · 37 unmodified lines
446 for (j = 0; j < 4; j++) {376 for (j = 0; j < 4; j++) {
447 u[i * 4 + j] = r_tmp->u[i][j];377 u[i * 4 + j] = r_tmp->u[i][j];
448 v[i * 4 + j] = r_tmp->v[i][j];378 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;
450 }380 }
451 }381 }
452}382}
@@ -501,7 +431,7 @@ static void lanczos_kernel(float du, float dv, const XYRemap *r_tmp, · 48 unmodified lines
501 for (j = 0; j < 4; j++) {431 for (j = 0; j < 4; j++) {
502 u[i * 4 + j] = r_tmp->u[i][j];432 u[i * 4 + j] = r_tmp->u[i][j];
503 v[i * 4 + j] = r_tmp->v[i][j];433 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;
505 }435 }
506 }436 }
507}437}
@@ -2038,6 +1968,8 @@ static int config_output(AVFilterLink *outlink) · 1530 unmodified lines
2038 av_assert0(0);1968 av_assert0(0);
2039 }1969 }
2040 1970
1971 ff_v360_init(s, depth);
1972
2041 switch (s->in) {1973 switch (s->in) {
2042 case EQUIRECTANGULAR:1974 case EQUIRECTANGULAR:
2043 in_transform = xyz_to_equirect;1975 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
31OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold_init.o31OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold_init.o
32OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_tinterlace_init.o32OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_tinterlace_init.o
33OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o33OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o
34OBJS-$(CONFIG_V360_FILTER) += x86/vf_v360_init.o
34OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif_init.o35OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif_init.o
35OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o36OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o
36 37
@@ -66,5 +67,6 @@ X86ASM-OBJS-$(CONFIG_TBLEND_FILTER) += x86/vf_blend.o · 29 unmodified lines
66X86ASM-OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold.o67X86ASM-OBJS-$(CONFIG_THRESHOLD_FILTER) += x86/vf_threshold.o
67X86ASM-OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_interlace.o68X86ASM-OBJS-$(CONFIG_TINTERLACE_FILTER) += x86/vf_interlace.o
68X86ASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o69X86ASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o
70X86ASM-OBJS-$(CONFIG_V360_FILTER) += x86/vf_v360.o
69X86ASM-OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif.o71X86ASM-OBJS-$(CONFIG_W3FDIF_FILTER) += x86/vf_w3fdif.o
70X86ASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif.o x86/yadif-16.o x86/yadif-10.o72X86ASM-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
25SECTION_RODATA
26
27pb_mask: db 0,4,8,12,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
28pd_255: times 4 dd 255
29
30SECTION .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
35INIT_YMM avx2
36cglobal 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
62INIT_YMM avx2
63cglobal 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
95INIT_YMM avx2
96cglobal 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
26void 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
29void 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
32void 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
35av_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