Skip to content

Commit 7e9ba60

Browse files
author
mr.fantastic
committed
clang-format openfx module source files
1 parent abb3048 commit 7e9ba60

22 files changed

Lines changed: 2731 additions & 3008 deletions

src/modules/openfx/factory.c

Lines changed: 190 additions & 195 deletions
Large diffs are not rendered by default.

src/modules/openfx/filter_openfx.c

Lines changed: 169 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1818
*/
1919

20-
#include "ofxImageEffect.h"
2120
#include "mlt_openfx.h"
21+
#include "ofxImageEffect.h"
2222
#include <framework/mlt.h>
2323
#include <string.h>
2424

@@ -33,100 +33,106 @@ static int filter_get_image(mlt_frame frame,
3333
int *height,
3434
int writable)
3535
{
36-
mlt_filter filter = (mlt_filter) mlt_frame_pop_service(frame);
37-
38-
mlt_properties properties = MLT_FILTER_PROPERTIES(filter);
39-
OfxPlugin *plugin = mlt_properties_get_data (properties, "ofx_plugin", NULL);
40-
mlt_properties image_effect = mlt_properties_get_data (properties, "ofx_image_effect", NULL);
41-
mlt_properties params = mlt_properties_get_data (image_effect, "mltofx_params", NULL);
42-
mlt_properties image_effect_params = mlt_properties_get_data (image_effect, "params", NULL);
43-
44-
*format = mlt_image_rgba;
45-
int error = mlt_frame_get_image(frame, image, format, width, height, 1);
46-
47-
if (error == 0)
48-
{
49-
mlt_position position = mlt_filter_get_position(filter, frame);
50-
mlt_position length = mlt_filter_get_length2(filter, frame);
51-
int params_count = mlt_properties_count(params);
52-
53-
int i;
54-
for (i = 0; i < params_count; ++i)
55-
{
56-
char *iprop_name = mlt_properties_get_name(params, i);
57-
58-
char *mlt_value = mlt_properties_get (properties, iprop_name);
59-
60-
if (mlt_value != NULL)
61-
{
62-
mlt_properties param = mlt_properties_get_data_at(params, i, NULL);
63-
64-
char *type = mlt_properties_get (param, "type");
65-
66-
if (type != NULL)
67-
{
68-
if (strcmp (type, "double") == 0)
69-
{
70-
double value = mlt_properties_anim_get_double (properties, iprop_name, position, length);
71-
mltofx_param_set_value (image_effect_params, iprop_name, mltofx_prop_double, value);
72-
}
73-
else if (strcmp (type, "integer") == 0)
74-
{
75-
int value = mlt_properties_anim_get_int (properties, iprop_name, position, length);
76-
mltofx_param_set_value (image_effect_params, iprop_name, mltofx_prop_int, value);
77-
}
78-
else if (strcmp (type, "string") == 0)
79-
{
80-
char *value = mlt_properties_anim_get (properties, iprop_name, position, length);
81-
mltofx_param_set_value (image_effect_params, iprop_name, mltofx_prop_string, value);
82-
}
83-
else if (strcmp (type, "boolean") == 0)
84-
{
85-
int value = mlt_properties_anim_get_int (properties, iprop_name, position, length);
86-
mltofx_param_set_value (image_effect_params, iprop_name, mltofx_prop_int, value);
87-
}
88-
}
89-
}
90-
}
91-
92-
mltofx_begin_sequence_render (plugin, image_effect);
93-
94-
mltofx_get_regions_of_interest (plugin, image_effect, (double) *width, (double) *height);
95-
mltofx_get_clip_preferences (plugin, image_effect);
96-
97-
uint8_t *src_copy = malloc(*width * *height * 4);
98-
if (src_copy == NULL)
99-
goto out;
100-
memcpy (src_copy, *image, *width * *height * 4);
101-
mltofx_set_source_clip_data (plugin, image_effect, src_copy, *width, *height);
102-
mltofx_set_output_clip_data (plugin, image_effect, *image, *width, *height);
103-
104-
mltofx_action_render (plugin, image_effect, *width, *height);
105-
106-
free (src_copy);
107-
108-
mltofx_end_sequence_render (plugin, image_effect);
36+
mlt_filter filter = (mlt_filter) mlt_frame_pop_service(frame);
37+
38+
mlt_properties properties = MLT_FILTER_PROPERTIES(filter);
39+
OfxPlugin *plugin = mlt_properties_get_data(properties, "ofx_plugin", NULL);
40+
mlt_properties image_effect = mlt_properties_get_data(properties, "ofx_image_effect", NULL);
41+
mlt_properties params = mlt_properties_get_data(image_effect, "mltofx_params", NULL);
42+
mlt_properties image_effect_params = mlt_properties_get_data(image_effect, "params", NULL);
43+
44+
*format = mlt_image_rgba;
45+
int error = mlt_frame_get_image(frame, image, format, width, height, 1);
46+
47+
if (error == 0) {
48+
mlt_position position = mlt_filter_get_position(filter, frame);
49+
mlt_position length = mlt_filter_get_length2(filter, frame);
50+
int params_count = mlt_properties_count(params);
51+
52+
int i;
53+
for (i = 0; i < params_count; ++i) {
54+
char *iprop_name = mlt_properties_get_name(params, i);
55+
56+
char *mlt_value = mlt_properties_get(properties, iprop_name);
57+
58+
if (mlt_value != NULL) {
59+
mlt_properties param = mlt_properties_get_data_at(params, i, NULL);
60+
61+
char *type = mlt_properties_get(param, "type");
62+
63+
if (type != NULL) {
64+
if (strcmp(type, "double") == 0) {
65+
double value = mlt_properties_anim_get_double(properties,
66+
iprop_name,
67+
position,
68+
length);
69+
mltofx_param_set_value(image_effect_params,
70+
iprop_name,
71+
mltofx_prop_double,
72+
value);
73+
} else if (strcmp(type, "integer") == 0) {
74+
int value
75+
= mlt_properties_anim_get_int(properties, iprop_name, position, length);
76+
mltofx_param_set_value(image_effect_params,
77+
iprop_name,
78+
mltofx_prop_int,
79+
value);
80+
} else if (strcmp(type, "string") == 0) {
81+
char *value
82+
= mlt_properties_anim_get(properties, iprop_name, position, length);
83+
mltofx_param_set_value(image_effect_params,
84+
iprop_name,
85+
mltofx_prop_string,
86+
value);
87+
} else if (strcmp(type, "boolean") == 0) {
88+
int value
89+
= mlt_properties_anim_get_int(properties, iprop_name, position, length);
90+
mltofx_param_set_value(image_effect_params,
91+
iprop_name,
92+
mltofx_prop_int,
93+
value);
94+
}
95+
}
96+
}
97+
}
98+
99+
mltofx_begin_sequence_render(plugin, image_effect);
100+
101+
mltofx_get_regions_of_interest(plugin, image_effect, (double) *width, (double) *height);
102+
mltofx_get_clip_preferences(plugin, image_effect);
103+
104+
uint8_t *src_copy = malloc(*width * *height * 4);
105+
if (src_copy == NULL)
106+
goto out;
107+
memcpy(src_copy, *image, *width * *height * 4);
108+
mltofx_set_source_clip_data(plugin, image_effect, src_copy, *width, *height);
109+
mltofx_set_output_clip_data(plugin, image_effect, *image, *width, *height);
110+
111+
mltofx_action_render(plugin, image_effect, *width, *height);
112+
113+
free(src_copy);
114+
115+
mltofx_end_sequence_render(plugin, image_effect);
109116
}
110-
out:
111-
return error;
117+
out:
118+
return error;
112119
}
113120

114-
115121
static mlt_frame filter_process(mlt_filter filter, mlt_frame frame)
116122
{
117-
mlt_frame_push_service(frame, filter);
118-
mlt_frame_push_get_image(frame, filter_get_image);
119-
return frame;
123+
mlt_frame_push_service(frame, filter);
124+
mlt_frame_push_get_image(frame, filter_get_image);
125+
return frame;
120126
}
121127

122128
static void filter_close(mlt_filter filter)
123129
{
124-
mlt_properties properties = MLT_FILTER_PROPERTIES(filter);
130+
mlt_properties properties = MLT_FILTER_PROPERTIES(filter);
125131

126-
OfxPlugin *plugin = mlt_properties_get_data (properties, "ofx_plugin", NULL);
127-
mlt_properties image_effect = mlt_properties_get_data (properties, "ofx_image_effect", NULL);
132+
OfxPlugin *plugin = mlt_properties_get_data(properties, "ofx_plugin", NULL);
133+
mlt_properties image_effect = mlt_properties_get_data(properties, "ofx_image_effect", NULL);
128134

129-
mltofx_destroy_instance (plugin, image_effect);
135+
mltofx_destroy_instance(plugin, image_effect);
130136
}
131137

132138
mlt_filter filter_openfx_init(mlt_profile profile, mlt_service_type type, const char *id, char *arg)
@@ -135,9 +141,9 @@ mlt_filter filter_openfx_init(mlt_profile profile, mlt_service_type type, const
135141
if (this != NULL) {
136142
mlt_properties properties = MLT_FILTER_PROPERTIES(this);
137143
this->process = filter_process;
138-
this->close = filter_close;
144+
this->close = filter_close;
139145

140-
/*
146+
/*
141147
WIP
142148
resource, _pluginid are properties set to the filter properties
143149
also the parameters are set in the filter properties so I need
@@ -149,82 +155,83 @@ mlt_filter filter_openfx_init(mlt_profile profile, mlt_service_type type, const
149155
*/
150156

151157
mlt_properties_set(properties, "resource", arg);
152-
if (!strncmp(id, "openfx.", 7))
153-
{
154-
mlt_properties_set(properties, "_pluginid", id + 7);
155-
156-
mlt_properties pb = (mlt_properties) mlt_properties_get_data(mltofx_context, id, NULL);
157-
158-
char *dli = mlt_properties_get (pb, "dli");
159-
int index = mlt_properties_get_int (pb, "index");
160-
161-
dli[0] = 'g';
162-
163-
OfxPlugin *(*GetPluginFn) (int nth) = mlt_properties_get_data(mltofx_dl, dli, NULL);
164-
165-
if (GetPluginFn != NULL)
166-
{
167-
OfxPlugin *pt = GetPluginFn (index);
168-
if (pt == NULL)
169-
return NULL;
170-
171-
mlt_properties params = mlt_properties_new();
172-
mlt_properties image_effect = mltofx_fetch_params (pt, params);
173-
174-
mltofx_create_instance (pt, image_effect);
175-
176-
mlt_properties begin_sequence_props = mlt_properties_new ();
177-
mlt_properties end_sequence_props = mlt_properties_new ();
178-
mlt_properties_set_data (image_effect,
179-
"begin_sequence_props",
180-
begin_sequence_props,
181-
0,
182-
(mlt_destructor) mlt_properties_close,
183-
NULL);
184-
mlt_properties_set_data (image_effect,
185-
"end_sequence_props",
186-
end_sequence_props,
187-
0,
188-
(mlt_destructor) mlt_properties_close,
189-
NULL);
190-
191-
192-
mlt_properties get_roi_in_args = mlt_properties_new ();
193-
mlt_properties get_roi_out_args = mlt_properties_new ();
194-
mlt_properties_set_data (image_effect,
195-
"get_roi_in_args",
196-
get_roi_in_args,
197-
0,
198-
(mlt_destructor) mlt_properties_close,
199-
NULL);
200-
mlt_properties_set_data (image_effect,
201-
"get_roi_out_args",
202-
get_roi_out_args,
203-
0,
204-
(mlt_destructor) mlt_properties_close,
205-
NULL);
206-
207-
mlt_properties get_clippref_args = mlt_properties_new ();
208-
mlt_properties_set_data (image_effect,
209-
"get_clippref_args",
210-
get_clippref_args,
211-
0,
212-
(mlt_destructor) mlt_properties_close,
213-
NULL);
214-
215-
mlt_properties render_in_args = mlt_properties_new ();
216-
mlt_properties_set_data (image_effect,
217-
"render_in_args",
218-
render_in_args,
219-
0,
220-
(mlt_destructor) mlt_properties_close,
221-
NULL);
222-
223-
mlt_properties_set_data (properties, "ofx_plugin", pt, 0, NULL, NULL);
224-
mlt_properties_set_data (properties, "ofx_image_effect", image_effect, 0, (mlt_destructor) mlt_properties_close, NULL);
225-
}
226-
227-
}
158+
if (!strncmp(id, "openfx.", 7)) {
159+
mlt_properties_set(properties, "_pluginid", id + 7);
160+
161+
mlt_properties pb = (mlt_properties) mlt_properties_get_data(mltofx_context, id, NULL);
162+
163+
char *dli = mlt_properties_get(pb, "dli");
164+
int index = mlt_properties_get_int(pb, "index");
165+
166+
dli[0] = 'g';
167+
168+
OfxPlugin *(*GetPluginFn)(int nth) = mlt_properties_get_data(mltofx_dl, dli, NULL);
169+
170+
if (GetPluginFn != NULL) {
171+
OfxPlugin *pt = GetPluginFn(index);
172+
if (pt == NULL)
173+
return NULL;
174+
175+
mlt_properties params = mlt_properties_new();
176+
mlt_properties image_effect = mltofx_fetch_params(pt, params);
177+
178+
mltofx_create_instance(pt, image_effect);
179+
180+
mlt_properties begin_sequence_props = mlt_properties_new();
181+
mlt_properties end_sequence_props = mlt_properties_new();
182+
mlt_properties_set_data(image_effect,
183+
"begin_sequence_props",
184+
begin_sequence_props,
185+
0,
186+
(mlt_destructor) mlt_properties_close,
187+
NULL);
188+
mlt_properties_set_data(image_effect,
189+
"end_sequence_props",
190+
end_sequence_props,
191+
0,
192+
(mlt_destructor) mlt_properties_close,
193+
NULL);
194+
195+
mlt_properties get_roi_in_args = mlt_properties_new();
196+
mlt_properties get_roi_out_args = mlt_properties_new();
197+
mlt_properties_set_data(image_effect,
198+
"get_roi_in_args",
199+
get_roi_in_args,
200+
0,
201+
(mlt_destructor) mlt_properties_close,
202+
NULL);
203+
mlt_properties_set_data(image_effect,
204+
"get_roi_out_args",
205+
get_roi_out_args,
206+
0,
207+
(mlt_destructor) mlt_properties_close,
208+
NULL);
209+
210+
mlt_properties get_clippref_args = mlt_properties_new();
211+
mlt_properties_set_data(image_effect,
212+
"get_clippref_args",
213+
get_clippref_args,
214+
0,
215+
(mlt_destructor) mlt_properties_close,
216+
NULL);
217+
218+
mlt_properties render_in_args = mlt_properties_new();
219+
mlt_properties_set_data(image_effect,
220+
"render_in_args",
221+
render_in_args,
222+
0,
223+
(mlt_destructor) mlt_properties_close,
224+
NULL);
225+
226+
mlt_properties_set_data(properties, "ofx_plugin", pt, 0, NULL, NULL);
227+
mlt_properties_set_data(properties,
228+
"ofx_image_effect",
229+
image_effect,
230+
0,
231+
(mlt_destructor) mlt_properties_close,
232+
NULL);
233+
}
234+
}
228235
}
229236
return this;
230237
}

0 commit comments

Comments
 (0)