FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/x86/vf_lut3d_init.c
Date: 2026-09-15 15:24:09
Exec Total Coverage
Lines: 0 27 0.0%
Functions: 0 7 0.0%
Branches: 0 74 0.0%

Line Branch Exec Source
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
21 #include "libavutil/attributes.h"
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) \
28 void ff_interp_##name##_##format##_##opt(LUT3DContext *lut3d, Lut3DPreLut *prelut, AVFrame *src, AVFrame *dst, int slice_start, int slice_end, int has_alpha); \
29 static 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
45 DEFINE_INTERP_FUNC(tetrahedral, pf32, avx2)
46 DEFINE_INTERP_FUNC(tetrahedral, p16, avx2)
47 #endif
48 #if HAVE_AVX_EXTERNAL
49 DEFINE_INTERP_FUNC(tetrahedral, pf32, avx)
50 DEFINE_INTERP_FUNC(tetrahedral, p16, avx)
51 #endif
52 #if HAVE_SSE2_EXTERNAL
53 DEFINE_INTERP_FUNC(tetrahedral, pf32, sse2)
54 DEFINE_INTERP_FUNC(tetrahedral, p16, sse2)
55 #endif
56 #endif
57
58
59 av_cold void ff_lut3d_init_x86(LUT3DContext *s, const AVPixFmtDescriptor *desc)
60 {
61 int cpu_flags = av_get_cpu_flags();
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 }
94