Debian Codegraph @

src/filter/invert0r/invert0r.c

raw symbols SCIP
1 #include <stdlib.h>
2 #include <assert.h>
3
4 #include "frei0r.h"
5
6 typedef struct inverter_instance
7 {
8 unsigned int width;
9 unsigned int height;
10 } inverter_instance_t;
11
12 int f0r_init()
13 {
14 return 1;
15 }
16
17 void f0r_deinit()
18 { /* no initialization required */ }
19
20 void f0r_get_plugin_info(f0r_plugin_info_t* inverterInfo)
21 {
22 inverterInfo->name = "Invert0r";
23 inverterInfo->author = "Gephex crew";
24 inverterInfo->plugin_type = F0R_PLUGIN_TYPE_FILTER;
25 inverterInfo->color_model = F0R_COLOR_MODEL_RGBA8888;
26 inverterInfo->frei0r_version = FREI0R_MAJOR_VERSION;
27 inverterInfo->major_version = 0;
28 inverterInfo->minor_version = 9;
29 inverterInfo->num_params = 0;
30 inverterInfo->explanation = "Inverts all colors of a source image";
31 }
32
33 void f0r_get_param_info(f0r_param_info_t* info, int param_index)
34 {
35 /* no params */
36 }
37
38 f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
39 {
40 inverter_instance_t* inst = (inverter_instance_t*)calloc(1, sizeof(*inst));
41 inst->width = width; inst->height = height;
42 return (f0r_instance_t)inst;
43 }
44
45 void f0r_destruct(f0r_instance_t instance)
46 {
47 free(instance);
48 }
49
50 void f0r_set_param_value(f0r_instance_t instance,
51 f0r_param_t param, int param_index)
52 { /* no params */ }
53
54 void f0r_get_param_value(f0r_instance_t instance,
55 f0r_param_t param, int param_index)
56 { /* no params */ }
57
58 void f0r_update(f0r_instance_t instance, double time,
59 const uint32_t* inframe, uint32_t* outframe)
60 {
61 assert(instance);
62 inverter_instance_t* inst = (inverter_instance_t*)instance;
63 unsigned int w = inst->width;
64 unsigned int h = inst->height;
65 unsigned int x,y;
66
67 uint32_t* dst = outframe;
68 const uint32_t* src = inframe;
69 for(y=0;y<h;++y)
70 for(x=0;x<w;++x,++src)
71 *dst++ = 0x00ffffff^(*src);
72 }
73