3 * Original MPlayer filters by Richard Felker.
5 * This file is part of FFmpeg.
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.
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.
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.
22 #include "libavutil/attributes.h"
23 #include "libavutil/cpu.h"
24 #include "libavutil/mem.h"
25 #include "libavutil/x86/cpu.h"
26 #include "libavutil/x86/asm.h"
27 #include "libavfilter/vf_eq.h"
29 extern void ff_process_one_line_mmxext(const uint8_t *src, uint8_t *dst, short contrast,
30 short brightness, int w);
31 extern void ff_process_one_line_sse2(const uint8_t *src, uint8_t *dst, short contrast,
32 short brightness, int w);
35 static void process_mmxext(EQParameters *param, uint8_t *dst, int dst_stride,
36 const uint8_t *src, int src_stride, int w, int h)
38 short contrast = (short) (param->contrast * 256 * 16);
39 short brightness = ((short) (100.0 * param->brightness + 100.0) * 511)
40 / 200 - 128 - contrast / 32;
43 ff_process_one_line_mmxext(src, dst, contrast, brightness, w);
50 static void process_sse2(EQParameters *param, uint8_t *dst, int dst_stride,
51 const uint8_t *src, int src_stride, int w, int h)
53 short contrast = (short) (param->contrast * 256 * 16);
54 short brightness = ((short) (100.0 * param->brightness + 100.0) * 511)
55 / 200 - 128 - contrast / 32;
58 ff_process_one_line_sse2(src, dst, contrast, brightness, w);
65 av_cold void ff_eq_init_x86(EQContext *eq)
68 int cpu_flags = av_get_cpu_flags();
69 if (EXTERNAL_MMXEXT(cpu_flags)) {
70 eq->process = process_mmxext;
72 if (EXTERNAL_SSE2(cpu_flags)) {
73 eq->process = process_sse2;