[FFmpeg-devel] [PATCH] avfilter/vf_blend: add x86 SIMD for some modes

Paul B Mahol onemda at gmail.com
Fri Oct 2 18:59:00 CEST 2015


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavfilter/blend.h             |  70 ++++++++++
 libavfilter/vf_blend.c          | 100 +++++----------
 libavfilter/x86/Makefile        |   4 +
 libavfilter/x86/vf_blend.asm    | 278 ++++++++++++++++++++++++++++++++++++++++
 libavfilter/x86/vf_blend_init.c |  97 ++++++++++++++
 5 files changed, 478 insertions(+), 71 deletions(-)
 create mode 100644 libavfilter/blend.h
 create mode 100644 libavfilter/x86/vf_blend.asm
 create mode 100644 libavfilter/x86/vf_blend_init.c

diff --git a/libavfilter/blend.h b/libavfilter/blend.h
new file mode 100644
index 0000000..c22ecd2
--- /dev/null
+++ b/libavfilter/blend.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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/eval.h"
+#include "avfilter.h"
+
+enum BlendMode {
+    BLEND_UNSET = -1,
+    BLEND_NORMAL,
+    BLEND_ADDITION,
+    BLEND_AND,
+    BLEND_AVERAGE,
+    BLEND_BURN,
+    BLEND_DARKEN,
+    BLEND_DIFFERENCE,
+    BLEND_DIFFERENCE128,
+    BLEND_DIVIDE,
+    BLEND_DODGE,
+    BLEND_EXCLUSION,
+    BLEND_HARDLIGHT,
+    BLEND_LIGHTEN,
+    BLEND_MULTIPLY,
+    BLEND_NEGATION,
+    BLEND_OR,
+    BLEND_OVERLAY,
+    BLEND_PHOENIX,
+    BLEND_PINLIGHT,
+    BLEND_REFLECT,
+    BLEND_SCREEN,
+    BLEND_SOFTLIGHT,
+    BLEND_SUBTRACT,
+    BLEND_VIVIDLIGHT,
+    BLEND_XOR,
+    BLEND_HARDMIX,
+    BLEND_LINEARLIGHT,
+    BLEND_GLOW,
+    BLEND_ADDITION128,
+    BLEND_NB
+};
+
+typedef struct FilterParams {
+    enum BlendMode mode;
+    double opacity;
+    AVExpr *e;
+    char *expr_str;
+    void (*blend)(const uint8_t *top, ptrdiff_t top_linesize,
+                  const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                  uint8_t *dst, ptrdiff_t dst_linesize,
+                  int width, int start, int end,
+                  struct FilterParams *param, double *values);
+} FilterParams;
+
+void ff_blend_init_x86(FilterParams *param, int is_16bit);
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index f6a649b..b19eb6b 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -28,69 +28,12 @@
 #include "internal.h"
 #include "dualinput.h"
 #include "video.h"
+#include "blend.h"
 
 #define TOP    0
 #define BOTTOM 1
 
-enum BlendMode {
-    BLEND_UNSET = -1,
-    BLEND_NORMAL,
-    BLEND_ADDITION,
-    BLEND_AND,
-    BLEND_AVERAGE,
-    BLEND_BURN,
-    BLEND_DARKEN,
-    BLEND_DIFFERENCE,
-    BLEND_DIFFERENCE128,
-    BLEND_DIVIDE,
-    BLEND_DODGE,
-    BLEND_EXCLUSION,
-    BLEND_HARDLIGHT,
-    BLEND_LIGHTEN,
-    BLEND_MULTIPLY,
-    BLEND_NEGATION,
-    BLEND_OR,
-    BLEND_OVERLAY,
-    BLEND_PHOENIX,
-    BLEND_PINLIGHT,
-    BLEND_REFLECT,
-    BLEND_SCREEN,
-    BLEND_SOFTLIGHT,
-    BLEND_SUBTRACT,
-    BLEND_VIVIDLIGHT,
-    BLEND_XOR,
-    BLEND_HARDMIX,
-    BLEND_LINEARLIGHT,
-    BLEND_GLOW,
-    BLEND_ADDITION128,
-    BLEND_NB
-};
-
-static const char *const var_names[] = {   "X",   "Y",   "W",   "H",   "SW",   "SH",   "T",   "N",   "A",   "B",   "TOP",   "BOTTOM",        NULL };
-enum                                   { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_SW, VAR_SH, VAR_T, VAR_N, VAR_A, VAR_B, VAR_TOP, VAR_BOTTOM, VAR_VARS_NB };
-
-typedef struct FilterParams {
-    enum BlendMode mode;
-    double opacity;
-    AVExpr *e;
-    char *expr_str;
-    void (*blend)(const uint8_t *top, int top_linesize,
-                  const uint8_t *bottom, int bottom_linesize,
-                  uint8_t *dst, int dst_linesize,
-                  int width, int start, int end,
-                  struct FilterParams *param, double *values);
-} FilterParams;
-
-typedef struct ThreadData {
-    const AVFrame *top, *bottom;
-    AVFrame *dst;
-    AVFilterLink *inlink;
-    int plane;
-    int w, h;
-    FilterParams *param;
-} ThreadData;
-
-typedef struct {
+typedef struct BlendContext {
     const AVClass *class;
     FFDualInputContext dinput;
     int hsub, vsub;             ///< chroma subsampling values
@@ -104,6 +47,18 @@ typedef struct {
     AVFrame *prev_frame;        /* only used with tblend */
 } BlendContext;
 
+static const char *const var_names[] = {   "X",   "Y",   "W",   "H",   "SW",   "SH",   "T",   "N",   "A",   "B",   "TOP",   "BOTTOM",        NULL };
+enum                                   { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_SW, VAR_SH, VAR_T, VAR_N, VAR_A, VAR_B, VAR_TOP, VAR_BOTTOM, VAR_VARS_NB };
+
+typedef struct ThreadData {
+    const AVFrame *top, *bottom;
+    AVFrame *dst;
+    AVFilterLink *inlink;
+    int plane;
+    int w, h;
+    FilterParams *param;
+} ThreadData;
+
 #define COMMON_OPTIONS \
     { "c0_mode", "set component #0 blend mode", OFFSET(params[0].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode"},\
     { "c1_mode", "set component #1 blend mode", OFFSET(params[1].mode), AV_OPT_TYPE_INT, {.i64=0}, 0, BLEND_NB-1, FLAGS, "mode"},\
@@ -162,9 +117,9 @@ static const AVOption blend_options[] = {
 
 AVFILTER_DEFINE_CLASS(blend);
 
-static void blend_normal(const uint8_t *top, int top_linesize,
-                         const uint8_t *bottom, int bottom_linesize,
-                         uint8_t *dst, int dst_linesize,
+static void blend_normal(const uint8_t *top, ptrdiff_t top_linesize,
+                         const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                         uint8_t *dst, ptrdiff_t dst_linesize,
                          int width, int start, int end,
                          FilterParams *param, double *values)
 {
@@ -172,9 +127,9 @@ static void blend_normal(const uint8_t *top, int top_linesize,
 }
 
 #define DEFINE_BLEND8(name, expr)                                              \
-static void blend_## name##_8bit(const uint8_t *top, int top_linesize,         \
-                                 const uint8_t *bottom, int bottom_linesize,   \
-                                 uint8_t *dst, int dst_linesize,               \
+static void blend_## name##_8bit(const uint8_t *top, ptrdiff_t top_linesize,         \
+                                 const uint8_t *bottom, ptrdiff_t bottom_linesize,   \
+                                 uint8_t *dst, ptrdiff_t dst_linesize,               \
                                  int width, int start, int end,                \
                                  FilterParams *param, double *values)          \
 {                                                                              \
@@ -192,9 +147,9 @@ static void blend_## name##_8bit(const uint8_t *top, int top_linesize,         \
 }
 
 #define DEFINE_BLEND16(name, expr)                                             \
-static void blend_## name##_16bit(const uint8_t *_top, int top_linesize,       \
-                                  const uint8_t *_bottom, int bottom_linesize, \
-                                  uint8_t *_dst, int dst_linesize,             \
+static void blend_## name##_16bit(const uint8_t *_top, ptrdiff_t top_linesize,       \
+                                  const uint8_t *_bottom, ptrdiff_t bottom_linesize, \
+                                  uint8_t *_dst, ptrdiff_t dst_linesize,             \
                                   int width, int start, int end,               \
                                   FilterParams *param, double *values)         \
 {                                                                              \
@@ -294,9 +249,9 @@ DEFINE_BLEND16(vividlight, (A < 32768) ? BURN(2 * A, B) : DODGE(2 * (A - 32768),
 DEFINE_BLEND16(linearlight,av_clip_uint16((B < 32768) ? B + 2 * A - 65535 : B + 2 * (A - 32768)))
 
 #define DEFINE_BLEND_EXPR(type, name, div)                                     \
-static void blend_expr_## name(const uint8_t *_top, int top_linesize,          \
-                               const uint8_t *_bottom, int bottom_linesize,    \
-                               uint8_t *_dst, int dst_linesize,                \
+static void blend_expr_## name(const uint8_t *_top, ptrdiff_t top_linesize,          \
+                               const uint8_t *_bottom, ptrdiff_t bottom_linesize,    \
+                               uint8_t *_dst, ptrdiff_t dst_linesize,                \
                                int width, int start, int end,                  \
                                FilterParams *param, double *values)            \
 {                                                                              \
@@ -515,6 +470,9 @@ static int config_output(AVFilterLink *outlink)
         case BLEND_XOR:        param->blend = is_16bit ? blend_xor_16bit        : blend_xor_8bit;        break;
         }
 
+        if (ARCH_X86)
+            ff_blend_init_x86(param, is_16bit);
+
         if (s->all_expr && !param->expr_str) {
             param->expr_str = av_strdup(s->all_expr);
             if (!param->expr_str)
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index db072cd..57b413f 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -1,3 +1,4 @@
+OBJS-$(CONFIG_BLEND_FILTER)                  += x86/vf_blend_init.o
 OBJS-$(CONFIG_EQ_FILTER)                     += x86/vf_eq.o
 OBJS-$(CONFIG_FSPP_FILTER)                   += x86/vf_fspp_init.o
 OBJS-$(CONFIG_GRADFUN_FILTER)                += x86/vf_gradfun_init.o
@@ -12,10 +13,12 @@ OBJS-$(CONFIG_PULLUP_FILTER)                 += x86/vf_pullup_init.o
 OBJS-$(CONFIG_REMOVEGRAIN_FILTER)            += x86/vf_removegrain_init.o
 OBJS-$(CONFIG_SPP_FILTER)                    += x86/vf_spp.o
 OBJS-$(CONFIG_SSIM_FILTER)                   += x86/vf_ssim_init.o
+OBJS-$(CONFIG_TBLEND_FILTER)                 += x86/vf_blend_init.o
 OBJS-$(CONFIG_TINTERLACE_FILTER)             += x86/vf_tinterlace_init.o
 OBJS-$(CONFIG_VOLUME_FILTER)                 += x86/af_volume_init.o
 OBJS-$(CONFIG_YADIF_FILTER)                  += x86/vf_yadif_init.o
 
+YASM-OBJS-$(CONFIG_BLEND_FILTER)             += x86/vf_blend.o
 YASM-OBJS-$(CONFIG_FSPP_FILTER)              += x86/vf_fspp.o
 YASM-OBJS-$(CONFIG_GRADFUN_FILTER)           += x86/vf_gradfun.o
 YASM-OBJS-$(CONFIG_HQDN3D_FILTER)            += x86/vf_hqdn3d.o
@@ -29,6 +32,7 @@ ifdef CONFIG_GPL
 YASM-OBJS-$(CONFIG_REMOVEGRAIN_FILTER)       += x86/vf_removegrain.o
 endif
 YASM-OBJS-$(CONFIG_SSIM_FILTER)              += x86/vf_ssim.o
+YASM-OBJS-$(CONFIG_TBLEND_FILTER)            += x86/vf_blend.o
 YASM-OBJS-$(CONFIG_TINTERLACE_FILTER)        += x86/vf_interlace.o
 YASM-OBJS-$(CONFIG_VOLUME_FILTER)            += x86/af_volume.o
 YASM-OBJS-$(CONFIG_YADIF_FILTER)             += x86/vf_yadif.o x86/yadif-16.o x86/yadif-10.o
diff --git a/libavfilter/x86/vf_blend.asm b/libavfilter/x86/vf_blend.asm
new file mode 100644
index 0000000..6cc6a84
--- /dev/null
+++ b/libavfilter/x86/vf_blend.asm
@@ -0,0 +1,278 @@
+;*****************************************************************************
+;* x86-optimized functions for blend filter
+;*
+;* Copyright (C) 2015 Paul B Mahol
+;*
+;* This file is part of FFmpeg.
+;*
+;* FFmpeg is free software; you can redistribute it and/or
+;* modify it under the terms of the GNU Lesser General Public
+;* License as published by the Free Software Foundation; either
+;* version 2.1 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
+;* Lesser General Public License for more details.
+;*
+;* You should have received a copy of the GNU Lesser 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/x86/x86util.asm"
+
+%if ARCH_X86_64
+SECTION_RODATA
+
+pw_128: times 8 dw 128
+
+SECTION .text
+
+INIT_XMM sse2
+cglobal blend_xor, 9, 10, 2, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movu            m0, [topq + x]
+        movu            m1, [bottomq + x]
+        pxor            m0, m1
+        mova    [dstq + x], m0
+        add           r10q, mmsize
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_or, 9, 10, 2, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movu            m0, [topq + x]
+        movu            m1, [bottomq + x]
+        por             m0, m1
+        mova    [dstq + x], m0
+        add           r10q, mmsize
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_and, 9, 10, 2, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movu            m0, [topq + x]
+        movu            m1, [bottomq + x]
+        pand            m0, m1
+        mova    [dstq + x], m0
+        add           r10q, mmsize
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_addition, 9, 10, 3, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    pxor       m2, m2
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movh            m0, [topq + x]
+        movh            m1, [bottomq + x]
+        punpcklbw       m0, m2
+        punpcklbw       m1, m2
+        paddw           m0, m1
+        packuswb        m0, m0
+        movh    [dstq + x], m0
+        add           r10q, mmsize / 2
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_subtract, 9, 10, 3, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    pxor       m2, m2
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movh            m0, [topq + x]
+        movh            m1, [bottomq + x]
+        punpcklbw       m0, m2
+        punpcklbw       m1, m2
+        psubw           m0, m1
+        packuswb        m0, m0
+        movh    [dstq + x], m0
+        add           r10q, mmsize / 2
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_difference128, 9, 10, 4, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    pxor       m2, m2
+    mova       m3, [pw_128]
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movh            m0, [topq + x]
+        movh            m1, [bottomq + x]
+        punpcklbw       m0, m2
+        punpcklbw       m1, m2
+        paddw           m0, m3
+        psubw           m0, m1
+        packuswb        m0, m0
+        movh    [dstq + x], m0
+        add           r10q, mmsize / 2
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_addition128, 9, 10, 4, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    pxor       m2, m2
+    mova       m3, [pw_128]
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movh            m0, [topq + x]
+        movh            m1, [bottomq + x]
+        punpcklbw       m0, m2
+        punpcklbw       m1, m2
+        paddw           m0, m1
+        psubw           m0, m3
+        packuswb        m0, m0
+        movh    [dstq + x], m0
+        add           r10q, mmsize / 2
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_darken, 9, 10, 2, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movh            m0, [topq + x]
+        movh            m1, [bottomq + x]
+        pminub          m0, m1
+        movh    [dstq + x], m0
+        add           r10q, mmsize / 2
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+cglobal blend_lighten, 9, 10, 2, 0, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, start, end
+    add      topq, widthq
+    add   bottomq, widthq
+    add      dstq, widthq
+    sub      endq, startq
+    neg    widthq
+.nextrow:
+    mov       r10q, widthq
+    %define      x  r10q
+
+    .loop:
+        movh            m0, [topq + x]
+        movh            m1, [bottomq + x]
+        pmaxub          m0, m1
+        movh    [dstq + x], m0
+        add           r10q, mmsize / 2
+    jl .loop
+
+    add          topq, top_linesizeq
+    add       bottomq, bottom_linesizeq
+    add          dstq, dst_linesizeq
+    sub          endd, 1
+    jg .nextrow
+REP_RET
+
+%endif
diff --git a/libavfilter/x86/vf_blend_init.c b/libavfilter/x86/vf_blend_init.c
new file mode 100644
index 0000000..0beb6b4
--- /dev/null
+++ b/libavfilter/x86/vf_blend_init.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2015 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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/x86/cpu.h"
+#include "libavfilter/blend.h"
+
+void ff_blend_addition_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                            const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                            uint8_t *dst, ptrdiff_t dst_linesize,
+                            int width, int start, int end,
+                            struct FilterParams *param, double *values);
+
+void ff_blend_addition128_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                               const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                               uint8_t *dst, ptrdiff_t dst_linesize,
+                               int width, int start, int end,
+                               struct FilterParams *param, double *values);
+
+void ff_blend_and_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                       const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                       uint8_t *dst, ptrdiff_t dst_linesize,
+                       int width, int start, int end,
+                       struct FilterParams *param, double *values);
+
+void ff_blend_darken_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                          const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                          uint8_t *dst, ptrdiff_t dst_linesize,
+                          int width, int start, int end,
+                          struct FilterParams *param, double *values);
+
+void ff_blend_difference128_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                                 const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                                 uint8_t *dst, ptrdiff_t dst_linesize,
+                                 int width, int start, int end,
+                                 struct FilterParams *param, double *values);
+
+void ff_blend_lighten_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                           const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                           uint8_t *dst, ptrdiff_t dst_linesize,
+                           int width, int start, int end,
+                           struct FilterParams *param, double *values);
+
+void ff_blend_or_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                      const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                      uint8_t *dst, ptrdiff_t dst_linesize,
+                      int width, int start, int end,
+                      struct FilterParams *param, double *values);
+
+void ff_blend_subtract_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                            const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                            uint8_t *dst, ptrdiff_t dst_linesize,
+                            int width, int start, int end,
+                            struct FilterParams *param, double *values);
+
+void ff_blend_xor_sse2(const uint8_t *top, ptrdiff_t top_linesize,
+                       const uint8_t *bottom, ptrdiff_t bottom_linesize,
+                       uint8_t *dst, ptrdiff_t dst_linesize,
+                       int width, int start, int end,
+                       struct FilterParams *param, double *values);
+
+av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit)
+{
+    int cpu_flags = av_get_cpu_flags();
+
+    if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags) && param->opacity == 1 && !is_16bit) {
+        switch (param->mode) {
+        case BLEND_ADDITION: param->blend = ff_blend_addition_sse2; break;
+        case BLEND_ADDITION128: param->blend = ff_blend_addition128_sse2; break;
+        case BLEND_AND:      param->blend = ff_blend_and_sse2;      break;
+        case BLEND_DARKEN:   param->blend = ff_blend_darken_sse2;   break;
+        case BLEND_DIFFERENCE128: param->blend = ff_blend_difference128_sse2; break;
+        case BLEND_LIGHTEN:  param->blend = ff_blend_lighten_sse2;  break;
+        case BLEND_OR:       param->blend = ff_blend_or_sse2;       break;
+        case BLEND_SUBTRACT: param->blend = ff_blend_subtract_sse2; break;
+        case BLEND_XOR:      param->blend = ff_blend_xor_sse2;      break;
+        }
+    }
+}
-- 
1.9.1



More information about the ffmpeg-devel mailing list