summaryrefslogtreecommitdiff
path: root/libavfilter/x86/vf_eq_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavfilter/x86/vf_eq_init.c')
-rw-r--r--libavfilter/x86/vf_eq_init.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/libavfilter/x86/vf_eq_init.c b/libavfilter/x86/vf_eq_init.c
new file mode 100644
index 0000000000..089961ffb2
--- /dev/null
+++ b/libavfilter/x86/vf_eq_init.c
@@ -0,0 +1,54 @@
+/*
+ *
+ * Original MPlayer filters by Richard Felker.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/mem.h"
+#include "libavutil/x86/cpu.h"
+#include "libavutil/x86/asm.h"
+#include "libavfilter/vf_eq.h"
+
+extern void ff_process_one_line_mmxext(const uint8_t *src, uint8_t *dst, short contrast,
+ short brightness, int w);
+
+static void process_mmxext(EQParameters *param, uint8_t *dst, int dst_stride,
+ const uint8_t *src, int src_stride, int w, int h)
+{
+ short contrast = (short) (param->contrast * 256 * 16);
+ short brightness = ((short) (100.0 * param->brightness + 100.0) * 511)
+ / 200 - 128 - contrast / 32;
+
+ while (h--) {
+ ff_process_one_line_mmxext(src, dst, contrast, brightness, w);
+ src += src_stride;
+ dst += dst_stride;
+ }
+ emms_c();
+}
+
+av_cold void ff_eq_init_x86(EQContext *eq)
+{
+ int cpu_flags = av_get_cpu_flags();
+
+ if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
+ eq->process = process_mmxext;
+ }
+}