FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_blend_init.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Paul B Mahol
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/attributes.h"
22 #include "libavutil/cpu.h"
23 #include "libavutil/x86/cpu.h"
24 #include "libavfilter/blend.h"
25 
26 #define BLEND_FUNC(name, opt) \
27 void ff_blend_##name##_##opt(const uint8_t *top, ptrdiff_t top_linesize, \
28  const uint8_t *bottom, ptrdiff_t bottom_linesize, \
29  uint8_t *dst, ptrdiff_t dst_linesize, \
30  ptrdiff_t width, ptrdiff_t height, \
31  struct FilterParams *param, double *values, int starty);
32 
33 BLEND_FUNC(addition, sse2)
34 BLEND_FUNC(grainmerge, sse2)
35 BLEND_FUNC(average, sse2)
36 BLEND_FUNC(and, sse2)
37 BLEND_FUNC(darken, sse2)
38 BLEND_FUNC(grainextract, sse2)
39 BLEND_FUNC(multiply, sse2)
40 BLEND_FUNC(screen, sse2)
41 BLEND_FUNC(hardmix, sse2)
42 BLEND_FUNC(divide, sse2)
43 BLEND_FUNC(lighten, sse2)
44 BLEND_FUNC(or, sse2)
45 BLEND_FUNC(phoenix, sse2)
46 BLEND_FUNC(subtract, sse2)
47 BLEND_FUNC(xor, sse2)
48 BLEND_FUNC(difference, sse2)
49 BLEND_FUNC(difference, ssse3)
50 BLEND_FUNC(extremity, sse2)
51 BLEND_FUNC(extremity, ssse3)
52 BLEND_FUNC(negation, sse2)
53 BLEND_FUNC(negation, ssse3)
54 
55 av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit)
56 {
58 
59  if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1 && !is_16bit) {
60  switch (param->mode) {
61  case BLEND_ADDITION: param->blend = ff_blend_addition_sse2; break;
62  case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_sse2; break;
63  case BLEND_AND: param->blend = ff_blend_and_sse2; break;
64  case BLEND_AVERAGE: param->blend = ff_blend_average_sse2; break;
65  case BLEND_DARKEN: param->blend = ff_blend_darken_sse2; break;
66  case BLEND_GRAINEXTRACT: param->blend = ff_blend_grainextract_sse2; break;
67  case BLEND_DIVIDE: param->blend = ff_blend_divide_sse2; break;
68  case BLEND_HARDMIX: param->blend = ff_blend_hardmix_sse2; break;
69  case BLEND_LIGHTEN: param->blend = ff_blend_lighten_sse2; break;
70  case BLEND_MULTIPLY: param->blend = ff_blend_multiply_sse2; break;
71  case BLEND_OR: param->blend = ff_blend_or_sse2; break;
72  case BLEND_PHOENIX: param->blend = ff_blend_phoenix_sse2; break;
73  case BLEND_SCREEN: param->blend = ff_blend_screen_sse2; break;
74  case BLEND_SUBTRACT: param->blend = ff_blend_subtract_sse2; break;
75  case BLEND_XOR: param->blend = ff_blend_xor_sse2; break;
76  case BLEND_DIFFERENCE: param->blend = ff_blend_difference_sse2; break;
77  case BLEND_EXTREMITY: param->blend = ff_blend_extremity_sse2; break;
78  case BLEND_NEGATION: param->blend = ff_blend_negation_sse2; break;
79  }
80  }
81  if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1 && !is_16bit) {
82  switch (param->mode) {
83  case BLEND_DIFFERENCE: param->blend = ff_blend_difference_ssse3; break;
84  case BLEND_EXTREMITY: param->blend = ff_blend_extremity_ssse3; break;
85  case BLEND_NEGATION: param->blend = ff_blend_negation_ssse3; break;
86  }
87  }
88 }
av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit)
Definition: vf_blend_init.c:55
static atomic_int cpu_flags
Definition: cpu.c:50
Macro definitions for various function/variable attributes.
#define av_cold
Definition: attributes.h:82
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:59
static SoftFloat_IEEE754 multiply(SoftFloat_IEEE754 a, SoftFloat_IEEE754 b)
multiply two softfloats and handle the rounding off
Definition: alsdec.c:1371
filter data
Definition: mlp.h:74
#define EXTERNAL_SSSE3(flags)
Definition: cpu.h:65
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:92
Definition: blend.h:44
#define BLEND_FUNC(name, opt)
Definition: vf_blend_init.c:26