FFmpeg
vf_eq_init.c
Go to the documentation of this file.
1 /*
2  *
3  * Original MPlayer filters by Richard Felker.
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #include "libavutil/attributes.h"
23 #include "libavutil/cpu.h"
24 #include "libavutil/x86/cpu.h"
25 #include "libavutil/x86/asm.h"
26 #include "libavfilter/vf_eq.h"
27 
28 extern void ff_process_one_line_mmxext(const uint8_t *src, uint8_t *dst, short contrast,
29  short brightness, int w);
30 extern void ff_process_one_line_sse2(const uint8_t *src, uint8_t *dst, short contrast,
31  short brightness, int w);
32 
33 #if HAVE_X86ASM
34 static void process_mmxext(EQParameters *param, uint8_t *dst, int dst_stride,
35  const uint8_t *src, int src_stride, int w, int h)
36 {
37  short contrast = (short) (param->contrast * 256 * 16);
38  short brightness = ((short) (100.0 * param->brightness + 100.0) * 511)
39  / 200 - 128 - contrast / 32;
40 
41  while (h--) {
42  ff_process_one_line_mmxext(src, dst, contrast, brightness, w);
43  src += src_stride;
44  dst += dst_stride;
45  }
46  emms_c();
47 }
48 
49 static void process_sse2(EQParameters *param, uint8_t *dst, int dst_stride,
50  const uint8_t *src, int src_stride, int w, int h)
51 {
52  short contrast = (short) (param->contrast * 256 * 16);
53  short brightness = ((short) (100.0 * param->brightness + 100.0) * 511)
54  / 200 - 128 - contrast / 32;
55 
56  while (h--) {
57  ff_process_one_line_sse2(src, dst, contrast, brightness, w);
58  src += src_stride;
59  dst += dst_stride;
60  }
61 }
62 #endif
63 
65 {
66 #if HAVE_X86ASM
69  eq->process = process_mmxext;
70  }
71  if (EXTERNAL_SSE2(cpu_flags)) {
72  eq->process = process_sse2;
73  }
74 #endif
75 }
ff_process_one_line_mmxext
void ff_process_one_line_mmxext(const uint8_t *src, uint8_t *dst, short contrast, short brightness, int w)
cpu.h
ff_process_one_line_sse2
void ff_process_one_line_sse2(const uint8_t *src, uint8_t *dst, short contrast, short brightness, int w)
w
uint8_t w
Definition: llviddspenc.c:38
ff_eq_init_x86
av_cold void ff_eq_init_x86(EQContext *eq)
Definition: vf_eq_init.c:64
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:98
cpu_flags
static atomic_int cpu_flags
Definition: cpu.c:50
eq
#define eq(A, B)
Definition: vf_xbr.c:90
av_cold
#define av_cold
Definition: attributes.h:90
EQParameters
Definition: vf_eq.h:47
vf_eq.h
src
#define src
Definition: vp8dsp.c:255
cpu.h
asm.h
EQContext
Definition: vf_eq.h:58
EQParameters::contrast
double contrast
Definition: vf_eq.h:53
attributes.h
EXTERNAL_SSE2
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:59
EQParameters::brightness
double brightness
Definition: vf_eq.h:53
h
h
Definition: vp9dsp_template.c:2038
short
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are short
Definition: writing_filters.txt:89
EXTERNAL_MMXEXT
#define EXTERNAL_MMXEXT(flags)
Definition: cpu.h:57