FFmpeg
Loading...
Searching...
No Matches
vf_lut3d_init.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Mark Reid <mindmark@gmail.com>
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
22#include "libavutil/cpu.h"
23#include "libavutil/x86/cpu.h"
24#include "libavfilter/filters.h"
25#include "libavfilter/lut3d.h"
26
27#define DEFINE_INTERP_FUNC(name, format, opt) \
28void ff_interp_##name##_##format##_##opt(LUT3DContext *lut3d, Lut3DPreLut *prelut, AVFrame *src, AVFrame *dst, int slice_start, int slice_end, int has_alpha); \
29static int interp_##name##_##format##_##opt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
30{ \
31 LUT3DContext *lut3d = ctx->priv; \
32 Lut3DPreLut *prelut = lut3d->prelut.size > 0? &lut3d->prelut: NULL; \
33 ThreadData *td = arg; \
34 AVFrame *in = td->in; \
35 AVFrame *out = td->out; \
36 int has_alpha = in->linesize[3] && out != in; \
37 int slice_start = ff_slice_pos(in->height, jobnr, nb_jobs); \
38 int slice_end = ff_slice_pos(in->height, jobnr + 1, nb_jobs); \
39 ff_interp_##name##_##format##_##opt(lut3d, prelut, in, out, slice_start, slice_end, has_alpha); \
40 return 0; \
41}
42
43#if ARCH_X86_64
44#if HAVE_AVX2_EXTERNAL
47#endif
48#if HAVE_AVX_EXTERNAL
51#endif
52#if HAVE_SSE2_EXTERNAL
55#endif
56#endif
57
58
60{
62 int planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR;
63 int isfloat = desc->flags & AV_PIX_FMT_FLAG_FLOAT;
64 int depth = desc->comp[0].depth;
65
66#if ARCH_X86_64
67 if (EXTERNAL_AVX2_FAST(cpu_flags) && EXTERNAL_FMA3(cpu_flags) && s->interpolation == INTERPOLATE_TETRAHEDRAL && planar) {
68#if HAVE_AVX2_EXTERNAL
69 if (isfloat && planar) {
70 s->interp = interp_tetrahedral_pf32_avx2;
71 } else if (depth == 16) {
72 s->interp = interp_tetrahedral_p16_avx2;
73 }
74#endif
75 } else if (EXTERNAL_AVX_FAST(cpu_flags) && s->interpolation == INTERPOLATE_TETRAHEDRAL && planar) {
76#if HAVE_AVX_EXTERNAL
77 if (isfloat) {
78 s->interp = interp_tetrahedral_pf32_avx;
79 } else if (depth == 16) {
80 s->interp = interp_tetrahedral_p16_avx;
81 }
82#endif
83 } else if (EXTERNAL_SSE2(cpu_flags) && s->interpolation == INTERPOLATE_TETRAHEDRAL && planar) {
84#if HAVE_SSE2_EXTERNAL
85 if (isfloat) {
86 s->interp = interp_tetrahedral_pf32_sse2;
87 } else if (depth == 16) {
88 s->interp = interp_tetrahedral_p16_sse2;
89 }
90#endif
91 }
92#endif
93}
#define s(width, name)
Definition cbs_vp9.c:198
@ INTERPOLATE_TETRAHEDRAL
Definition lut3d.h:33
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define EXTERNAL_AVX2_FAST(flags)
Definition cpu.h:73
#define EXTERNAL_FMA3(flags)
Definition cpu.h:68
#define EXTERNAL_AVX_FAST(flags)
Definition cpu.h:65
#define EXTERNAL_SSE2(flags)
Definition cpu.h:53
const char * desc
Definition libsvtav1.c:83
static av_always_inline v3u16_t tetrahedral(const SwsLut3D *lut3d, int Rx, int Gx, int Bx, int Rf, int Gf, int Bf)
Definition lut3d.c:69
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition pixdesc.h:158
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition pixdesc.h:132
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
#define DEFINE_INTERP_FUNC(name, format, opt)
av_cold void ff_lut3d_init_x86(LUT3DContext *s, const AVPixFmtDescriptor *desc)