Debian Codegraph @

include/frei0r.h

raw symbols SCIP
1 /** @mainpage frei0r - a minimalistic plugin API for video effects
2 *
3 * @section sec_intro Introduction
4 *
5 * This is frei0r - a minimalistic plugin API for video effects.
6 *
7 * The main emphasis is on simplicity - there are many different applications
8 * that use video effects, and they all have different requirements regarding
9 * their internal plugin API. And that's why frei0r does not try to be a
10 * one-in-all general video plugin API, but instead an API for the most
11 * common video effects: simple filters, sources and mixers that can be
12 * controlled by parameters.
13 *
14 * It's our hope that this way these simple effects can be shared between
15 * many applications, avoiding their reimplementation by different
16 * projects.
17 *
18 * On the other hand, this is not meant as a competing standard to
19 * more ambitious efforts that try to satisfy the needs of many different
20 * applications and more complex effects.
21 *
22 *
23 * @section sec_overview Overview
24 *
25 * If you are new to frei0r, the best thing is probably to have
26 * a look at the <a href="frei0r_8h_source.html">frei0r header</a>,
27 * which is quite simple.
28 *
29 * After that, you might want to look at the
30 * <a href="frei0r_8h.html">frei0r functions</a> in more detail.
31 *
32 * When developing a new frei0r effect, you have to choose
33 * - which effect type to use (\ref PLUGIN_TYPE),
34 * - which color model to use (\ref COLOR_MODEL), and
35 * - which parameter types (\ref PARAM_TYPE) your effect will support.
36 *
37 * To round things up, you should decide whether your effect should have
38 * an associated icon (\ref icons), and where it will be installed
39 * (\ref pluglocations).
40 *
41 * @section sec_changes Changes
42 *
43 * @subsection sec_changes_1_1_1_2 From frei0r 1.1 to frei0r 1.2
44 * - make \<vendor\> in plugin path optional
45 * - added section on FREI0R_PATH environment variable
46 * - added requirement to initialize all parameters in f0r_construct()
47 *
48 * @subsection sec_changes_1_0_1_1 From frei0r 1.0 to frei0r 1.1
49 *
50 * - added specifications for plugin locations
51 * - added specifications for frei0r icons
52 * - added RGBA8888 color model
53 * - added packed32 color model
54 * - added better specification of color models
55 * - added string type
56 * - added bounds to resolution (8 <= width, height <= 2048)
57 * - width and height must be an integer multiple of 8
58 * - frame data must be 16 byte aligned
59 * - improved update specification (must not change parameters,
60 * must restore fpu state)
61 * - added note for applications to ignore effects with unknown fields
62 * - added new plugin types mixer2 and mixer3
63 * - added section about \ref concurrency
64 */
65
66
67 /**
68 * \addtogroup pluglocations Plugin Locations
69 * @section sec_pluglocations Plugin Locations
70 *
71 * For Unix platforms there are rules for the location of frei0r plugins.
72 *
73 * frei0r 1.x plugin files should be located in
74 *
75 * - (1) /usr/lib/frei0r-1/\<vendor\>
76 * - (2) /usr/local/lib/frei0r-1/\<vendor\>
77 * - (3) $HOME/.frei0r-1/lib/\<vendor\>
78 *
79 * Examples:
80 *
81 * - /usr/lib/frei0r-1/mob/flippo.so
82 * - /usr/lib/frei0r-1/drone/flippo.so
83 * - /usr/local/lib/frei0r-1/gephex/coma/invert0r.so
84 * - /home/martin/.frei0r-1/lib/martin/test.so
85 *
86 * Like in these examples plugins should be placed in \<vendor\> subdirs
87 * to reduce name clashes. However, \<vendor\> is optional and may be left blank.
88 *
89 * @subsection sec_order Plugin Loading Order
90 *
91 * The application shall load plugins in the following order: 3, 2, 1.
92 * If a name clash occurs (two or more frei0r plugins with identical
93 * effect name), the plugins in directory 3 have precedence over plugins
94 * in directory 2, and those in directory 2 have precedence over plugins
95 * in directory 1.
96 *
97 * This makes it possible for users to "override" effects that are
98 * installed in system wide directories by placing plugins in their
99 * home directory.
100 *
101 * The order of loading plugins inside each of the directories
102 * 1, 2, and 3 is not defined.
103 *
104 * @subsection sec_path FREI0R_PATH Environment Variable
105 *
106 * If the environment variable FREI0R_PATH is defined, then it shall be
107 * considered a colon separated list of directories which replaces the
108 * default list.
109 *
110 * For example:
111 *
112 * FREI0R_PATH=/home/foo/frei0r-plugins:/usr/lib/frei0r-1:/etc/frei0r
113 *
114 * On Windows platforms a semicolon ';' must be used instead of colon
115 * ':' to separate FREI0R_PATH entries (due to the way filenames are
116 * interpreted), hence a cross-platform host application should detect
117 * the platform running and adjust the parsed char accordingly, for
118 * example:
119 *
120 * FREI0R_PATH="C:\Program Files\frei0r-1;%%PROGRAMFILES%\frei0r-1"
121 *
122 */
123
124 /**
125 *\addtogroup icons Icons for frei0r effects
126 * @section sec_icons Icons for frei0r effects
127 *
128 * Each frei0r effect can have an associated icon.
129 *
130 * @subsection sec_icon_format Icon Format
131 *
132 * The format of frei0r icons must be png.
133 * Recommended resolution is 64x64.
134 * The icon filename of an effect with effect name "frei0r"
135 * must be "frei0r.png".
136 *
137 * @subsection sec_icon_location Icon location
138 *
139 * The exact location where the application should look for the
140 * plugin is platform dependent.
141 *
142 * For Windows platforms, the icon should be at the same place as
143 * the plugin containing the effect.
144 *
145 * For Unix platforms, the following mapping from plugin location
146 * to icon location must be used:
147 *
148 * Let \<plugin_path\>/\<plugin\> be a frei0r plugin with name \<effect_name\>.
149 * Then the corresponding icon (if any) shall be located in
150 * \<icon_path\>/\<effect_name\>.png.
151 * \<icon_path\> can be obtained in the following way:
152 *
153 * @verbatim
154 <plugin_path> | <icon_path>
155 ----------------------------------------------------------------------------
156 $HOME/.frei0r-1/lib/<vendor> | $HOME/.frei0r-1/icons/<vendor>
157 /usr/local/lib/frei0r-1/<vendor> | /usr/local/share/frei0r-1/icons/<vendor>
158 /usr/lib/frei0r-1/<vendor> | /usr/share/frei0r-1/icons/<vendor>
159 * | <plugin_path>
160 @endverbatim
161 *
162 * (The wildcard '*' stands for any other plugin_path)
163 *
164 * For other platforms, no location is defined. We recommend to use the
165 * plugin path where possible.
166 */
167
168 /**
169 * \addtogroup concurrency Concurrency
170 * @section sec_concurrency Concurrency
171 *
172 * - \ref f0r_init
173 * - \ref f0r_deinit
174 *
175 * These methods must not be called more than once. It is obvious that no
176 * concurrent calls are allowed.
177 *
178 *
179 * - \ref f0r_get_plugin_info
180 * - \ref f0r_get_param_info
181 * - \ref f0r_construct
182 * - \ref f0r_destruct
183 *
184 * Concurrent calls of these functions are allowed.
185 *
186 *
187 * - \ref f0r_set_param_value
188 * - \ref f0r_get_param_value
189 * - \ref f0r_update
190 * - \ref f0r_update2
191 *
192 * If a thread is in one of these methods its allowed for another thread to
193 * enter one of these methods for a different effect instance. But for one
194 * effect instance only one thread is allowed to execute any of these methods.
195 */
196
197
198
199 /** \file
200 * \brief This file defines the frei0r api, version 1.2.
201 *
202 * A conforming plugin must implement and export all functions declared in
203 * this header.
204 *
205 * A conforming application must accept only those plugins which use
206 * allowed values for the described fields.
207 */
208
209 #ifndef INCLUDED_FREI0R_H
210 #define INCLUDED_FREI0R_Hcxx . . $ `include/frei0r.h:210:9`!
211
212 #include <inttypes.h>
213
214 /**
215 * The frei0r API major version
216 */
217 #define FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`! 1
218
219 /**
220 * The frei0r API minor version
221 */
222 #define FREI0R_MINOR_VERSIONcxx . . $ `include/frei0r.h:222:9`! 2
223
224 //---------------------------------------------------------------------------
225
226 /**
227 * f0r_init() is called once when the plugin is loaded by the application.
228 * \see f0r_deinit
229 */
230 int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).(void);
231
232 /**
233 * f0r_deinit is called once when the plugin is unloaded by the application.
234 * \see f0r_init
235 */
236 void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).(void);
237
238 //---------------------------------------------------------------------------
239
240 /** \addtogroup PLUGIN_TYPE Type of the Plugin
241 * These defines determine whether the plugin is a
242 * source, a filter or one of the two mixer types
243 * @{
244 */
245
246 /** one input and one output */
247 #define F0R_PLUGIN_TYPE_FILTERcxx . . $ `include/frei0r.h:247:9`! 0
248 /** just one output */
249 #define F0R_PLUGIN_TYPE_SOURCEcxx . . $ `include/frei0r.h:249:9`! 1
250 /** two inputs and one output */
251 #define F0R_PLUGIN_TYPE_MIXER2cxx . . $ `include/frei0r.h:251:9`! 2
252 /** three inputs and one output */
253 #define F0R_PLUGIN_TYPE_MIXER3cxx . . $ `include/frei0r.h:253:9`! 3
254
255 /** @} */
256
257 //---------------------------------------------------------------------------
258
259 /** \addtogroup COLOR_MODEL Color Models
260 * List of supported color models.
261 *
262 * Note: the color models are endian independent, because the
263 * color components are defined by their position in memory, not
264 * by their significance in an uint32_t value.
265 *
266 * For effects that work on the color components,
267 * RGBA8888 is the recommended color model for frei0r-1.2 effects.
268 * For effects that only work on pixels, PACKED32 is the recommended
269 * color model since it helps the application to avoid unnecessary
270 * color conversions.
271 *
272 * Effects can choose an appropriate color model, applications must support
273 * all color models and do conversions if necessary. Source effects
274 * must not use the PACKED32 color model because the application must know
275 * in which color model the created framebuffers are represented.
276 *
277 * For each color model, a frame consists of width*height pixels which
278 * are stored row-wise and consecutively in memory. The size of a pixel is
279 * 4 bytes. There is no extra pitch parameter
280 * (i.e. the pitch is simply width*4).
281 *
282 * The following additional constraints must be honored:
283 * - The top-most line of a frame is stored first in memory.
284 * - A frame must be aligned to a 16 byte border in memory.
285 * - The width and height of a frame must be positive
286 * - The width and height of a frame must be integer multiples of 8
287 *
288 * These constraints make sure that each line is stored at an address aligned
289 * to 16 byte.
290 */
291 /*@{*/
292 /**
293 * In BGRA8888, each pixel is represented by 4 consecutive
294 * unsigned bytes, where the first byte value represents
295 * the blue, the second the green, and the third the red color
296 * component of the pixel. The last value represents the
297 * alpha value.
298 */
299 #define F0R_COLOR_MODEL_BGRA8888cxx . . $ `include/frei0r.h:299:9`! 0
300
301 /**
302 * In RGBA8888, each pixel is represented by 4 consecutive
303 * unsigned bytes, where the first byte value represents
304 * the red, the second the green, and the third the blue color
305 * component of the pixel. The last value represents the
306 * alpha value.
307 */
308 #define F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`! 1
309
310 /**
311 * In PACKED32, each pixel is represented by 4 consecutive
312 * bytes, but it is not defined how the color components are
313 * stored. The true color format could be RGBA8888,
314 * BGRA8888, a packed 32 bit YUV format, or any other
315 * color format that stores pixels in 32 bit.
316 *
317 * This is useful for effects that don't work on color but
318 * only on pixels (for example a mirror effect).
319 *
320 * Note that source effects must not use this color model.
321 */
322 #define F0R_COLOR_MODEL_PACKED32cxx . . $ `include/frei0r.h:322:9`! 2
323 /*@}*/
324
325 /**
326 * The f0r_plugin_info_t structure is filled in by the plugin
327 * to tell the application about its name, type, number of parameters,
328 * and version.
329 *
330 * An application should ignore (i.e. not use) frei0r effects that
331 * have unknown values in the plugin_type or color_model field.
332 * It should also ignore effects with a too high frei0r_version.
333 *
334 * This is necessary to be able to extend the frei0r spec (e.g.
335 * by adding new color models or plugin types) in a way that does not
336 * result in crashes when loading effects that make use of these
337 * extensions into an older application.
338 *
339 * All strings are unicode, 0-terminated, and the encoding is utf-8.
340 */
341 typedef struct f0r_plugin_infocxx . . $ f0r_plugin_info#
342 {
343 const char* namecxx . . $ f0r_plugin_info#name.; /**< The (short) name of the plugin */
344 const char* authorcxx . . $ f0r_plugin_info#author.; /**< The plugin author */
345 /** The plugin type
346 * \see PLUGIN_TYPE
347 */
348 int plugin_typecxx . . $ f0r_plugin_info#plugin_type.;
349 int color_modelcxx . . $ f0r_plugin_info#color_model.; /**< The color model used */
350 int frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version.; /**< The frei0r major version this plugin is built for*/
351 int major_versioncxx . . $ f0r_plugin_info#major_version.; /**< The major version of the plugin */
352 int minor_versioncxx . . $ f0r_plugin_info#minor_version.; /**< The minor version of the plugin */
353 int num_paramscxx . . $ f0r_plugin_info#num_params.; /**< The number of parameters of the plugin */
354 const char* explanationcxx . . $ f0r_plugin_info#explanation.; /**< An optional explanation string */
355 } f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#;
356
357
358 /**
359 * Is called once after init. The plugin has to fill in the values in info.
360 *
361 * \param info Pointer to an info struct allocated by the application.
362 */
363 void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* info);
364
365 //---------------------------------------------------------------------------
366
367 /** \addtogroup PARAM_TYPE Parameter Types
368 *
369 * @{
370 */
371
372
373 /**
374 * Parameter type for boolean values
375 * \see f0r_param_bool
376 */
377 #define F0R_PARAM_BOOLcxx . . $ `include/frei0r.h:377:9`! 0
378
379 /**
380 * Parameter type for doubles
381 * \see f0r_param_double
382 */
383 #define F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`! 1
384
385 /**
386 * Parameter type for color
387 * \see f0r_param_color
388 */
389 #define F0R_PARAM_COLORcxx . . $ `include/frei0r.h:389:9`! 2
390 /**
391 * Parameter type for position
392 * \see f0r_param_position
393 */
394 #define F0R_PARAM_POSITIONcxx . . $ `include/frei0r.h:394:9`! 3
395
396 /**
397 * Parameter type for string
398 * \see f0r_param_string
399 */
400 #define F0R_PARAM_STRINGcxx . . $ `include/frei0r.h:400:9`! 4
401
402 /**
403 * The boolean type. The allowed range of values is [0, 1].
404 * [0, 0.5[ is mapped to false and [0.5, 1] is mapped to true.
405 */
406 typedef double f0r_param_boolcxx . . $ f0r_param_bool#;
407
408 /**
409 * The double type. The allowed range of values is [0, 1].
410 */
411 typedef double f0r_param_doublecxx . . $ f0r_param_double#;
412
413 /**
414 * The color type. All three color components are in the range [0, 1].
415 */
416 typedef struct f0r_param_colorcxx . . $ f0r_param_color#
417 {
418 float rcxx . . $ f0r_param_color#r.; /**< red color component */
419 float gcxx . . $ f0r_param_color#g.; /**< green color component */
420 float bcxx . . $ f0r_param_color#b.; /**< blue color component */
421 } f0r_param_color_tcxx . . $ f0r_param_color_t#;
422
423 /**
424 * The position type. Both position coordinates are in the range [0, 1].
425 */
426 typedef struct f0r_param_positioncxx . . $ f0r_param_position#
427 {
428 double xcxx . . $ f0r_param_position#x.; /**< x coordinate */
429 double ycxx . . $ f0r_param_position#y.; /**< y coordinate */
430 } f0r_param_position_tcxx . . $ f0r_param_position_t#;
431
432
433 /**
434 * The string type.
435 * Zero terminated array of 8-bit values in utf-8 encoding
436 */
437 typedef char* f0r_param_stringcxx . . $ f0r_param_string#;
438
439 /** @} */
440
441
442 /**
443 * Similar to f0r_plugin_info_t, this structure is filled by the plugin
444 * for every parameter.
445 *
446 * All strings are unicode, 0-terminated, and the encoding is utf-8.
447 */
448 typedef struct f0r_param_infocxx . . $ f0r_param_info#
449 {
450 const char* namecxx . . $ f0r_param_info#name.; /**<The (short) name of the param */
451 int typecxx . . $ f0r_param_info#type.; /**<The type (see the F0R_PARAM_* defines) */
452 const char* explanationcxx . . $ f0r_param_info#explanation.; /**<Optional explanation (can be 0) */
453 } f0r_param_info_tcxx . . $ f0r_param_info_t#;
454
455 /**
456 * f0r_get_param_info is called by the application to query the type of
457 * each parameter.
458 *
459 * \param info is allocated by the application and filled by the plugin
460 * \param param_index the index of the parameter to be queried (from 0 to
461 * num_params-1)
462 */
463 void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index);
464
465 //---------------------------------------------------------------------------
466
467 /**
468 * Transparent instance pointer of the frei0r effect.
469 */
470 typedef void* f0r_instance_tcxx . . $ f0r_instance_t#;
471
472 /**
473 * Constructor for effect instances. The plugin returns a pointer to
474 * its internal instance structure.
475 *
476 * The resolution must be an integer multiple of 8,
477 * must be greater than 0 and be at most 2048 in both dimensions.
478 * The plugin must set default values for all parameters in this function.
479 *
480 * \param width The x-resolution of the processed video frames
481 * \param height The y-resolution of the processed video frames
482 * \returns 0 on failure or a pointer != 0 on success
483 *
484 * \see f0r_destruct
485 */
486 f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height);
487
488 /**
489 * Destroys an effect instance.
490 *
491 * \param instance The pointer to the plugins internal instance structure.
492 *
493 * \see f0r_construct
494 */
495 void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance);
496
497 //---------------------------------------------------------------------------
498
499 /**
500 * Transparent parameter handle.
501 */
502 typedef void* f0r_param_tcxx . . $ f0r_param_t#;
503
504 /**
505 * This function allows the application to set the parameter values of an
506 * effect instance. Validity of the parameter pointer is handled by the
507 * application thus the data must be copied by the effect.
508 *
509 * If the parameter type is of F0R_PARAM_STRING, then the caller should
510 * supply a pointer to f0r_param_string (char**). The plugin must copy
511 * copy the string and not assume it exists beyond the lifetime of the call.
512 * The reason a double pointer is requested when only a single is really
513 * needed is simply for API consistency.
514 *
515 * Furthermore, if an update event/signal is needed in a host
516 * application to notice when parameters have changed, this should be
517 * implemented inside its own update() call. The host application
518 * would presumably need to store the current value as well to see if
519 * it changes; to make this thread safe, it should store a copy of the
520 * current value in a struct which uses instance as a key.
521 *
522 * \param instance the effect instance
523 * \param param pointer to the parameter value
524 * \param param_index index of the parameter
525 *
526 * \see f0r_get_param_value
527 */
528 void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
529 f0r_param_tcxx . . $ f0r_param_t# param, int param_index);
530
531 /**
532 * This function allows the application to query the parameter values of an
533 * effect instance.
534 *
535 * If the parameter type is of F0R_PARAM_STRING, then the caller should
536 * supply a pointer to f0r_param_string (char**). The plugin sets the
537 * pointer to the address of its copy of the parameter value. Therefore,
538 * the caller should not free the result. If the caller needs to modify
539 * the value, it should make a copy of it and modify before calling
540 * f0r_set_param_value().
541 *
542 * \param instance the effect instance
543 * \param param pointer to the parameter value
544 * \param param_index index of the parameter
545 *
546 * \see f0r_set_param_value
547 */
548 void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
549 f0r_param_tcxx . . $ f0r_param_t# param, int param_index);
550
551 //---------------------------------------------------------------------------
552
553 /**
554 * This is where the core effect processing happens. The application calls it
555 * after it has set the necessary parameter values.
556 * inframe and outframe must be aligned to an integer multiple of 16 bytes
557 * in memory.
558 *
559 * This function should not alter the parameters of the effect in any
560 * way (\ref f0r_get_param_value should return the same values after a call
561 * to \ref f0r_update as before the call).
562 *
563 * The function is responsible to restore the fpu state (e.g. rounding mode)
564 * and mmx state if applicable before it returns to the caller.
565 *
566 * The host mustn't call \ref f0r_update for effects of type
567 * \ref F0R_PLUGIN_TYPE_MIXER2 and \ref F0R_PLUGIN_TYPE_MIXER3.
568 *
569 * \param instance the effect instance
570 * \param time the application time in seconds but with subsecond resolution
571 * (e.g. milli-second resolution). The resolution should be at least
572 * the inter-frame period of the application.
573 * \param inframe the incoming video frame (can be zero for sources)
574 * \param outframe the resulting video frame
575 *
576 * \see f0r_update2
577 */
578 void f0r_updatecxx . . $ f0r_update(96cd7b27f2fca8a7).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
579 double time, const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe);
580
581 //---------------------------------------------------------------------------
582
583 /**
584 * For effects of type \ref F0R_PLUGIN_TYPE_SOURCE or
585 * \ref F0R_PLUGIN_TYPE_FILTER this method is optional. The \ref f0r_update
586 * method must still be exported for these two effect types. If both are
587 * provided the behavior of them must be the same.
588 *
589 * Effects of type \ref F0R_PLUGIN_TYPE_MIXER2 or \ref F0R_PLUGIN_TYPE_MIXER3 must provide the new \ref f0r_update2 method.
590
591 * \param instance the effect instance
592 * \param time the application time in seconds but with subsecond resolution
593 * (e.g. milli-second resolution). The resolution should be at least
594 * the inter-frame period of the application.
595 * \param inframe1 the first incoming video frame (can be zero for sources)
596 * \param inframe2 the second incoming video frame
597 (can be zero for sources and filters)
598 * \param inframe3 the third incoming video frame
599 (can be zero for sources, filters and mixer2)
600 * \param outframe the resulting video frame
601 *
602 * \see f0r_update
603 */
604 void f0r_update2cxx . . $ f0r_update2(1b234bc88d3943d5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
605 double time,
606 const uint32_tcxx . . $ uint32_t#* inframe1,
607 const uint32_tcxx . . $ uint32_t#* inframe2,
608 const uint32_tcxx . . $ uint32_t#* inframe3,
609 uint32_tcxx . . $ uint32_t#* outframe);
610 //---------------------------------------------------------------------------
611
612 #endif