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);
32 
33 BLEND_FUNC(addition, sse2)
34 BLEND_FUNC(addition128, sse2)
35 BLEND_FUNC(average, sse2)
36 BLEND_FUNC(and, sse2)
37 BLEND_FUNC(darken, sse2)
38 BLEND_FUNC(difference128, sse2)
39 BLEND_FUNC(multiply, sse2)
40 BLEND_FUNC(screen, sse2)
41 BLEND_FUNC(hardmix, sse2)
42 BLEND_FUNC(lighten, sse2)
43 BLEND_FUNC(or, sse2)
44 BLEND_FUNC(phoenix, sse2)
45 BLEND_FUNC(subtract, sse2)
46 BLEND_FUNC(xor, sse2)
47 BLEND_FUNC(difference, sse2)
48 BLEND_FUNC(difference, ssse3)
49 BLEND_FUNC(negation, sse2)
50 BLEND_FUNC(negation, ssse3)
51 
52 av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit)
53 {
54  int cpu_flags = av_get_cpu_flags();
55 
56  if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1 && !is_16bit) {
57  switch (param->mode) {
58  case BLEND_ADDITION: param->blend = ff_blend_addition_sse2; break;
59  case BLEND_ADDITION128: param->blend = ff_blend_addition128_sse2; break;
60  case BLEND_AND: param->blend = ff_blend_and_sse2; break;
61  case BLEND_AVERAGE: param->blend = ff_blend_average_sse2; break;
62  case BLEND_DARKEN: param->blend = ff_blend_darken_sse2; break;
63  case BLEND_DIFFERENCE128: param->blend = ff_blend_difference128_sse2; break;
64  case BLEND_HARDMIX: param->blend = ff_blend_hardmix_sse2; break;
65  case BLEND_LIGHTEN: param->blend = ff_blend_lighten_sse2; break;
66  case BLEND_MULTIPLY: param->blend = ff_blend_multiply_sse2; break;
67  case BLEND_OR: param->blend = ff_blend_or_sse2; break;
68  case BLEND_PHOENIX: param->blend = ff_blend_phoenix_sse2; break;
69  case BLEND_SCREEN: param->blend = ff_blend_screen_sse2; break;
70  case BLEND_SUBTRACT: param->blend = ff_blend_subtract_sse2; break;
71  case BLEND_XOR: param->blend = ff_blend_xor_sse2; break;
72  case BLEND_DIFFERENCE: param->blend = ff_blend_difference_sse2; break;
73  case BLEND_NEGATION: param->blend = ff_blend_negation_sse2; break;
74  }
75  }
76  if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1 && !is_16bit) {
77  switch (param->mode) {
78  case BLEND_DIFFERENCE: param->blend = ff_blend_difference_ssse3; break;
79  case BLEND_NEGATION: param->blend = ff_blend_negation_ssse3; break;
80  }
81  }
82 }
av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit)
Definition: vf_blend_init.c:52
Macro definitions for various function/variable attributes.
#define av_cold
Definition: attributes.h:82
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:57
static SDL_Surface * screen
Definition: ffplay.c:365
filter data
Definition: mlp.h:74
#define EXTERNAL_SSSE3(flags)
Definition: cpu.h:63
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:76
Definition: blend.h:44
#define BLEND_FUNC(name, opt)
Definition: vf_blend_init.c:26