FFmpeg
vf_gblur_init.c
Go to the documentation of this file.
1 /*
2  *
3  * This file is part of FFmpeg.
4  *
5  * FFmpeg is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * FFmpeg is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with FFmpeg; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #include "config.h"
21 
22 #include "libavutil/attributes.h"
23 #include "libavutil/cpu.h"
24 #include "libavutil/mem.h"
25 #include "libavutil/x86/cpu.h"
26 #include "libavfilter/gblur.h"
27 
28 void ff_horiz_slice_sse4(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf);
29 void ff_horiz_slice_avx2(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf);
30 void ff_horiz_slice_avx512(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf);
31 
32 void ff_postscale_slice_sse(float *ptr, int length, float postscale, float min, float max);
33 void ff_postscale_slice_avx2(float *ptr, int length, float postscale, float min, float max);
34 void ff_postscale_slice_avx512(float *ptr, int length, float postscale, float min, float max);
35 
36 void ff_verti_slice_avx2(float *buffer, int width, int height, int column_begin, int column_end,
37  int steps, float nu, float bscale);
38 void ff_verti_slice_avx512(float *buffer, int width, int height, int column_begin, int column_end,
39  int steps, float nu, float bscale);
40 
42 {
44 
45  if (EXTERNAL_SSE(cpu_flags)) {
46  s->postscale_slice = ff_postscale_slice_sse;
47  }
49  s->postscale_slice = ff_postscale_slice_avx2;
50  }
51 #if ARCH_X86_64
52  if (EXTERNAL_SSE4(cpu_flags)) {
53  s->horiz_slice = ff_horiz_slice_sse4;
54  }
55  if (EXTERNAL_AVX2(cpu_flags)) {
56  s->verti_slice = ff_verti_slice_avx2;
57  }
59  s->postscale_slice = ff_postscale_slice_avx512;
60  s->verti_slice = ff_verti_slice_avx512;
61  }
62  if (EXTERNAL_AVX2(cpu_flags)) {
63  s->stride = EXTERNAL_AVX512(cpu_flags) ? 16 : 8;
64  s->localbuf = av_malloc(s->stride * sizeof(float) * s->planewidth[0] * s->planeheight[0]);
65  if (!s->localbuf)
66  return;
67 
68  s->horiz_slice = ff_horiz_slice_avx2;
70  s->horiz_slice = ff_horiz_slice_avx512;
71  }
72  }
73 #endif
74 }
cpu.h
EXTERNAL_AVX2_FAST
#define EXTERNAL_AVX2_FAST(flags)
Definition: cpu.h:79
ff_postscale_slice_sse
void ff_postscale_slice_sse(float *ptr, int length, float postscale, float min, float max)
ff_horiz_slice_sse4
void ff_horiz_slice_sse4(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf)
max
#define max(a, b)
Definition: cuda_runtime.h:33
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:109
cpu_flags
static atomic_int cpu_flags
Definition: cpu.c:56
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
EXTERNAL_AVX2
#define EXTERNAL_AVX2(flags)
Definition: cpu.h:78
ff_postscale_slice_avx2
void ff_postscale_slice_avx2(float *ptr, int length, float postscale, float min, float max)
ff_gblur_init_x86
av_cold void ff_gblur_init_x86(GBlurContext *s)
Definition: vf_gblur_init.c:41
av_cold
#define av_cold
Definition: attributes.h:90
gblur.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
EXTERNAL_SSE
#define EXTERNAL_SSE(flags)
Definition: cpu.h:58
postscale
static const FLOAT postscale[64]
Definition: faandct.c:55
height
#define height
Definition: dsp.h:85
cpu.h
attributes.h
ff_verti_slice_avx512
void ff_verti_slice_avx512(float *buffer, int width, int height, int column_begin, int column_end, int steps, float nu, float bscale)
ff_postscale_slice_avx512
void ff_postscale_slice_avx512(float *ptr, int length, float postscale, float min, float max)
ff_verti_slice_avx2
void ff_verti_slice_avx2(float *buffer, int width, int height, int column_begin, int column_end, int steps, float nu, float bscale)
EXTERNAL_SSE4
#define EXTERNAL_SSE4(flags)
Definition: cpu.h:68
steps
static const int16_t steps[16]
Definition: misc4.c:30
EXTERNAL_AVX512
#define EXTERNAL_AVX512(flags)
Definition: cpu.h:82
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
ff_horiz_slice_avx2
void ff_horiz_slice_avx2(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf)
mem.h
GBlurContext
Definition: gblur.h:32
width
#define width
Definition: dsp.h:85
ff_horiz_slice_avx512
void ff_horiz_slice_avx512(float *ptr, int width, int height, int steps, float nu, float bscale, float *localbuf)
min
float min
Definition: vorbis_enc_data.h:429