Debian Codegraph @

src/filter/spillsupress/spillsupress.c

raw symbols SCIP
1 /*
2 * spillsupress.c
3 * Copyright 2012 Janne Liljeblad
4 *
5 * This file is a Frei0r plugin.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include <stdlib.h>
23 #include <assert.h>
24 #include <string.h>
25
26 #include "frei0r.h"cxx . . $ `<file>/include/frei0r.h`/
27
28 void green_limited_by_bluecxx . . $ green_limited_by_blue(6e3baf38f1776cd6).(unsigned int len, const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe)
29 {
30
31 unsigned char* dst = (unsigned char*)outframe;
32 const unsigned char* src = (unsigned char*)inframe;
33 unsigned char b = 0;
34 unsigned char g = 0;
35
36 while (len--)
37 {
38 *dst++ = *src++;
39 g = *src++;
40 dst++;
41 b = *src++;
42 dst++;
43 *dst++ = *src++;
44
45 if( g > b )
46 {
47 *(dst - 3) = b;
48 *(dst - 2) = b;
49 }
50 else
51 {
52 *(dst - 3) = g;
53 *(dst - 2) = b;
54 }
55
56 }
57 }
58
59 void blue_limited_by_greencxx . . $ blue_limited_by_green(6e3baf38f1776cd6).(unsigned int len, const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe)
60 {
61
62 unsigned char* dst = (unsigned char*)outframe;
63 const unsigned char* src = (unsigned char*)inframe;
64 unsigned char b = 0;
65 unsigned char g = 0;
66
67 while (len--)
68 {
69 *dst++ = *src++;
70 g = *src++;
71 dst++;
72 b = *src++;
73 dst++;
74 *dst++ = *src++;
75
76 if( b > g )
77 {
78 *(dst - 3) = g;
79 *(dst - 2) = g;
80 }
81 else
82 {
83 *(dst - 3) = g;
84 *(dst - 2) = b;
85 }
86
87 }
88 }
89
90 typedef struct spillsupress_instancecxx . . $ spillsupress_instance#
91 {
92 unsigned int widthcxx . . $ spillsupress_instance#width.;
93 unsigned int heightcxx . . $ spillsupress_instance#height.;
94 double supress_typecxx . . $ spillsupress_instance#supress_type.; /* type of spill suppression applied to image
95 <= 0.5, green suppress
96 > 0.5, blue suppress */
97 } spillsupress_instance_tcxx . . $ spillsupress_instance_t#;
98
99 int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).()
100 {
101 return 1;
102 }
103
104 void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).()
105 { /* no initialization required */ }
106
107 void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* spillsupress_info)
108 {
109 spillsupress_info->namecxx . . $ f0r_plugin_info#name. = "spillsupress";
110 spillsupress_info->authorcxx . . $ f0r_plugin_info#author. = "Janne Liljeblad";
111 spillsupress_info->plugin_typecxx . . $ f0r_plugin_info#plugin_type. = F0R_PLUGIN_TYPE_FILTERcxx . . $ `include/frei0r.h:247:9`!;
112 spillsupress_info->color_modelcxx . . $ f0r_plugin_info#color_model. = F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!;
113 spillsupress_info->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version. = FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!;
114 spillsupress_info->major_versioncxx . . $ f0r_plugin_info#major_version. = 0;
115 spillsupress_info->minor_versioncxx . . $ f0r_plugin_info#minor_version. = 1;
116 spillsupress_info->num_paramscxx . . $ f0r_plugin_info#num_params. = 1;
117 spillsupress_info->explanationcxx . . $ f0r_plugin_info#explanation. = "Remove green or blue spill light from subjects shot in front of green or blue screen";
118 }
119
120 void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index)
121 {
122 switch(param_index)
123 {
124 case 0:
125 info->namecxx . . $ f0r_param_info#name. = "supresstype";
126 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
127 info->explanationcxx . . $ f0r_param_info#explanation. = "Defines if green or blue screen spill suppress is applied";
128 break;
129 }
130 }
131
132 f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height)
133 {
134 spillsupress_instance_tcxx . . $ spillsupress_instance_t#* inst = (spillsupress_instance_tcxx . . $ spillsupress_instance_t#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*inst));
135 inst->widthcxx . . $ spillsupress_instance#width. = width;
136 inst->heightcxx . . $ spillsupress_instance#height. = height;
137 inst->supress_typecxx . . $ spillsupress_instance#supress_type. = 0.0; // default suppress type is green suppress
138 return (f0r_instance_tcxx . . $ f0r_instance_t#)inst;
139 }
140
141 void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance)
142 {
143 freecxx . . $ free(5d22bdacc48458e8).(instance);
144 }
145
146 void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
147 f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
148 {
149 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance);
150 spillsupress_instance_tcxx . . $ spillsupress_instance_t#* inst = (spillsupress_instance_tcxx . . $ spillsupress_instance_t#*)instance;
151
152 switch(param_index)
153 {
154 case 0:
155 inst->supress_typecxx . . $ spillsupress_instance#supress_type. = *((double*)param);
156 break;
157 }
158 }
159
160 void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
161 f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
162 {
163 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance);
164 spillsupress_instance_tcxx . . $ spillsupress_instance_t#* inst = (spillsupress_instance_tcxx . . $ spillsupress_instance_t#*)instance;
165
166 switch(param_index)
167 {
168 case 0:
169 *((double*)param) = inst->supress_typecxx . . $ spillsupress_instance#supress_type.;
170 break;
171 }
172 }
173
174 void f0r_updatecxx . . $ f0r_update(96cd7b27f2fca8a7).(f0r_instance_tcxx . . $ f0r_instance_t# instance, double time,
175 const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe)
176 {
177 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance);
178 spillsupress_instance_tcxx . . $ spillsupress_instance_t#* inst = (spillsupress_instance_tcxx . . $ spillsupress_instance_t#*)instance;
179 unsigned int len = inst->widthcxx . . $ spillsupress_instance#width. * inst->heightcxx . . $ spillsupress_instance#height.;
180
181 if (inst->supress_typecxx . . $ spillsupress_instance#supress_type. > 0.5)
182 {
183 blue_limited_by_greencxx . . $ blue_limited_by_green(6e3baf38f1776cd6).(len, inframe, outframe);
184 }
185 else
186 {
187 green_limited_by_bluecxx . . $ green_limited_by_blue(6e3baf38f1776cd6).(len, inframe, outframe);
188 }
189 }
190