aboutsummaryrefslogtreecommitdiff
path: root/pdp_frei0r
diff options
context:
space:
mode:
Diffstat (limited to 'pdp_frei0r')
-rwxr-xr-xpdp_frei0r/CHANGES.LOG2
-rw-r--r--pdp_frei0r/INSTALL20
-rw-r--r--pdp_frei0r/Makefile14
-rw-r--r--pdp_frei0r/Makefile.config22
-rw-r--r--pdp_frei0r/frei0r.h567
-rw-r--r--pdp_frei0r/help_pdp_frei0r.pd328
-rw-r--r--pdp_frei0r/pdp_frei0r.c637
7 files changed, 1590 insertions, 0 deletions
diff --git a/pdp_frei0r/CHANGES.LOG b/pdp_frei0r/CHANGES.LOG
new file mode 100755
index 0000000..a273448
--- /dev/null
+++ b/pdp_frei0r/CHANGES.LOG
@@ -0,0 +1,2 @@
+0.1
+ initial release
diff --git a/pdp_frei0r/INSTALL b/pdp_frei0r/INSTALL
new file mode 100644
index 0000000..551090b
--- /dev/null
+++ b/pdp_frei0r/INSTALL
@@ -0,0 +1,20 @@
+1. Download Frei0r specs and plugins, here: http://www.piksel.org/frei0r
+
+ darcs get http://darcs.gephex.org/frei0r/frei0r--main--1.1
+ cd to the frei0r-plugins-x.y.z directory
+ compile the plugins::
+ cd to plugins and type 'scons'
+ install the plugins::
+ type 'scons install'
+
+2. Download pdp_frei0r-0.1.tar.gz from http://www.artefacte.org/pd/pdp_frei0r-0.1.tar.gz
+
+ untar the pdp_frei0r-0.1.tar.gz file
+ cd in to the pdp_frei0r-0.1 directory
+
+ edit the Makefile.config file and change the path to the pd (m_pd.h), pdp (pdp.h) sources
+ and frei0r plugin directory (.so) if needed.
+
+ type 'make'
+
+ to load the pdp_frei0r help file type 'pd -nrt -lib pdp:pdp_frei0r help_pdp_frei0r.pd'
diff --git a/pdp_frei0r/Makefile b/pdp_frei0r/Makefile
new file mode 100644
index 0000000..30b81e0
--- /dev/null
+++ b/pdp_frei0r/Makefile
@@ -0,0 +1,14 @@
+current: all
+
+include Makefile.config
+
+PDP_MOD = pdp_frei0r.o
+
+all: $(PDP_MOD)
+ $(CC) -export_dynamic -shared -o pdp_frei0r.pd_linux *.o $(PDP_LIBS)
+
+clean:
+ rm -f *~
+ rm -f *.o
+ rm -f *.pd_linux
+
diff --git a/pdp_frei0r/Makefile.config b/pdp_frei0r/Makefile.config
new file mode 100644
index 0000000..cf89221
--- /dev/null
+++ b/pdp_frei0r/Makefile.config
@@ -0,0 +1,22 @@
+# if configure can't find the m_pd.h header
+# specify pd's include path here and ignore the warning
+#
+FR_PLUGIN_DIR=/usr/local/lib/frei0r-1/
+PD_CPPFLAGS=-I/usr/local/pd/src
+PDP_CFLAGS=-I/usr/local/pd/pdp/include -DPD -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses -Wno-switch -O2 -funroll-loops -fomit-frame-pointer -ffast-math -freg-struct-return -DLINUX
+
+prefix=/usr/local
+PDPF_VERSION = 0.1
+PDPF_TARGET = linux
+PDPF_LIBRARY_NAME = pdp_frei0r.pd_linux
+
+PDP_CPPFLAGS = -I. -I/usr/X11R6/include -I../include -I../../include $(PD_CPPFLAGS)
+
+PDP_CFLAGS += -DPDPF_VERSION=\"$(PDPF_VERSION)\" -DFR_PLUGIN_DIR=\"$(FR_PLUGIN_DIR)\"
+
+CC = gcc
+
+# build rules
+
+.c.o:
+ $(CC) $(PDP_CFLAGS) $(PDP_CPPFLAGS) -o $*.o -c $*.c
diff --git a/pdp_frei0r/frei0r.h b/pdp_frei0r/frei0r.h
new file mode 100644
index 0000000..2e09113
--- /dev/null
+++ b/pdp_frei0r/frei0r.h
@@ -0,0 +1,567 @@
+/** @mainpage frei0r - a minimalistic plugin API for video effects
+ *
+ * @section sec_intro Introduction
+ *
+ * This is frei0r - a minimalistic plugin API for video effects.
+ *
+ * The main emphasis is on simplicity - there are many different applications
+ * that use video effects, and they all have different requirements regarding
+ * their internal plugin API. And that's why frei0r does not try to be a
+ * one-in-all general video plugin API, but instead an API for the most
+ * common video effects: simple filters, sources and mixers that can be
+ * controlled by parameters.
+ *
+ * It's our hope that this way these simple effects can be shared between
+ * many applications, avoiding their reimplementation by different
+ * projects.
+ *
+ * On the other hand, this is not meant as a competing standard to
+ * more ambitious efforts that try to satisfy the needs of many different
+ * applications and more complex effects.
+ *
+ *
+ * @section sec_overview Overview
+ *
+ * If you are new to frei0r, the best thing is probably to have
+ * a look at the <a href="frei0r_8h-source.html">frei0r header</a>,
+ * which is quite simple.
+ *
+ * After that, you might want to look at the
+ * <a href="frei0r_8h.html">frei0r functions</a> in more detail.
+ *
+ * When developing a new frei0r effect, you have to choose
+ * - which effect type to use (\ref PLUGIN_TYPE),
+ * - which color model to use (\ref COLOR_MODEL), and
+ * - which parameter types (\ref PARAM_TYPE) your effect will support.
+ *
+ * To round things up, you should decide whether your effect should have
+ * an associated icon (\ref icons), and where it will be installed
+ * (\ref pluglocations).
+ *
+ * @section sec_changes Changes
+ *
+ * @subsection sec_changes_1_0_1_1 From frei0r 1.0 to frei0r 1.1
+ *
+ * - added specifications for plugin locations
+ * - added specifications for frei0r icons
+ * - added RGBA8888 color model
+ * - added packed32 color model
+ * - added better specification of color models
+ * - added string type
+ * - added bounds to resolution (8 <= width, height <= 2048)
+ * - width and height must be an integer multiple of 8
+ * - frame data must be 16 byte aligned
+ * - improved update specification (must not change parameters,
+ * must restore fpu state)
+ * - added note for applications to ignore effects with unknown fields
+ * - added new plugin types mixer2 and mixer3
+ * - added section about \ref concurrency
+ */
+
+
+/**
+ * \addtogroup pluglocations Plugin Locations
+ * @section sec_pluglocations Plugin Locations
+ *
+ * For Unix platforms there are rules for the location of frei0r plugins.
+ *
+ * frei0r 1.x plugin files should be located in
+ *
+ * - (1) /usr/lib/frei0r-1/\<vendor\>
+ * - (2) /usr/local/lib/frei0r-1/\<vendor\>
+ * - (3) $HOME/.frei0r-1/lib/\<vendor\>
+ *
+ * Examples:
+ *
+ * - /usr/lib/frei0r-1/mob/flippo.so
+ * - /usr/lib/frei0r-1/drone/flippo.so
+ * - /usr/local/lib/frei0r-1/gephex/coma/invert0r.so
+ * - /home/martin/.frei0r-1/lib/martin/test.so
+ *
+ * Like in these examples plugins should be placed in "vendor" subdirs
+ * to reduce name clashes.
+ *
+ * @subsection sec_order Plugin Loading Order
+ *
+ * The application shall load plugins in the following order: 3, 2, 1.
+ * If a name clash occurs (two or more frei0r plugins with identical
+ * effect name), the plugins in directory 3 have precedence over plugins
+ * in directory 2, and those in directory 2 have precedence over plugins
+ * in directory 1.
+ *
+ * This makes it possible for users to "override" effects that are
+ * installed in system wide directories by placing plugins in their
+ * home directory.
+ *
+ * The order of loading plugins inside each of the directories
+ * 1, 2, and 3 is not defined.
+ */
+
+/**
+ *\addtogroup icons Icons for frei0r effects
+ * @section sec_icons Icons for frei0r effects
+ *
+ * Each frei0r effect can have an associated icon.
+ *
+ * @subsection sec_icon_format Icon Format
+ *
+ * The format of frei0r icons must be png.
+ * Recommended resolution is 64x64.
+ * The icon filename of an effect with effect name "frei0r"
+ * must be "frei0r.png".
+ *
+ * @subsection sec_icon_location Icon location
+ *
+ * The exact location where the application should look for the
+ * plugin is platform dependant.
+ *
+ * For Windows platforms, the icon should be at the same place as
+ * the plugin containing the effect.
+ *
+ * For Unix platforms, the following mapping from plugin location
+ * to icon location must be used:
+ *
+ * Let \<plugin_path\>/\<plugin\> be a frei0r plugin with name \<effect_name\>.
+ * Then the corresponding icon (if any) shall be located in
+ * \<icon_path\>/\<effect_name\>.png.
+ * \<icon_path\> can be obtained in the following way:
+ *
+ * @verbatim
+ <plugin_path> | <icon_path>
+ ----------------------------------------------------------------------------
+ $HOME/.frei0r-1/lib/<vendor> | $HOME/.frei0r-1/icons/<vendor>
+ /usr/local/lib/frei0r-1/<vendor> | /usr/local/share/frei0r-1/icons/<vendor>
+ /usr/lib/frei0r-1/<vendor> | /usr/share/frei0r-1/icons/<vendor>
+ * | <plugin_path>
+ @endverbatim
+ *
+ * (The wildcard '*' stands for any other plugin_path)
+ *
+ * For other platforms, no location is defined. We recommend to use the
+ * plugin path where possible.
+ */
+
+/**
+ * \addtogroup concurrency Concurrency
+ * @section sec_concurrency Concurrency
+ *
+ * - \ref f0r_init
+ * - \ref f0r_deinit
+ *
+ * These methods must not be called more than once. It is obvious that no
+ * concurrent calls are allowed.
+ *
+ *
+ * - \ref f0r_get_plugin_info
+ * - \ref f0r_get_param_info
+ * - \ref f0r_construct
+ * - \ref f0r_destruct
+ *
+ * Concurrent calls of these functions are allowed.
+ *
+ *
+ * - \ref f0r_set_param_value
+ * - \ref f0r_get_param_value
+ * - \ref f0r_update
+ * - \ref f0r_update2
+ *
+ * If a thread is in one of these methods its allowed for another thread to
+ * enter one of theses methods for a different effect instance. But for one
+ * effect instance only one thread is allowed to execute any of these methods.
+ */
+
+
+
+/** \file
+ * \brief This file defines the frei0r api, version 1.1.
+ *
+ * A conforming plugin must implement and export all functions declared in
+ * this header.
+ *
+ * A conforming application must accept only those plugins which use
+ * allowed values for the described fields.
+ */
+
+#ifndef INCLUDED_FREI0R_H
+#define INCLUDED_FREI0R_H
+
+#include <inttypes.h>
+
+/**
+ * The frei0r API major version
+ */
+#define FREI0R_MAJOR_VERSION 1
+
+/**
+ * The frei0r API minor version
+ */
+#define FREI0R_MINOR_VERSION 1
+
+//---------------------------------------------------------------------------
+
+/**
+ * f0r_init() is called once when the plugin is loaded by the application.
+ * \see f0r_deinit
+ */
+int f0r_init(void);
+
+/**
+ * f0r_deinit is called once when the plugin is unloaded by the application.
+ * \see f0r_init
+ */
+void f0r_deinit(void);
+
+//---------------------------------------------------------------------------
+
+/** \addtogroup PLUGIN_TYPE Type of the Plugin
+ * These defines determine whether the plugin is a
+ * source, a filter or one of the two mixer types
+ * @{
+ */
+
+/** one input and one output */
+#define F0R_PLUGIN_TYPE_FILTER 0
+/** just one output */
+#define F0R_PLUGIN_TYPE_SOURCE 1
+/** two inputs and one output */
+#define F0R_PLUGIN_TYPE_MIXER2 2
+/** three inputs and one output */
+#define F0R_PLUGIN_TYPE_MIXER3 3
+
+/** @} */
+
+//---------------------------------------------------------------------------
+
+/** \addtogroup COLOR_MODEL Color Models
+ * List of supported color models.
+ *
+ * Note: the color models are endian independent, because the
+ * color components are defined by their positon in memory, not
+ * by their significance in an uint32_t value.
+ *
+ * For effects that work on the color components,
+ * RGBA8888 is the recommended color model for frei0r-1.1 effects.
+ * For effects that only work on pixels, PACKED32 is the recommended
+ * color model since it helps the application to avoid unnecessary
+ * color conversions.
+ *
+ * Effects can choose an appropriate color model, applications must support
+ * all color models and do conversions if necessary. Source effects
+ * must not use the PACKED32 color model because the application must know
+ * in which color model the created framebuffers are represented.
+ *
+ * For each color model, a frame consists of width*height pixels which
+ * are stored row-wise and consecutively in memory. The size of a pixel is
+ * 4 bytes. There is no extra pitch parameter
+ * (i.e. the pitch is simply width*4).
+ *
+ * The following additional constraints must be honored:
+ * - The top-most line of a frame is stored first in memory.
+ * - A frame must be aligned to a 16 byte border in memory.
+ * - The width and height of a frame must be positive
+ * - The width and height of a frame must be integer multiples of 8
+ *
+ * These constraints make sure that each line is stored at an address aligned
+ * to 16 byte.
+ */
+/*@{*/
+/**
+ * In BGRA8888, each pixel is represented by 4 consecutive
+ * unsigned bytes, where the first byte value represents
+ * the blue, the second the green, and the third the red color
+ * component of the pixel. The last value represents the
+ * alpha value.
+ */
+#define F0R_COLOR_MODEL_BGRA8888 0
+
+/**
+ * In RGBA8888, each pixel is represented by 4 consecutive
+ * unsigned bytes, where the first byte value represents
+ * the red, the second the green, and the third the blue color
+ * component of the pixel. The last value represents the
+ * alpha value.
+ */
+#define F0R_COLOR_MODEL_RGBA8888 1
+
+/**
+ * In PACKED32, each pixel is represented by 4 consecutive
+ * bytes, but it is not defined how the color componets are
+ * stored. The true color format could be RGBA8888,
+ * BGRA8888, a packed 32 bit YUV format, or any other
+ * color format that stores pixels in 32 bit.
+ *
+ * This is useful for effects that don't work on color but
+ * only on pixels (for example a mirror effect).
+ *
+ * Note that source effects must not use this color model.
+ */
+#define F0R_COLOR_MODEL_PACKED32 2
+/*@}*/
+
+/**
+ * The f0r_plugin_info_t structure is filled in by the plugin
+ * to tell the application about its name, type, number of parameters,
+ * and version.
+ *
+ * An application should ignore (i.e. not use) frei0r effects that
+ * have unknown values in the plugin_type or color_model field.
+ * It should also ignore effects with a too high frei0r_version.
+ *
+ * This is necessary to be able to extend the frei0r spec (e.g.
+ * by adding new color models or plugin types) in a way that does not
+ * result in crashes when loading effects that make use of these
+ * extensions into an older application.
+ *
+ * All strings are unicode, 0-terminated, and the encoding is utf-8.
+ */
+typedef struct f0r_plugin_info
+{
+ const char* name; /**< The (short) name of the plugin */
+ const char* author; /**< The plugin author */
+ /** The plugin type
+ * \see PLUGIN_TYPE
+ */
+ int plugin_type;
+ int color_model; /**< The color model used */
+ int frei0r_version; /**< The frei0r major version this plugin is built for*/
+ int major_version; /**< The major version of the plugin */
+ int minor_version; /**< The minor version of the plugin */
+ int num_params; /**< The number of parameters of the plugin */
+ const char* explanation; /**< An optional explanation string */
+} f0r_plugin_info_t;
+
+
+/**
+ * Is called once after init. The plugin has to fill in the values in info.
+ *
+ * \param info Pointer to an info struct allocated by the application.
+ */
+void f0r_get_plugin_info(f0r_plugin_info_t* info);
+
+//---------------------------------------------------------------------------
+
+/** \addtogroup PARAM_TYPE Parameter Types
+ *
+ * @{
+ */
+
+
+/**
+ * Parameter type for boolean values
+ * \see f0r_param_bool
+ */
+#define F0R_PARAM_BOOL 0
+
+/**
+ * Parameter type for doubles
+ * \see f0r_param_double
+ */
+#define F0R_PARAM_DOUBLE 1
+
+/**
+ * Parameter type for color
+ * \see f0r_param_color
+ */
+#define F0R_PARAM_COLOR 2
+/**
+ * Parameter type for position
+ * \see f0r_param_position
+ */
+#define F0R_PARAM_POSITION 3
+
+/**
+ * Parameter type for string
+ * \see f0r_param_string
+ */
+#define F0R_PARAM_STRING 4
+
+/**
+ * The boolean type. The allowed range of values is [0, 1].
+ * [0, 0.5[ is mapped to false and [0.5, 1] is mapped to true.
+ */
+typedef double f0r_param_bool;
+
+/**
+ * The double type. The allowed range of values is [0, 1].
+ */
+typedef double f0r_param_double;
+
+/**
+ * The color type. All three color components are in the range [0, 1].
+ */
+typedef struct f0r_param_color
+{
+ float r; /**< red color component */
+ float g; /**< green color component */
+ float b; /**< blue color component */
+} f0r_param_color_t;
+
+/**
+ * The position type. Both position coordinates are in the range [0, 1].
+ */
+typedef struct f0r_param_position
+{
+ double x; /**< x coordinate */
+ double y; /**< y coordinate */
+} f0r_param_position_t;
+
+
+/**
+ * The string type.
+ * Zero terminated array of 8-bit values in utf-8 encoding
+ */
+typedef char f0r_param_string;
+
+/** @} */
+
+
+/**
+ * Similar to f0r_plugin_info_t, this structure is filled by the plugin
+ * for every parameter.
+ *
+ * All strings are unicode, 0-terminated, and the encoding is utf-8.
+ */
+typedef struct f0r_param_info
+{
+ const char* name; /**<The (short) name of the param */
+ int type; /**<The type (see the F0R_PARAM_* defines) */
+ const char* explanation; /**<Optional explanation (can be 0) */
+} f0r_param_info_t;
+
+/**
+ * f0r_get_param_info is called by the application to query the type of
+ * each parameter.
+ *
+ * \param info is allocated by the application and filled by the plugin
+ * \param param_index the index of the parameter to be queried (from 0 to
+ * num_params-1)
+ */
+void f0r_get_param_info(f0r_param_info_t* info, int param_index);
+
+//---------------------------------------------------------------------------
+
+/**
+ * Transparent instance pointer of the frei0r effect.
+ */
+typedef void* f0r_instance_t;
+
+/**
+ * Constructor for effect instances. The plugin returns a pointer to
+ * its internal instance structure.
+ *
+ * The resolution has to be an integer multiple of 8,
+ * must be greater than 0 and be at most 2048 in both dimensions.
+ *
+ * \param width The x-resolution of the processed video frames
+ * \param height The y-resolution of the processed video frames
+ * \returns 0 on failure or a pointer != 0 on success
+ *
+ * \see f0r_destruct
+ */
+f0r_instance_t f0r_construct(unsigned int width, unsigned int height);
+
+/**
+ * Destroys an effect instance.
+ *
+ * \param instance The pointer to the plugins internal instance structure.
+ *
+ * \see f0r_construct
+ */
+void f0r_destruct(f0r_instance_t instance);
+
+//---------------------------------------------------------------------------
+
+/**
+ * Transparent parameter handle.
+ */
+typedef void* f0r_param_t;
+
+/**
+ * This function allows the application to set the parameter values of an
+ * effect instance. Validity of the parameter pointer is handled by the
+ * application thus the data must be copied by the effect.
+ *
+ * \param instance the effect instance
+ * \param param pointer to the parameter value
+ * \param param_index index of the parameter
+ *
+ * \see f0r_get_param_value
+ */
+void f0r_set_param_value(f0r_instance_t instance,
+ f0r_param_t param, int param_index);
+
+/**
+ * This function allows the application to query the parameter values of an
+ * effect instance.
+ *
+ * \param instance the effect instance
+ * \param param pointer to the parameter value
+ * \param param_index index of the parameter
+ *
+ * \see f0r_set_param_value
+ */
+void f0r_get_param_value(f0r_instance_t instance,
+ f0r_param_t param, int param_index);
+
+//---------------------------------------------------------------------------
+
+/**
+ * This is where the core effect processing happens. The application calls it
+ * after it has set the necessary parameter values.
+ * inframe and outframe must be aligned to an integer multiple of 16 bytes
+ * in memory.
+ *
+ * This funcition should not alter the parameters of the effect in any
+ * way (\ref f0r_get_param_value should return the same values after a call
+ * to \ref f0r_update as before the call).
+ *
+ * The function is responsible to restore the fpu state (e.g. rounding mode)
+ * and mmx state if applicable before it returns to the caller.
+ *
+ * The host mustn't call \ref f0r_update for effects of type
+ * \ref F0R_PLUGIN_TYPE_MIXER2 and \ref F0R_PLUGIN_TYPE_MIXER3.
+ *
+ * \param instance the effect instance
+ * \param time the application time in seconds but with subsecond resolution
+ * (e.g. milli-second resolution). The resolution should be at least
+ * the inter-frame period of the application.
+ * \param inframe the incoming video frame (can be zero for sources)
+ * \param outframe the resulting video frame
+ *
+ * \see f0r_update2
+ */
+void f0r_update(f0r_instance_t instance,
+ double time, const uint32_t* inframe, uint32_t* outframe);
+
+//---------------------------------------------------------------------------
+
+/**
+ * For effects of type \ref F0R_PLUGIN_TYPE_SOURCE or
+ * \ref F0R_PLUGIN_TYPE_FILTER this method is optional. The \ref f0r_update
+ * method must still be exported for these two effect types. If both are
+ * provided the behavior of them must be the same.
+ *
+ * Effects of type \ref F0R_PLUGIN_TYPE_MIXER2 or \ref F0R_PLUGIN_TYPE_MIXER3 must provide the new \ref f0r_update2 method.
+
+ * \param instance the effect instance
+ * \param time the application time in seconds but with subsecond resolution
+ * (e.g. milli-second resolution). The resolution should be at least
+ * the inter-frame period of the application.
+ * \param inframe1 the first incoming video frame (can be zero for sources)
+ * \param inframe2 the second incoming video frame
+ (can be zero for sources and filters)
+ * \param inframe3 the third incoming video frame
+ (can be zero for sources, filters and mixer3)
+ * \param outframe the resulting video frame
+ *
+ * \see f0r_update
+ */
+void f0r_update2(f0r_instance_t instance,
+ double time,
+ const uint32_t* inframe1,
+ const uint32_t* inframe2,
+ const uint32_t* inframe3,
+ uint32_t* outframe);
+//---------------------------------------------------------------------------
+
+#endif
diff --git a/pdp_frei0r/help_pdp_frei0r.pd b/pdp_frei0r/help_pdp_frei0r.pd
new file mode 100644
index 0000000..0898526
--- /dev/null
+++ b/pdp_frei0r/help_pdp_frei0r.pd
@@ -0,0 +1,328 @@
+#N canvas 0 0 996 665 10;
+#X floatatom 151 379 5 0 0 0 - - -;
+#X obj 196 377 hradio 15 1 0 49 empty empty empty 0 -6 0 8 -262144
+-1 -1 16;
+#X obj 261 171 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X obj 401 171 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X obj 541 171 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X msg 258 191 param 3 \$1;
+#X msg 398 190 param 4 \$1;
+#X msg 539 190 param 5 \$1;
+#X text 197 358 Select the plugin;
+#X text 258 72 Adjust plugin parameters.;
+#X symbolatom 87 501 20 0 0 0 - - -;
+#X text 240 501 <-- plugin name;
+#X floatatom 106 479 5 0 0 0 - - -;
+#X text 154 477 <-- number of parameters;
+#X text 205 451 <-- parameter name;
+#X text 232 423 <-- parameter type;
+#X obj 263 112 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 3200 1;
+#X obj 401 112 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 4100 1;
+#X obj 542 112 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X obj 261 234 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X obj 402 234 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X obj 544 234 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X msg 260 131 param 0 \$1;
+#X msg 398 131 param 1 \$1;
+#X msg 539 131 param 2 \$1;
+#X msg 260 254 param 6 \$1;
+#X msg 399 253 param 7 \$1;
+#X msg 541 253 param 8 \$1;
+#N canvas 0 0 996 665 pname 0;
+#X obj 51 119 l2s;
+#X obj 80 119 l2s;
+#X obj 111 119 l2s;
+#X obj 143 119 l2s;
+#X obj 207 120 l2s;
+#X obj 236 120 l2s;
+#X obj 267 120 l2s;
+#X obj 298 119 l2s;
+#X obj 327 119 l2s;
+#X obj 97 51 inlet;
+#X obj 51 154 s ffparam0;
+#X obj 79 178 s ffparam1;
+#X obj 118 205 s ffparam2;
+#X obj 148 227 s ffparam3;
+#X obj 185 157 s ffparam4;
+#X obj 213 181 s ffparam5;
+#X obj 255 206 s ffparam6;
+#X obj 283 230 s ffparam7;
+#X obj 305 155 s ffparam8;
+#X obj 391 53 inlet;
+#X msg 390 79 symbol;
+#X obj 359 118 l2s;
+#X obj 391 118 l2s;
+#X obj 97 79 route 0 1 2 3 4 5 6 7 8 9 10;
+#X obj 357 178 s ffparam9;
+#X obj 414 202 s ffparam10;
+#X connect 0 0 10 0;
+#X connect 1 0 11 0;
+#X connect 2 0 12 0;
+#X connect 3 0 13 0;
+#X connect 4 0 14 0;
+#X connect 5 0 15 0;
+#X connect 6 0 16 0;
+#X connect 7 0 17 0;
+#X connect 8 0 18 0;
+#X connect 9 0 23 0;
+#X connect 19 0 20 0;
+#X connect 20 0 10 0;
+#X connect 20 0 11 0;
+#X connect 20 0 12 0;
+#X connect 20 0 13 0;
+#X connect 20 0 14 0;
+#X connect 20 0 15 0;
+#X connect 20 0 16 0;
+#X connect 20 0 17 0;
+#X connect 20 0 18 0;
+#X connect 20 0 24 0;
+#X connect 20 0 25 0;
+#X connect 21 0 24 0;
+#X connect 22 0 25 0;
+#X connect 23 0 0 0;
+#X connect 23 1 1 0;
+#X connect 23 2 2 0;
+#X connect 23 3 3 0;
+#X connect 23 4 4 0;
+#X connect 23 5 5 0;
+#X connect 23 6 6 0;
+#X connect 23 7 7 0;
+#X connect 23 8 8 0;
+#X connect 23 9 21 0;
+#X connect 23 10 22 0;
+#X restore 137 451 pd pname;
+#X symbolatom 260 93 18 0 0 0 - ffparam0 -;
+#X symbolatom 399 92 18 0 0 0 - ffparam1 -;
+#X symbolatom 538 92 18 0 0 0 - ffparam2 -;
+#X symbolatom 261 154 18 0 0 0 - ffparam3 -;
+#X symbolatom 400 153 18 0 0 0 - ffparam4 -;
+#X symbolatom 539 153 18 0 0 0 - ffparam5 -;
+#X symbolatom 261 214 18 0 0 0 - ffparam6 -;
+#X symbolatom 400 213 18 0 0 0 - ffparam7 -;
+#X symbolatom 539 213 18 0 0 0 - ffparam8 -;
+#X text 489 424 frei0r host for Pure Data Packet version 0.1;
+#X text 491 439 by Lluis Gomez i Bigorda (lluis@artefacte.org);
+#X text 510 452 & Yves Degoyon (ydegoyon@free.fr);
+#X text 491 495 made at piksel yearly gathering : http://www.piksel.no
+;
+#X obj 155 423 print type;
+#X text 491 467 using frei0r specification 1.1 by Georg Seidel \, Phillip
+Promesberger and Martin Bayer;
+#X obj 261 304 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X obj 404 304 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X symbolatom 261 283 18 0 0 0 - ffparam9 -;
+#X symbolatom 400 283 18 0 0 0 - ffparam10 -;
+#X msg 259 323 param 9 \$1;
+#X msg 401 323 param 10 \$1;
+#X obj 46 545 pdp_xv;
+#N canvas 222 59 450 300 input1 0;
+#X obj 49 181 pdp_qt;
+#X msg 49 49 bang;
+#X msg 110 111 loop 1;
+#X obj 50 214 pdp_scale 320 240;
+#X msg 167 111 open \$1;
+#X obj 167 89 openpanel;
+#X text 98 49 Load a mov file;
+#X obj 244 113 pdp_v4l;
+#X msg 244 58 bang;
+#X obj 49 250 outlet;
+#X obj 49 5 inlet;
+#X obj 251 7 inlet;
+#X obj 247 33 route 0;
+#X msg 298 59 stop;
+#X obj 50 28 route 0;
+#X msg 14 79 stop;
+#X obj 49 111 metro 80;
+#X obj 244 86 metro 80;
+#X connect 0 0 3 0;
+#X connect 1 0 2 0;
+#X connect 1 0 5 0;
+#X connect 1 0 16 0;
+#X connect 2 0 0 0;
+#X connect 3 0 9 0;
+#X connect 4 0 0 0;
+#X connect 5 0 4 0;
+#X connect 7 0 3 0;
+#X connect 8 0 17 0;
+#X connect 10 0 14 0;
+#X connect 11 0 12 0;
+#X connect 12 0 13 0;
+#X connect 12 1 8 0;
+#X connect 13 0 17 0;
+#X connect 14 0 15 0;
+#X connect 14 1 1 0;
+#X connect 15 0 16 0;
+#X connect 16 0 0 0;
+#X connect 17 0 7 0;
+#X restore 44 44 pd input1;
+#X text 49 24 .mov;
+#X text 115 24 cam;
+#X obj 102 10 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+;
+#X obj 44 10 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X text 85 89 .mov;
+#X text 151 89 cam;
+#X obj 138 75 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 80 75 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
+;
+#N canvas 222 59 450 300 input2 0;
+#X obj 49 181 pdp_qt;
+#X msg 49 49 bang;
+#X msg 110 111 loop 1;
+#X obj 50 214 pdp_scale 320 240;
+#X msg 167 111 open \$1;
+#X obj 167 89 openpanel;
+#X text 98 49 Load a mov file;
+#X obj 244 113 pdp_v4l;
+#X msg 244 58 bang;
+#X obj 49 250 outlet;
+#X obj 49 5 inlet;
+#X obj 251 7 inlet;
+#X obj 247 33 route 0;
+#X msg 298 59 stop;
+#X obj 50 28 route 0;
+#X msg 14 79 stop;
+#X obj 49 111 metro 80;
+#X obj 244 86 metro 80;
+#X connect 0 0 3 0;
+#X connect 1 0 2 0;
+#X connect 1 0 5 0;
+#X connect 1 0 16 0;
+#X connect 2 0 0 0;
+#X connect 3 0 9 0;
+#X connect 4 0 0 0;
+#X connect 5 0 4 0;
+#X connect 7 0 3 0;
+#X connect 8 0 17 0;
+#X connect 10 0 14 0;
+#X connect 11 0 12 0;
+#X connect 12 0 13 0;
+#X connect 12 1 8 0;
+#X connect 13 0 17 0;
+#X connect 14 0 15 0;
+#X connect 14 1 1 0;
+#X connect 15 0 16 0;
+#X connect 16 0 0 0;
+#X connect 17 0 7 0;
+#X restore 80 109 pd input2;
+#X text 116 148 .mov;
+#X text 182 148 cam;
+#X obj 169 134 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 111 134 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#N canvas 222 59 450 300 input3 0;
+#X obj 49 181 pdp_qt;
+#X msg 49 49 bang;
+#X msg 110 111 loop 1;
+#X obj 50 214 pdp_scale 320 240;
+#X msg 167 111 open \$1;
+#X obj 167 89 openpanel;
+#X text 98 49 Load a mov file;
+#X obj 244 113 pdp_v4l;
+#X msg 244 58 bang;
+#X obj 49 250 outlet;
+#X obj 49 5 inlet;
+#X obj 251 7 inlet;
+#X obj 247 33 route 0;
+#X msg 298 59 stop;
+#X obj 50 28 route 0;
+#X msg 14 79 stop;
+#X obj 49 111 metro 80;
+#X obj 244 86 metro 80;
+#X connect 0 0 3 0;
+#X connect 1 0 2 0;
+#X connect 1 0 5 0;
+#X connect 1 0 16 0;
+#X connect 2 0 0 0;
+#X connect 3 0 9 0;
+#X connect 4 0 0 0;
+#X connect 5 0 4 0;
+#X connect 7 0 3 0;
+#X connect 8 0 17 0;
+#X connect 10 0 14 0;
+#X connect 11 0 12 0;
+#X connect 12 0 13 0;
+#X connect 12 1 8 0;
+#X connect 13 0 17 0;
+#X connect 14 0 15 0;
+#X connect 14 1 1 0;
+#X connect 15 0 16 0;
+#X connect 16 0 0 0;
+#X connect 17 0 7 0;
+#X restore 111 168 pd input3;
+#X obj 43 202 pdp_scale 320 240;
+#X obj 69 232 pdp_scale 320 240;
+#X obj 93 262 pdp_scale 320 240;
+#X obj 905 409 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 905 461 pdp_control;
+#X msg 905 434 thread \$1;
+#X floatatom 905 522 5 0 0 0 - - -;
+#X obj 905 493 route pdp_drop;
+#X text 498 547 constructor : pdp_frei0r <index>;
+#X obj 46 376 pdp_frei0r 16;
+#X text 499 562 you can get the index from the list of loaded plugins
+;
+#X text 498 575 at startup ( check pd window );
+#X text 13 290 WARNING : sizes of inputs;
+#X text 12 302 _must_ be the same;
+#X connect 0 0 75 3;
+#X connect 1 0 0 0;
+#X connect 2 0 5 0;
+#X connect 3 0 6 0;
+#X connect 4 0 7 0;
+#X connect 5 0 75 0;
+#X connect 6 0 75 0;
+#X connect 7 0 75 0;
+#X connect 12 0 28 1;
+#X connect 16 0 22 0;
+#X connect 17 0 23 0;
+#X connect 18 0 24 0;
+#X connect 19 0 25 0;
+#X connect 20 0 26 0;
+#X connect 21 0 27 0;
+#X connect 22 0 75 0;
+#X connect 23 0 75 0;
+#X connect 24 0 75 0;
+#X connect 25 0 75 0;
+#X connect 26 0 75 0;
+#X connect 27 0 75 0;
+#X connect 44 0 48 0;
+#X connect 45 0 49 0;
+#X connect 48 0 75 0;
+#X connect 49 0 75 0;
+#X connect 51 0 66 0;
+#X connect 54 0 51 1;
+#X connect 55 0 51 0;
+#X connect 58 0 60 1;
+#X connect 59 0 60 0;
+#X connect 60 0 67 0;
+#X connect 63 0 65 1;
+#X connect 64 0 65 0;
+#X connect 65 0 68 0;
+#X connect 66 0 75 0;
+#X connect 67 0 75 1;
+#X connect 68 0 75 2;
+#X connect 69 0 71 0;
+#X connect 70 0 73 0;
+#X connect 71 0 70 0;
+#X connect 73 0 72 0;
+#X connect 75 0 50 0;
+#X connect 75 1 10 0;
+#X connect 75 2 12 0;
+#X connect 75 3 28 0;
+#X connect 75 4 42 0;
diff --git a/pdp_frei0r/pdp_frei0r.c b/pdp_frei0r/pdp_frei0r.c
new file mode 100644
index 0000000..3a66147
--- /dev/null
+++ b/pdp_frei0r/pdp_frei0r.c
@@ -0,0 +1,637 @@
+/*
+ * Pure Data Packet module.
+ * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <limits.h>
+#include <dlfcn.h>
+
+#include "pdp.h"
+#include "frei0r.h"
+
+#define FREI0R_PNAME_LENGTH 128
+
+typedef struct
+{
+ char name[FREI0R_PNAME_LENGTH+1];
+ unsigned numparameters;
+ int plugin_type;
+ f0r_instance_t instance;
+ f0r_plugin_info_t plugin_info;
+ int (*f0r_init)(void);
+ void (*f0r_get_plugin_info)(f0r_plugin_info_t* pluginInfo);
+ void (*f0r_get_param_info)(f0r_param_info_t* info, int param_index);
+ f0r_instance_t (*f0r_construct)(unsigned int width, unsigned int height);
+ void (*f0r_destruct)(f0r_instance_t instance);
+ void (*f0r_set_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index);
+ void (*f0r_get_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index);
+ void (*f0r_update)(f0r_instance_t instance, double time, const uint32_t* inframe, uint32_t* outframe);
+ void (*f0r_update2)(f0r_instance_t instance, double time,
+ const uint32_t* inframe1, const uint32_t* inframe2, const uint32_t* inframe3, uint32_t* outframe);
+ int (*f0r_deinit)(void);
+} PLUGIN;
+
+typedef struct pdp_frei0r_struct
+{
+ t_object x_obj;
+ t_float x_f;
+
+ t_outlet *x_outlet0;
+ t_outlet *x_pname;
+ t_outlet *x_nparams;
+ t_outlet *x_parname;
+ t_outlet *x_partype;
+ int x_packet0;
+ int x_packet1;
+ int x_packet2;
+ int x_packet3;
+
+ // middle input packets
+ int x_packetm0;
+ int x_packetm1;
+
+ // right input packets
+ int x_packetr0;
+ int x_packetr1;
+
+ int x_dropped;
+ int x_queue_id;
+
+ int x_width;
+ int x_height;
+ int x_size;
+
+ int x_plugin_count;
+ struct dirent **x_filename_list;
+ int x_filename_count;
+
+ int x_plugin;
+ int x_infosok;
+
+ PLUGIN *plugins;
+
+} t_pdp_frei0r;
+
+void panic(const char *panicstr, ...)
+{
+ post("pdp_frei0r :: PANIC!! %s\n", panicstr);
+ exit(1);
+}
+
+static int selector(const struct dirent *dp)
+{
+ return (strstr(dp->d_name, ".so") != NULL);
+}
+
+static void scan_plugins(t_pdp_frei0r *x, char *plugindir)
+{
+ x->x_filename_count = scandir(plugindir, &x->x_filename_list, selector, alphasort);
+ if (x->x_filename_count < 0)
+ {
+ x->x_filename_count = 0;
+ }
+}
+
+void fr_loadplugins(t_pdp_frei0r *x, char *plugindir)
+{
+ char libname[PATH_MAX];
+ unsigned instance, numparameters;
+ int i;
+ char *pluginname;
+ void *plugin_handle;
+
+ scan_plugins(x, plugindir);
+
+ x->x_plugin_count = 0;
+ x->plugins = (PLUGIN *)getbytes(x->x_filename_count*sizeof(PLUGIN));
+ if (x->plugins == NULL)
+ {
+ panic("no memory for loading plugins\n");
+ }
+ else
+ {
+ post( "allocated plugins : %x", x->plugins );
+ }
+
+ for (i=0; i<x->x_filename_count; i++)
+ {
+ pluginname = x->x_filename_list[i]->d_name;
+
+ snprintf(libname, PATH_MAX, "%s/%s", plugindir, pluginname);
+
+ post( "pdp_frei0r : opening : %s", pluginname );
+
+ plugin_handle = dlopen(libname, RTLD_NOW);
+ dlerror();
+
+ // get functions pointers
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_init) = dlsym(plugin_handle, "f0r_init");
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_get_plugin_info) = dlsym(plugin_handle, "f0r_get_plugin_info");
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_get_param_info) = dlsym(plugin_handle, "f0r_get_param_info");
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_construct) = dlsym(plugin_handle, "f0r_construct");
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_destruct) = dlsym(plugin_handle, "f0r_destruct");
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_set_param_value) = dlsym(plugin_handle, "f0r_set_param_value");
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_get_param_value) = dlsym(plugin_handle, "f0r_get_param_value");
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_update) = dlsym(plugin_handle, "f0r_update");
+ dlerror();
+
+ // check for special function update2
+ *(void**) (&x->plugins[x->x_plugin_count].f0r_update2) = dlsym(plugin_handle, "f0r_update2");
+ if (!dlerror())
+ {
+ // continue;
+ }
+
+ // init plugin
+ (*x->plugins[x->x_plugin_count].f0r_init)();
+
+ // instantiate
+ x->plugins[x->x_plugin_count].instance = (*x->plugins[x->x_plugin_count].f0r_construct)(x->x_width, x->x_height);
+
+ // get plugin infos
+ (*x->plugins[x->x_plugin_count].f0r_get_plugin_info)(&x->plugins[x->x_plugin_count].plugin_info);
+ strcpy( x->plugins[x->x_plugin_count].name, x->plugins[x->x_plugin_count].plugin_info.name );
+ x->plugins[x->x_plugin_count].numparameters=x->plugins[x->x_plugin_count].plugin_info.num_params;
+ x->plugins[x->x_plugin_count].plugin_type=x->plugins[x->x_plugin_count].plugin_info.plugin_type;
+
+ if ( ( x->plugins[x->x_plugin_count].plugin_info.color_model != F0R_COLOR_MODEL_RGBA8888 ) &&
+ ( x->plugins[x->x_plugin_count].plugin_info.color_model != F0R_COLOR_MODEL_BGRA8888 ) &&
+ ( x->plugins[x->x_plugin_count].plugin_info.color_model != F0R_COLOR_MODEL_PACKED32 ) )
+ {
+ post( "pdp_frei0r : warning : plugin : %s use unsupported color model (%d) : ignored ...",
+ pluginname, x->plugins[x->x_plugin_count].plugin_info.color_model );
+ continue;
+ }
+
+ x->x_plugin_count++;
+ }
+}
+
+void fr_processframe(t_pdp_frei0r *x, int plugin, void *ibuffer, void *imbuffer, void *irbuffer, void *obuffer)
+{
+ double time = 0.0;
+
+ if ( x->x_plugin_count <= 0 )
+ {
+ return;
+ }
+
+ if ( ( x->plugins[x->x_plugin].plugin_type == F0R_PLUGIN_TYPE_FILTER ) ||
+ ( x->plugins[x->x_plugin].plugin_type == F0R_PLUGIN_TYPE_SOURCE ) )
+ {
+ // process frame
+ (*x->plugins[x->x_plugin].f0r_update)(x->plugins[x->x_plugin].instance, time, ibuffer, obuffer);
+ }
+ if ( x->plugins[x->x_plugin].plugin_type == F0R_PLUGIN_TYPE_MIXER2 )
+ {
+ if ( ( x->x_packet1 != -1 ) && ( x->x_packet2 != -1 ) && ( x->x_packetm1 != -1 ) )
+ {
+ // process frame
+ (*x->plugins[x->x_plugin].f0r_update2)(x->plugins[x->x_plugin].instance, time, ibuffer, imbuffer, irbuffer, obuffer);
+ }
+ }
+ if ( x->plugins[x->x_plugin].plugin_type == F0R_PLUGIN_TYPE_MIXER3 )
+ {
+ if ( ( x->x_packet1 != -1 ) && ( x->x_packet2 != -1 ) && ( x->x_packetm1 != -1 ) && ( x->x_packetr1 != -1 ) )
+ {
+ // process frame
+ (*x->plugins[x->x_plugin].f0r_update2)(x->plugins[x->x_plugin].instance, time, ibuffer, imbuffer, irbuffer, obuffer);
+ }
+ }
+}
+
+void fr_freeplugins(t_pdp_frei0r *x)
+{
+ t_int i;
+
+ for (i=0; i<x->x_plugin_count; i++)
+ {
+ // destroy plugin
+ (*x->plugins[i].f0r_destruct)(x->plugins[i].instance);
+ }
+ post("freeing plugin resources : %x", x->plugins);
+ freebytes( x->plugins, x->x_filename_count*sizeof(PLUGIN) );
+ x->plugins = NULL;
+}
+
+static void pdp_frei0r_process_rgba(t_pdp_frei0r *x)
+{
+ t_pdp *newheader = pdp_packet_header(x->x_packet2);
+ char *newdata = (char *)pdp_packet_data(x->x_packet2);
+ t_pdp *lheader = pdp_packet_header(x->x_packet1);
+ char *ldata = (char *)pdp_packet_data(x->x_packet1);
+ t_pdp *mheader = pdp_packet_header(x->x_packetm1);
+ char *mdata = (char *)pdp_packet_data(x->x_packetm1);
+ t_pdp *rheader = pdp_packet_header(x->x_packetr1);
+ char *rdata = (char *)pdp_packet_data(x->x_packetr1);
+
+ if ((x->x_width != (t_int)lheader->info.image.width) ||
+ (x->x_height != (t_int)lheader->info.image.height))
+ {
+
+ post("pdp_frei0r :: resizing plugins");
+
+ fr_freeplugins(x);
+
+ x->x_width = lheader->info.image.width;
+ x->x_height = lheader->info.image.height;
+ x->x_size = x->x_width*x->x_height;
+
+ //load the plugins
+ fr_loadplugins(x, FR_PLUGIN_DIR);
+ }
+
+ newheader->info.image.encoding = lheader->info.image.encoding;
+ newheader->info.image.width = x->x_width;
+ newheader->info.image.height = x->x_height;
+
+ memcpy( newdata, ldata, x->x_size*sizeof(uint32_t) );
+
+ fr_processframe(x, x->x_plugin, ldata, mdata, rdata, newdata);
+
+
+}
+
+static void pdp_frei0r_param(t_pdp_frei0r *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int pnumber;
+ f0r_param_info_t param_infos;
+
+ if ( x->x_plugin_count <= 0 )
+ {
+ post( "frei0r : set parameter : no plugins loaded, check your plugin directory setup" );
+ return;
+ }
+
+ if ( argc < 2 )
+ {
+ post("pdp_frei0r : set parameter : insufficient parameters (%d)", argc );
+ return;
+ }
+
+ if ( argv[0].a_type != A_FLOAT )
+ {
+ post("pdp_frei0r : set parameter : wrong parameter number" );
+ return;
+ }
+ pnumber = (int)argv[0].a_w.w_float;
+ // post("pdp_frei0r : setting parameter : %d", pnumber );
+
+ if ( (pnumber<0) || (pnumber>=(int)x->plugins[x->x_plugin].numparameters) )
+ {
+ post("pdp_frei0r : set parameter : wrong parameter number : %d : max : %d", pnumber, x->plugins[x->x_plugin].numparameters );
+ return;
+ }
+
+ (*x->plugins[x->x_plugin].f0r_get_param_info)(&param_infos, pnumber);
+
+ // set parameter
+ switch (param_infos.type)
+ {
+ case F0R_PARAM_BOOL:
+ {
+ f0r_param_bool fvalue;
+
+ if ( argc != 2 )
+ {
+ post("pdp_frei0r : wrong parameter arguments (%d) for boolean", argc );
+ return;
+ }
+ if ( argv[1].a_type != A_FLOAT )
+ {
+ post("pdp_frei0r : wrong parameter value" );
+ return;
+ }
+ if ( argv[1].a_w.w_float != 0. && argv[1].a_w.w_float != 1. )
+ {
+ // post("pdp_frei0r : wrong parameter value for boolean" );
+ return;
+ }
+ fvalue=argv[1].a_w.w_float;
+ (*x->plugins[x->x_plugin].f0r_set_param_value)(x->plugins[x->x_plugin].instance, &fvalue, pnumber);
+ }
+ break;
+ case F0R_PARAM_DOUBLE:
+ {
+ f0r_param_double fvalue;
+
+ if ( argc != 2 )
+ {
+ post("pdp_frei0r : wrong parameter arguments (%d) for double", argc );
+ return;
+ }
+ if ( argv[1].a_type != A_FLOAT )
+ {
+ post("pdp_frei0r : wrong parameter value" );
+ return;
+ }
+ fvalue=argv[1].a_w.w_float;
+ (*x->plugins[x->x_plugin].f0r_set_param_value)(x->plugins[x->x_plugin].instance, &fvalue, pnumber);
+ }
+ break;
+ case F0R_PARAM_COLOR:
+ {
+ struct f0r_param_color color;
+
+ if ( argc != 4 )
+ {
+ post("pdp_frei0r : wrong parameter arguments (%d) for color", argc );
+ return;
+ }
+ if ( argv[1].a_type != A_FLOAT ||
+ argv[2].a_type != A_FLOAT ||
+ argv[3].a_type != A_FLOAT )
+ {
+ post("pdp_frei0r : wrong parameter value" );
+ return;
+ }
+ color.r = argv[1].a_w.w_float;
+ color.g = argv[2].a_w.w_float;
+ color.b = argv[3].a_w.w_float;
+ (*x->plugins[x->x_plugin].f0r_set_param_value)(x->plugins[x->x_plugin].instance, &color, pnumber);
+ }
+ break;
+ case F0R_PARAM_POSITION:
+ {
+ struct f0r_param_position position;
+
+ if ( argc != 3 )
+ {
+ post("pdp_frei0r : wrong parameter arguments (%d) for position", argc );
+ return;
+ }
+ if ( argv[1].a_type != A_FLOAT ||
+ argv[2].a_type != A_FLOAT )
+ {
+ post("pdp_frei0r : wrong parameter value" );
+ return;
+ }
+ position.x = argv[1].a_w.w_float;
+ position.y = argv[2].a_w.w_float;
+ (*x->plugins[x->x_plugin].f0r_set_param_value)(x->plugins[x->x_plugin].instance, &position, pnumber);
+ }
+ break;
+ default:
+ post("pdp_frei0r : unsupported parameter type (%d)", param_infos.type );
+ return;
+ }
+}
+
+static void pdp_frei0r_plugin(t_pdp_frei0r *x, t_floatarg f)
+{
+ unsigned pi;
+ char *parname;
+ int partype;
+ t_atom plist[2];
+ t_atom tlist[2];
+ t_atom vlist[2];
+ f0r_param_info_t param_infos;
+
+ if ( x->x_plugin_count <= 0 )
+ {
+ post( "frei0r : no plugins loaded, check your plugin directory setup" );
+ return;
+ }
+ if((f<x->x_plugin_count)&&(f>-1))
+ {
+ x->x_plugin = f;
+ }
+ else
+ {
+ post( "frei0r : plugin out of range : %d", (t_int)f );
+ return;
+ }
+ post ("pdp_freeframe :: %s selected, %d parameters", x->plugins[x->x_plugin].name, x->plugins[x->x_plugin].numparameters);
+ outlet_symbol(x->x_pname, gensym( x->plugins[x->x_plugin].name ) );
+ outlet_float(x->x_nparams, (float)x->plugins[x->x_plugin].numparameters);
+ for ( pi=0; pi<x->plugins[x->x_plugin].numparameters; pi++ )
+ {
+ (*x->plugins[x->x_plugin].f0r_get_param_info)(&param_infos, pi);
+ SETFLOAT(&plist[0], pi);
+ SETSYMBOL(&plist[1], gensym(param_infos.name) );
+ outlet_list( x->x_parname, &s_list, 2, &plist[0] );
+ SETFLOAT(&tlist[0], pi);
+ SETFLOAT(&tlist[1], param_infos.type );
+ outlet_list( x->x_partype, &s_list, 2, &tlist[0] );
+ }
+}
+
+static void pdp_frei0r_sendpacket(t_pdp_frei0r *x)
+{
+ /* release the incoming packets */
+ pdp_packet_mark_unused(x->x_packet0);
+ x->x_packet0 = -1;
+ pdp_packet_mark_unused(x->x_packet1);
+ x->x_packet1 = -1;
+ pdp_packet_mark_unused(x->x_packetr0);
+ x->x_packetr0 = -1;
+ pdp_packet_mark_unused(x->x_packetr1);
+ x->x_packetr1 = -1;
+ pdp_packet_mark_unused(x->x_packetm0);
+ x->x_packetm0 = -1;
+ pdp_packet_mark_unused(x->x_packetm1);
+ x->x_packetm1 = -1;
+
+ x->x_packet3=-1;
+ x->x_dropped = pdp_packet_convert_ro_or_drop(&x->x_packet3, x->x_packet2, pdp_gensym("bitmap/rgb/*") );
+ pdp_packet_mark_unused(x->x_packet2);
+ x->x_packet2 = -1;
+
+ /* unregister and propagate if valid dest packet */
+ pdp_packet_pass_if_valid(x->x_outlet0, &x->x_packet3);
+}
+
+static void pdp_frei0r_process(t_pdp_frei0r *x)
+{
+ int encoding;
+ t_pdp *header = 0;
+ char *parname;
+ unsigned pi;
+ int partype;
+ t_atom plist[2];
+ t_atom tlist[2];
+ t_atom vlist[2];
+ f0r_param_info_t param_infos;
+
+ /* check if image data packets are compatible */
+ if ( (header = pdp_packet_header(x->x_packet1))
+ && (PDP_BITMAP == header->type)){
+
+ /* pdp_frei0r_process inputs and write into active inlet */
+ switch(pdp_packet_header(x->x_packet1)->info.image.encoding){
+
+ case PDP_BITMAP_RGBA:
+ x->x_packet2 = pdp_packet_clone_rw(x->x_packet1);
+ pdp_queue_add(x, pdp_frei0r_process_rgba, pdp_frei0r_sendpacket, &x->x_queue_id);
+ break;
+
+ default:
+ /* don't know the type, so dont pdp_frei0r_process */
+ break;
+
+ }
+ }
+
+ // hack to display infos of first loaded plugin
+ if ( ( x->x_plugin_count>0 ) && ( !x->x_infosok ) )
+ {
+ outlet_symbol(x->x_pname, gensym( x->plugins[x->x_plugin].name ) );
+ outlet_float(x->x_nparams, (float)x->plugins[x->x_plugin].numparameters);
+ for ( pi=0; pi<x->plugins[x->x_plugin].numparameters; pi++ )
+ {
+ (*x->plugins[x->x_plugin].f0r_get_param_info)(&param_infos, pi);
+ SETFLOAT(&plist[0], pi);
+ SETSYMBOL(&plist[1], gensym(param_infos.name) );
+ outlet_list( x->x_parname, &s_list, 2, &plist[0] );
+ SETFLOAT(&tlist[0], pi);
+ SETFLOAT(&tlist[1], param_infos.type );
+ outlet_list( x->x_partype, &s_list, 2, &tlist[0] );
+ }
+ x->x_infosok = 1;
+ }
+}
+
+static void pdp_frei0r_input_0(t_pdp_frei0r *x, t_symbol *s, t_floatarg f)
+{
+ if (s == gensym("register_rw"))
+ {
+ x->x_packet0=-1;
+ x->x_dropped = pdp_packet_convert_ro_or_drop(&x->x_packet0, (int)f, pdp_gensym("bitmap/rgb/*") );
+ // post("pdp_freiOr : drop 1 : %d", x->x_dropped );
+ x->x_packet1=-1;
+ x->x_dropped = pdp_packet_convert_ro_or_drop(&x->x_packet1, x->x_packet0, pdp_gensym("bitmap/rgba/*") );
+ // post("pdp_freiOr : drop 2 : %d", x->x_dropped );
+ }
+
+ if ((s == gensym("process")) && (-1 != x->x_packet1) && (!x->x_dropped))
+ {
+ /* add the process method and callback to the process queue */
+ pdp_frei0r_process(x);
+ }
+}
+
+static void pdp_frei0r_input_1(t_pdp_frei0r *x, t_symbol *s, t_floatarg f)
+{
+ char *ddata;
+ char *sdata;
+
+ if ( x->x_packetm0 != -1 )
+ {
+ return;
+ }
+ x->x_dropped = pdp_packet_convert_rw_or_drop(&x->x_packetm0, (int)f, pdp_gensym("bitmap/rgb/*") );
+ // post("pdp_freiOr : middle drop 1 : %d", x->x_dropped );
+ x->x_dropped = pdp_packet_convert_rw_or_drop(&x->x_packetm1, x->x_packetm0, pdp_gensym("bitmap/rgba/*") );
+ // post("pdp_freiOr : middle drop 2 : %d", x->x_dropped );
+}
+
+static void pdp_frei0r_input_2(t_pdp_frei0r *x, t_symbol *s, t_floatarg f)
+{
+ char *ddata;
+ char *sdata;
+
+ if ( x->x_packetr0 != -1 )
+ {
+ return;
+ }
+ x->x_dropped = pdp_packet_convert_rw_or_drop(&x->x_packetr0, (int)f, pdp_gensym("bitmap/rgb/*") );
+ // post("pdp_freiOr : right drop 1 : %d", x->x_dropped );
+ x->x_dropped = pdp_packet_convert_rw_or_drop(&x->x_packetr1, x->x_packetr0, pdp_gensym("bitmap/rgba/*") );
+ // post("pdp_freiOr : right drop 2 : %d", x->x_dropped );
+}
+
+static void pdp_frei0r_free(t_pdp_frei0r *x)
+{
+ int i;
+
+ pdp_queue_finish(x->x_queue_id);
+ pdp_packet_mark_unused(x->x_packet0);
+ fr_freeplugins(x);
+}
+
+t_class *pdp_frei0r_class;
+
+void *pdp_frei0r_new(t_floatarg f)
+{
+ int i;
+
+ t_pdp_frei0r *x = (t_pdp_frei0r *)pd_new(pdp_frei0r_class);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("pdp"), gensym("pdp1") );
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("pdp"), gensym("pdp2") );
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("plugin"));
+
+ x->x_outlet0 = outlet_new(&x->x_obj, &s_anything);
+ x->x_pname = outlet_new(&x->x_obj, &s_anything);
+ x->x_nparams = outlet_new(&x->x_obj, &s_anything);
+ x->x_parname = outlet_new(&x->x_obj, &s_anything);
+ x->x_partype = outlet_new(&x->x_obj, &s_anything);
+
+ x->x_packet0 = -1;
+ x->x_packet1 = -1;
+ x->x_packet2 = -1;
+ x->x_packet3 = -1;
+ x->x_packetm0 = -1;
+ x->x_packetm1 = -1;
+ x->x_packetr0 = -1;
+ x->x_packetr1 = -1;
+ x->x_queue_id = -1;
+
+ x->x_width = 320;
+ x->x_height = 240;
+ x->x_size = x->x_width * x->x_height;
+
+ //load the plugins
+ x->x_plugin_count = 0;
+ x->x_infosok = 0;
+ fr_loadplugins(x, FR_PLUGIN_DIR);
+
+ //select plugin
+ pdp_frei0r_plugin(x, f);
+
+ return (void *)x;
+}
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+void pdp_frei0r_setup(void)
+{
+
+ post( "pdp_frei0r :: frei0r host for Pure Data Packet version 0.1\n by Lluis Gomez i Bigorda (lluis@artefacte.org) \n & Yves Degoyon (ydegoyon@free.fr)\n using frei0r specification 1.1 by Georg Seidel,\n Phillip Promesberger and Martin Bayer\n made at piksel yearly gathering : http://www.piksel.no" );
+ pdp_frei0r_class = class_new(gensym("pdp_frei0r"), (t_newmethod)pdp_frei0r_new,
+ (t_method)pdp_frei0r_free, sizeof(t_pdp_frei0r), 0, A_DEFFLOAT, A_NULL);
+
+ class_addmethod(pdp_frei0r_class, (t_method)pdp_frei0r_input_0, gensym("pdp"), A_SYMBOL, A_DEFFLOAT, A_NULL);
+ class_addmethod(pdp_frei0r_class, (t_method)pdp_frei0r_input_1, gensym("pdp1"), A_SYMBOL, A_DEFFLOAT, A_NULL);
+ class_addmethod(pdp_frei0r_class, (t_method)pdp_frei0r_input_2, gensym("pdp2"), A_SYMBOL, A_DEFFLOAT, A_NULL);
+ class_addmethod(pdp_frei0r_class, (t_method)pdp_frei0r_plugin, gensym("plugin"), A_FLOAT, A_NULL);
+ class_addmethod(pdp_frei0r_class, (t_method)pdp_frei0r_param, gensym("param"), A_GIMME, A_NULL);
+
+}
+
+#ifdef __cplusplus
+}
+#endif