mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-12 19:00:02 +01:00
fix frei0r
This commit is contained in:
@@ -1324,6 +1324,8 @@ effect_constr* _effect_new( char *effect_line )
|
||||
if(descr_len <= 0) return NULL;
|
||||
|
||||
ec = g_new( effect_constr, 1);
|
||||
veejay_memset(ec,0,sizeof(ec));
|
||||
veejay_memset(ec->param_description,0,sizeof(ec->param_description));
|
||||
veejay_memset(ec->description,0,sizeof(ec->description));
|
||||
strncpy( ec->description, effect_line+3, descr_len );
|
||||
tokens = sscanf(effect_line+(descr_len+3), "%03d%1d%1d%02d", &(ec->id),&(ec->is_video),
|
||||
@@ -4047,8 +4049,8 @@ void load_effectlist_info()
|
||||
if(len > 0)
|
||||
{
|
||||
effect_constr *ec;
|
||||
char line[255];
|
||||
veejay_memset( line,0,sizeof(line));
|
||||
char line[512];
|
||||
veejay_memset( line,512,sizeof(line));
|
||||
strncpy( line, fxtext + offset, len );
|
||||
ec = _effect_new(line);
|
||||
if(ec) info->effect_info = g_list_append( info->effect_info, ec );
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
* 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 <config.h>
|
||||
#include <string.h>
|
||||
@@ -62,14 +64,83 @@ typedef void (*f0r_update_f)(f0r_instance_t instance, double time, const uint32_
|
||||
typedef void (*f0r_update2_f)(f0r_instance_t instance, double time, const uint32_t *inframe1, const uint32_t *inframe2, const uint32_t *inframe3, uint32_t *outframe);
|
||||
|
||||
typedef void (*f0r_set_param_value_f)(f0r_instance_t *instance, f0r_param_t *param, int param_index);
|
||||
void frei0r_plug_param_f( void *port, int seq_no, void *value );
|
||||
int frei0r_push_frame_f( void *plugin, char *dir, int seqno, VJFrame *in );
|
||||
int frei0r_process_frame_f( void *plugin );
|
||||
int frei0r_process_frame_ext_f( void *plugin );
|
||||
int frei0r_get_param_f( void *port, void *dst );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *buf;
|
||||
VJFrame *in[4];
|
||||
VJFrame *out;
|
||||
void *in_scaler;
|
||||
void *out_scaler;
|
||||
VJFrame *last;
|
||||
} fr0_conv_t;
|
||||
|
||||
|
||||
static int init_param_fr( void *port, int p, int hint)
|
||||
int frei0r_get_param_f( void *port, void *dst )
|
||||
{
|
||||
void *instance = NULL;
|
||||
int err = vevo_property_get(port, "frei0r",0,&instance );
|
||||
if( err != VEVO_NO_ERROR )
|
||||
return 0;
|
||||
|
||||
int np = 0;
|
||||
err = vevo_property_get(port, "num_params",0,&np);
|
||||
if( err != VEVO_NO_ERROR || np == 0 )
|
||||
return 0;
|
||||
|
||||
int i;
|
||||
for( i = 0;i < np; i ++ ) {
|
||||
char key[20];
|
||||
snprintf(key,sizeof(key),"p%02d",i );
|
||||
void *param = NULL;
|
||||
err = vevo_property_get(port,key,0,¶m);
|
||||
if( err != VEVO_NO_ERROR) continue;
|
||||
|
||||
vevo_property_clone( param, dst, "value", "value");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int frei0r_push_frame_f( void *plugin, char *dir, int seqno, VJFrame *in )
|
||||
{
|
||||
void *instance = NULL;
|
||||
int err = vevo_property_get(plugin, "frei0r",0,&instance );
|
||||
if( err != VEVO_NO_ERROR )
|
||||
return 0;
|
||||
|
||||
int i = 0;
|
||||
if( strcasecmp( dir, "in_channels" ) == 0 )
|
||||
i = 1;
|
||||
else
|
||||
i = 0;
|
||||
|
||||
fr0_conv_t *fr = NULL;
|
||||
err = vevo_property_get(plugin, "HOST_conv",0,&fr);
|
||||
if( err != VEVO_NO_ERROR )
|
||||
return 0;
|
||||
|
||||
if ( i == 1 ) {
|
||||
yuv_convert_and_scale_rgb( fr->in_scaler, in, fr->in[seqno]);
|
||||
}
|
||||
|
||||
if( seqno == 0 && i == 1 ) {
|
||||
fr->last = in;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int init_param_fr( void *port, int p,f0r_param_info_t *info, int hint, int pcount)
|
||||
{
|
||||
void *parameter = vpn( VEVO_FR_PARAM_PORT );
|
||||
int min = 0;
|
||||
int max = 100;
|
||||
int dv = 50;
|
||||
int min[] = { 0,0,0,0};
|
||||
int max[] = { 100,100,100,100 };
|
||||
int dv[] = { 50,50,50,50};
|
||||
int n_values = 0;
|
||||
|
||||
switch(hint)
|
||||
@@ -78,8 +149,8 @@ static int init_param_fr( void *port, int p, int hint)
|
||||
n_values = 1;
|
||||
break;
|
||||
case F0R_PARAM_BOOL:
|
||||
max = 1;
|
||||
dv = 0;
|
||||
max[0] = 1;
|
||||
dv[0] = 0;
|
||||
n_values = 1;
|
||||
break;
|
||||
case F0R_PARAM_COLOR:
|
||||
@@ -96,21 +167,20 @@ static int init_param_fr( void *port, int p, int hint)
|
||||
{
|
||||
int values[n_values];
|
||||
int k;
|
||||
for( k = 0; k < n_values; k ++ ) values[k] = 0;
|
||||
for( k = 0; k < n_values; k ++ ) values[k] = dv[k];
|
||||
vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_INT, n_values, &values );
|
||||
}
|
||||
|
||||
vevo_property_set( parameter, "value", VEVO_ATOM_TYPE_INT, 0, NULL );
|
||||
|
||||
vevo_property_set( parameter, "min", VEVO_ATOM_TYPE_INT,1, &min );
|
||||
vevo_property_set( parameter, "max", VEVO_ATOM_TYPE_INT,1, &max );
|
||||
vevo_property_set( parameter, "default", VEVO_ATOM_TYPE_INT,1, &dv );
|
||||
vevo_property_set( parameter, "name", VEVO_ATOM_TYPE_STRING,1,&(info->name));
|
||||
vevo_property_set( parameter, "min", VEVO_ATOM_TYPE_INT,n_values, (n_values==1? &(min[0]): min) );
|
||||
vevo_property_set( parameter, "max", VEVO_ATOM_TYPE_INT,n_values, (n_values==1? &(max[0]):max) );
|
||||
vevo_property_set( parameter, "default", VEVO_ATOM_TYPE_INT,n_values, (n_values==1?&dv[0]: dv) );
|
||||
vevo_property_set( parameter, "hint", VEVO_ATOM_TYPE_INT,1, &hint );
|
||||
|
||||
vevo_property_set( parameter, "seqno", VEVO_ATOM_TYPE_INT,1,&pcount);
|
||||
|
||||
char key[20];
|
||||
snprintf(key,20, "p%02d", p );
|
||||
vevo_property_set( port, key, VEVO_ATOM_TYPE_VOIDPTR, 1, ¶meter );
|
||||
vevo_property_set( port, key, VEVO_ATOM_TYPE_PORTPTR, 1, ¶meter );
|
||||
|
||||
return n_values;
|
||||
}
|
||||
@@ -149,14 +219,13 @@ void* deal_with_fr( void *handle, char *name)
|
||||
vpf( port );
|
||||
return NULL;
|
||||
}
|
||||
//@ gamble
|
||||
|
||||
void *f0r_construct = dlsym( handle, "f0r_construct" );
|
||||
void *f0r_destruct = dlsym( handle, "f0r_destruct" );
|
||||
void *processf = dlsym( handle, "f0r_update" );
|
||||
// void *processm = dlsym( handle, "f0r_update2" );
|
||||
void *processm = dlsym( handle, "f0r_update2" );
|
||||
void *set_params = dlsym( handle, "f0r_set_param_value" );
|
||||
|
||||
|
||||
vevo_property_set( port, "handle", VEVO_ATOM_TYPE_VOIDPTR,1, &handle );
|
||||
vevo_property_set( port, "init", VEVO_ATOM_TYPE_VOIDPTR, 1, &f0r_init );
|
||||
vevo_property_set( port, "deinit", VEVO_ATOM_TYPE_VOIDPTR, 1, &f0r_deinit );
|
||||
@@ -164,9 +233,14 @@ void* deal_with_fr( void *handle, char *name)
|
||||
vevo_property_set( port, "parameters", VEVO_ATOM_TYPE_VOIDPTR, 1, &f0r_param );
|
||||
vevo_property_set( port, "construct", VEVO_ATOM_TYPE_VOIDPTR, 1, &f0r_construct );
|
||||
vevo_property_set( port, "destruct", VEVO_ATOM_TYPE_VOIDPTR, 1, &f0r_destruct );
|
||||
vevo_property_set( port, "process", VEVO_ATOM_TYPE_VOIDPTR, 1, &processf);
|
||||
// vevo_property_set( port, "process_mix", VEVO_ATOM_TYPE_VOIDPTR, 1, &processm);
|
||||
vevo_property_set( port, "set_params", VEVO_ATOM_TYPE_VOIDPTR,1,&set_params);
|
||||
|
||||
if( processf != NULL)
|
||||
vevo_property_set( port, "process", VEVO_ATOM_TYPE_VOIDPTR, 1, &processf);
|
||||
|
||||
if( processm != NULL )
|
||||
vevo_property_set( port, "process_mix", VEVO_ATOM_TYPE_VOIDPTR, 1, &processm);
|
||||
if( set_params != NULL )
|
||||
vevo_property_set( port, "set_params", VEVO_ATOM_TYPE_VOIDPTR,1,&set_params);
|
||||
|
||||
f0r_plugin_info_t finfo;
|
||||
f0r_param_info_t pinfo;
|
||||
@@ -191,148 +265,344 @@ void* deal_with_fr( void *handle, char *name)
|
||||
return NULL;
|
||||
}
|
||||
int extra = 0;
|
||||
//@ fixme
|
||||
// if( finfo.plugin_type == F0R_PLUGIN_TYPE_MIXER2 )
|
||||
// extra = 1;
|
||||
int n_inputs = 0;
|
||||
if( finfo.plugin_type == F0R_PLUGIN_TYPE_MIXER2 ) {
|
||||
extra = 1;
|
||||
n_inputs = 2;
|
||||
} else if ( finfo.plugin_type == F0R_PLUGIN_TYPE_FILTER ) {
|
||||
extra = 0;
|
||||
n_inputs = 1;
|
||||
} else {
|
||||
//@ frei0r "supports" source plugins,
|
||||
//@ but our sources are samples, so skip them.
|
||||
veejay_msg(0, "Frei0r plugin type %d not supported.", finfo.plugin_type );
|
||||
(*f0r_deinit)();
|
||||
vpf(port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//@ cheap check for insane frei0r plugins
|
||||
if( (finfo.plugin_type == F0R_PLUGIN_TYPE_FILTER && processf == NULL) ||
|
||||
(finfo.plugin_type == F0R_PLUGIN_TYPE_MIXER2 && processm == NULL) ) {
|
||||
veejay_msg(0, "Frei0r plugin %s behaves badly",name);
|
||||
(*f0r_deinit)();
|
||||
vpf(port);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//@ bang, if plug behaves badly. veejay crashes. is it blacklisted?
|
||||
|
||||
//@FIXME: blacklist
|
||||
|
||||
int n_params = finfo.num_params;
|
||||
int r_params = 0;
|
||||
int p = 0;
|
||||
|
||||
if( set_params == NULL )
|
||||
n_params = 0; // lol
|
||||
|
||||
for ( p = 0; p < n_params; p ++ )
|
||||
{
|
||||
(*f0r_param)(&pinfo,p);
|
||||
r_params += init_param_fr( port, p, pinfo.type );
|
||||
|
||||
int fr_params = init_param_fr(port,p,&pinfo,pinfo.type,p);
|
||||
|
||||
|
||||
r_params += fr_params;
|
||||
}
|
||||
|
||||
if( r_params > 8 )
|
||||
if( r_params > 8 ) {
|
||||
veejay_msg(0, "Maximum parameter count reached, allowing %d/%d parameters.",
|
||||
r_params,n_params);
|
||||
r_params = 8;
|
||||
}
|
||||
|
||||
char *plug_name = strdup( finfo.name );
|
||||
vevo_property_set( port, "n_params", VEVO_ATOM_TYPE_INT, 1, &r_params );
|
||||
vevo_property_set( port, "f0r_p", VEVO_ATOM_TYPE_INT,1, &n_params );
|
||||
char tmp_name[256];
|
||||
snprintf(tmp_name, sizeof(tmp_name), "frei0r %s",finfo.name );
|
||||
|
||||
char *plug_name = strdup(tmp_name);
|
||||
|
||||
vevo_property_set( port, "num_params", VEVO_ATOM_TYPE_INT, 1, &r_params );
|
||||
vevo_property_set( port, "name", VEVO_ATOM_TYPE_STRING,1, &plug_name );
|
||||
vevo_property_set( port, "mixer", VEVO_ATOM_TYPE_INT,1, &extra );
|
||||
vevo_property_set( port, "HOST_plugin_type", VEVO_ATOM_TYPE_INT,1,&frei0r_signature_);
|
||||
/* vevo_property_set( port, "HOST_plugin_param_f", VEVO_ATOM_TYPE_VOIDPTR, 1, &frei0r_plug_param_f);
|
||||
vevo_property_set( port, "HOST_plugin_push_f", VEVO_ATOM_TYPE_VOIDPTR,1,&frei0r_push_frame_f);
|
||||
vevo_property_set( port, "HOST_plugin_process_f", VEVO_ATOM_TYPE_VOIDPTR,1,&frei0r_process_frame_f);*/
|
||||
vevo_property_set( port, "num_inputs", VEVO_ATOM_TYPE_INT,1, &n_inputs );
|
||||
|
||||
int pixfmt = PIX_FMT_RGB24;
|
||||
free(plug_name);
|
||||
|
||||
switch( finfo.color_model ) {
|
||||
case F0R_COLOR_MODEL_BGRA8888:
|
||||
pixfmt = PIX_FMT_BGRA;
|
||||
break;
|
||||
case F0R_COLOR_MODEL_RGBA8888:
|
||||
case F0R_COLOR_MODEL_PACKED32: //lol
|
||||
pixfmt = PIX_FMT_RGBA;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
vevo_property_set( port, "format", VEVO_ATOM_TYPE_INT,1,&pixfmt);
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
|
||||
int frei0r_plug_init( void *plugin , int w, int h )
|
||||
void frei0r_plug_deinit( void *plugin )
|
||||
{
|
||||
int state = 0;
|
||||
|
||||
void *parent = NULL;
|
||||
int err = vevo_property_get( plugin, "parent",0, &parent );
|
||||
if( err != VEVO_NO_ERROR ) {
|
||||
veejay_msg(0,"Unable to free plugin.");
|
||||
return;
|
||||
}
|
||||
|
||||
f0r_destruct_f base;
|
||||
vevo_property_get( parent, "destruct", 0, &base);
|
||||
f0r_instance_t instance;
|
||||
vevo_property_get( plugin, "frei0r", 0, &instance );
|
||||
(*base)(instance);
|
||||
|
||||
|
||||
fr0_conv_t *fr = NULL;
|
||||
err = vevo_property_get( plugin, "HOST_conv",0,&fr);
|
||||
if( fr && err == VEVO_NO_ERROR ){
|
||||
if(fr->buf) free(fr->buf);
|
||||
if(fr->in[0]) free(fr->in[0]);
|
||||
if(fr->in[1]) free(fr->in[1]);
|
||||
if(fr->in[2]) free(fr->in[2]);
|
||||
if(fr->out) free(fr->out);
|
||||
yuv_free_swscaler( fr->in_scaler );
|
||||
yuv_free_swscaler( fr->out_scaler );
|
||||
free(fr);
|
||||
fr = NULL;
|
||||
}
|
||||
|
||||
vpf(plugin);
|
||||
}
|
||||
|
||||
|
||||
void *frei0r_plug_init( void *plugin , int w, int h, int pf )
|
||||
{
|
||||
void *instance = vpn( VEVO_ANONYMOUS_PORT );
|
||||
f0r_construct_f base;
|
||||
vevo_property_get( plugin, "construct", 0, &base);
|
||||
f0r_instance_t k = (*base)(w,h);
|
||||
vevo_property_set(plugin, "instance", VEVO_ATOM_TYPE_VOIDPTR, 1, &k);
|
||||
if( k == NULL )
|
||||
{
|
||||
veejay_msg(VEEJAY_MSG_ERROR, "Unable to initialize plugin");
|
||||
// store instance running status
|
||||
int state = 1;
|
||||
vevo_property_set( plugin, "running", VEVO_ATOM_TYPE_INT, 1, &state );
|
||||
return state;
|
||||
}
|
||||
vpf(instance);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void frei0r_plug_deinit( void *plugin, int w, int h )
|
||||
{
|
||||
int state = 0;
|
||||
vevo_property_get( plugin, "state", 0, &state );
|
||||
if(!state)
|
||||
return;
|
||||
vevo_property_set(instance, "frei0r", VEVO_ATOM_TYPE_PORTPTR, 1, &k);
|
||||
|
||||
vevo_property_set( instance, "parent", VEVO_ATOM_TYPE_VOIDPTR, 1,&plugin);
|
||||
|
||||
f0r_destruct_f base;
|
||||
vevo_property_get( plugin, "destruct", 0, &base);
|
||||
f0r_instance_t instance;
|
||||
vevo_property_get( plugin, "instance", 0, &instance );
|
||||
(*base)(instance);
|
||||
|
||||
generic_push_channel_f gpc = frei0r_push_frame_f;
|
||||
generic_process_f gpf = frei0r_process_frame_f;
|
||||
generic_push_parameter_f gpp = frei0r_plug_param_f;
|
||||
generic_deinit_f gdd = frei0r_plug_deinit;
|
||||
|
||||
int n = 0;
|
||||
vevo_property_get( plugin, "num_inputs", 0,&n);
|
||||
if( n > 1 )
|
||||
gpf = frei0r_process_frame_ext_f;
|
||||
|
||||
vevo_property_set( instance, "HOST_plugin_param_f", VEVO_ATOM_TYPE_VOIDPTR, 1, &gpp);
|
||||
vevo_property_set( instance, "HOST_plugin_push_f", VEVO_ATOM_TYPE_VOIDPTR,1,&gpc);
|
||||
vevo_property_set( instance, "HOST_plugin_process_f", VEVO_ATOM_TYPE_VOIDPTR,1,&gpf);
|
||||
vevo_property_set( instance, "HOST_plugin_deinit_f", VEVO_ATOM_TYPE_VOIDPTR,1,&gdd);
|
||||
|
||||
int frfmt = 0;
|
||||
vevo_property_get( plugin, "format",0,&frfmt );
|
||||
|
||||
sws_template templ;
|
||||
memset(&templ,0,sizeof(sws_template));
|
||||
templ.flags = yuv_which_scaler();
|
||||
|
||||
fr0_conv_t *fr = (fr0_conv_t*) vj_calloc(sizeof(fr0_conv_t));
|
||||
int i;
|
||||
fr->buf = (uint8_t*) vj_calloc(sizeof(uint8_t) * w * h * 4 * (2+n));
|
||||
uint8_t *bufx = fr->buf;
|
||||
for( i = 0; i < (n+1); i ++ ){
|
||||
fr->in[i] = yuv_rgb_template(bufx, w,h, frfmt );
|
||||
bufx += (w*h*4);
|
||||
}
|
||||
fr->out = yuv_yuv_template(bufx, bufx+(w*h), bufx+(w*h*2), w,h,pf );
|
||||
fr->out_scaler = yuv_init_swscaler( fr->in[0], fr->out, &templ, yuv_sws_get_cpu_flags()); // rgb -> yuv
|
||||
fr->in_scaler = yuv_init_swscaler( fr->out,fr->in[0], &templ, yuv_sws_get_cpu_flags()); // yuv -> rgb
|
||||
|
||||
|
||||
void *frptr = (void*) fr;
|
||||
vevo_property_set( instance, "HOST_conv", VEVO_ATOM_TYPE_VOIDPTR,1,&frptr);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void frei0r_plug_free( void *plugin )
|
||||
{
|
||||
int n = 0;
|
||||
//@@ clear parameters
|
||||
//FIXME: not used
|
||||
f0r_deinit_f base;
|
||||
vevo_property_get( plugin, "deinit", 0, &base);
|
||||
(*base)();
|
||||
vevo_property_get( plugin, "f0r_p", 0, &n );
|
||||
}
|
||||
|
||||
int frei0r_plug_process( void *plugin, void *buffer, void *out_buffer )
|
||||
int frei0r_process_frame_f( void *plugin )
|
||||
{
|
||||
void *parent = NULL;
|
||||
int err = vevo_property_get( plugin, "parent",0,&parent );
|
||||
if( err != VEVO_NO_ERROR ) {
|
||||
veejay_msg(0, "unable to process frei0r plugin.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
f0r_update_f base;
|
||||
vevo_property_get( plugin, "process", 0, &base );
|
||||
vevo_property_get( parent, "process", 0, &base );
|
||||
f0r_instance_t instance;
|
||||
vevo_property_get( plugin, "instance",0, &instance );
|
||||
(*base)( instance, rand(), buffer, out_buffer );
|
||||
|
||||
vevo_property_get( plugin, "frei0r",0, &instance );
|
||||
|
||||
|
||||
fr0_conv_t *fr = NULL;
|
||||
err = vevo_property_get(plugin, "HOST_conv",0,&fr);
|
||||
if( err != VEVO_NO_ERROR )
|
||||
return 0;
|
||||
|
||||
|
||||
(*base)( instance, rand(), fr->in[0]->data[0],fr->in[1]->data[0] );
|
||||
|
||||
VJFrame *dst = fr->in[0];
|
||||
if( fr->last )
|
||||
dst = fr->last;
|
||||
|
||||
yuv_convert_and_scale_from_rgb( fr->out_scaler, fr->in[1], dst );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int frei0r_process_frame_ext_f(void *plugin)
|
||||
{
|
||||
|
||||
void *parent = NULL;
|
||||
int err = vevo_property_get( plugin, "parent",0,&parent );
|
||||
if( err != VEVO_NO_ERROR ) {
|
||||
veejay_msg(0, "unable to process frei0r plugin.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
f0r_update2_f base;
|
||||
vevo_property_get( parent, "process_mix", 0, &base );
|
||||
f0r_instance_t instance;
|
||||
|
||||
vevo_property_get( plugin, "frei0r",0, &instance );
|
||||
fr0_conv_t *fr = NULL;
|
||||
err = vevo_property_get(plugin, "HOST_conv",0,&fr);
|
||||
if( err != VEVO_NO_ERROR )
|
||||
return 0;
|
||||
|
||||
|
||||
(*base)( instance, rand(), fr->in[0]->data[0],fr->in[1]->data[0],NULL,fr->in[2]->data[0] );
|
||||
|
||||
VJFrame *dst = fr->in[0];
|
||||
if( fr->last )
|
||||
dst = fr->last;
|
||||
|
||||
yuv_convert_and_scale_from_rgb( fr->out_scaler, fr->in[2], dst );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void frei0r_plug_param_f( void *port, int seq_no, void *dargs )
|
||||
{
|
||||
void *plugin = NULL;
|
||||
int err = vevo_property_get(port, "frei0r",0,&plugin);
|
||||
if( err != VEVO_NO_ERROR ) {
|
||||
return;
|
||||
}
|
||||
f0r_set_param_value_f q;
|
||||
f0r_get_param_info_f inf;
|
||||
f0r_param_position_t pos;
|
||||
f0r_param_color_t col;
|
||||
f0r_param_t *fparam = NULL;
|
||||
|
||||
void *parent = NULL;
|
||||
err = vevo_property_get(port, "parent",0,&parent);
|
||||
if( err != VEVO_NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
double value = 0.0;
|
||||
int *args = (int*) dargs;
|
||||
|
||||
err = vevo_property_get( parent, "set_params", 0, &q);
|
||||
|
||||
if( err != VEVO_NO_ERROR ) {
|
||||
veejay_msg(0, "dont know how to set parameter %d",seq_no);
|
||||
return;
|
||||
}
|
||||
|
||||
f0r_param_info_t finfo;
|
||||
|
||||
if( vevo_property_get( parent, "parameters",0,&inf ) != VEVO_NO_ERROR )
|
||||
return;
|
||||
|
||||
(*inf)( &finfo, seq_no );
|
||||
|
||||
char key[20];
|
||||
sprintf(key, "p%02d", seq_no );
|
||||
void *param = NULL;
|
||||
|
||||
if(vevo_property_get( parent, key, 0, ¶m )!=VEVO_NO_ERROR)
|
||||
param = NULL;
|
||||
|
||||
switch( finfo.type ) {
|
||||
case F0R_PARAM_BOOL:
|
||||
value = ( (int) args[0]);
|
||||
fparam = &value;
|
||||
if(param) vevo_property_set( param, "value", VEVO_ATOM_TYPE_INT, 1,&args[0]);
|
||||
break;
|
||||
case F0R_PARAM_DOUBLE:
|
||||
value = ((double)args[0]*0.01);
|
||||
fparam=&value;
|
||||
if(param) vevo_property_set( param,"value", VEVO_ATOM_TYPE_INT,1,&args[0]);
|
||||
break;
|
||||
case F0R_PARAM_POSITION:
|
||||
pos.x = ( (float) args[0] * 0.01);
|
||||
pos.y = ( (float) args[1] * 0.01);
|
||||
fparam = &pos;
|
||||
if(param) vevo_property_set( param,"value",VEVO_ATOM_TYPE_INT,2, args );
|
||||
break;
|
||||
case F0R_PARAM_COLOR:
|
||||
col.r = ( (double) args[0] * 0.01);
|
||||
col.g = ( (double) args[1] * 0.01);
|
||||
col.b = ( (double) args[2] * 0.01);
|
||||
fparam = &col;
|
||||
if(param) vevo_property_set( param, "value", VEVO_ATOM_TYPE_INT,3, args);
|
||||
break;
|
||||
default:
|
||||
veejay_msg(VEEJAY_MSG_DEBUG, "Parameter type %d not supported.",finfo.type);
|
||||
break;
|
||||
}
|
||||
|
||||
if( fparam && param ) {
|
||||
int fr0_seq_no = 0;
|
||||
vevo_property_get(param, "seqno", 0,&fr0_seq_no);
|
||||
(*q)( plugin, fparam, seq_no );
|
||||
}
|
||||
}
|
||||
|
||||
void frei0r_plug_control( void *port, int *args )
|
||||
{
|
||||
int p,num_params=0;
|
||||
vevo_property_get( port, "n_params", 0, &num_params);
|
||||
int v_params = 0;
|
||||
|
||||
f0r_set_param_value_f q;
|
||||
|
||||
vevo_property_get( port, "set_params", 0, &q);
|
||||
for( p = 0; p < num_params; p ++ )
|
||||
{
|
||||
char key[20];
|
||||
sprintf(key, "p%02d", p );
|
||||
void *param = NULL;
|
||||
vevo_property_get( port, key, 0, ¶m );
|
||||
if( param ) continue;
|
||||
|
||||
int n = vevo_property_element_size( param, "value", p );
|
||||
|
||||
f0r_param_position_t pos;
|
||||
f0r_param_color_t col;
|
||||
|
||||
double value = 0.0;
|
||||
int instance = 0;
|
||||
vevo_property_get( port, "instance", 0, &instance );
|
||||
int max = 0;
|
||||
vevo_property_get( param, "max",0,&max);
|
||||
|
||||
void *fparam = NULL;
|
||||
switch(n)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
value = ( (double) args[v_params] * (max == 100 ? 0.01: 1));
|
||||
fparam = &value;
|
||||
v_params ++;
|
||||
break;
|
||||
case 2:
|
||||
pos.x = ( (double) args[v_params] * 0.01 );
|
||||
v_params ++;
|
||||
pos.y = ( (double) args[v_params] * 0.01 );
|
||||
v_params ++;
|
||||
fparam = &pos;
|
||||
break;
|
||||
case 3:
|
||||
col.r = ( (double) args[v_params] * 0.01 );
|
||||
v_params ++;
|
||||
col.g = ( (double) args[v_params] * 0.01 );
|
||||
v_params ++;
|
||||
col.b = ( (double) args[v_params] * 0.01 );
|
||||
v_params ++;
|
||||
fparam = &col;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( fparam )
|
||||
(*q)( instance, fparam, p );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void frei0r_plug_process_ext( void *plugin, void *in0, void *in1, void *out)
|
||||
{
|
||||
f0r_update2_f base;
|
||||
vevo_property_get( plugin, "process_mix", 0, &base );
|
||||
f0r_instance_t instance;
|
||||
vevo_property_get( plugin, "instance",0, &instance );
|
||||
(*base)( instance, rand(), in0, in1, NULL, out );
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void* deal_with_fr( void *handle, char *name );
|
||||
|
||||
int frei0r_plug_init( void *plugin , int w, int h );
|
||||
void* frei0r_plug_init( void *plugin , int w, int h,int pf );
|
||||
|
||||
void frei0r_plug_deinit( void *plugin );
|
||||
|
||||
@@ -15,4 +15,5 @@ void frei0r_plug_control( void *plugin, int *args );
|
||||
|
||||
void frei0r_plug_process_ext( void *plugin, void *in1, void *in2, void *out);
|
||||
|
||||
int init_frei0r(int w, int h, int pf);
|
||||
#endif
|
||||
|
||||
@@ -58,9 +58,6 @@
|
||||
static vevo_port_t **index_map_ = NULL;
|
||||
static vevo_port_t *illegal_plugins_ =NULL;
|
||||
static int index_ = 0;
|
||||
static void *buffer_ = NULL;
|
||||
static void *buffer2_ = NULL;
|
||||
static void *buffer_b_ = NULL;
|
||||
static int base_width_ =0;
|
||||
static int base_height_ =0;
|
||||
static int n_ff_ = 0;
|
||||
@@ -108,7 +105,7 @@ static void *instantiate_plugin( void *plugin, int w , int h )
|
||||
return freeframe_plug_init( plugin,w,h);
|
||||
break;
|
||||
case VEVO_PLUG_FR:
|
||||
return frei0r_plug_init( plugin,w,h );
|
||||
return frei0r_plug_init( plugin,w,h,base_fmt_ );
|
||||
break;
|
||||
default:
|
||||
#ifdef STRICT_CHECKING
|
||||
@@ -341,23 +338,10 @@ static int scan_plugins()
|
||||
void plug_sys_free(void)
|
||||
{
|
||||
free_plugins();
|
||||
if( buffer_ )
|
||||
free( buffer_ );
|
||||
if( buffer2_ )
|
||||
free( buffer2_ );
|
||||
if( buffer_b_)
|
||||
free( buffer_b_ );
|
||||
}
|
||||
|
||||
void plug_sys_init( int fmt, int w, int h )
|
||||
{
|
||||
buffer_ = (void*) vj_malloc( w * h * 4);
|
||||
memset( buffer_, 0, w * h * 4);
|
||||
buffer2_ = (void*) vj_malloc( w * h * 4);
|
||||
memset( buffer2_, 0, w * h * 4);
|
||||
buffer_b_ = (void*) vj_malloc( w * h * 4);
|
||||
memset( buffer_b_, 0, w * h * 4);
|
||||
|
||||
base_width_ = w;
|
||||
base_height_ = h;
|
||||
|
||||
@@ -411,6 +395,9 @@ int plug_sys_detect_plugins(void)
|
||||
veejay_msg(VEEJAY_MSG_INFO, "\thttp://www.piksel.org/frei0r");
|
||||
veejay_msg(VEEJAY_MSG_INFO, "\tFound %d frei0r %s",
|
||||
n_fr_ , n_fr_ == 1 ? "plugin" : "plugins" );
|
||||
|
||||
veejay_msg(VEEJAY_MSG_WARNING, "\tPerformance penalty for frei0r: native -> RGB -> native.");
|
||||
|
||||
veejay_msg(VEEJAY_MSG_INFO, "\tLivido - (Linux) Video Dynamic Objects" );
|
||||
veejay_msg(VEEJAY_MSG_INFO, "\t(C) Copyright 2005 Gabriel 'Salsaman' Finch, Niels Elburg, Dennis 'Jaromil' Rojo");
|
||||
veejay_msg(VEEJAY_MSG_INFO, "\t Daniel Fischer, Martin Bayer, Kentaro Fukuchi and Andraz Tori");
|
||||
@@ -477,7 +464,7 @@ void plug_set_parameter( void *instance, int seq_num,int n_elements,void *value
|
||||
#ifdef STRICT_CHECKING
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
veejay_msg(0, "HOST_plugin_param_f missing!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -842,10 +829,9 @@ void plug_push_frame( void *instance, int out, int seq_num, void *frame_info )
|
||||
#endif
|
||||
generic_push_channel_f gpu;
|
||||
int error = vevo_property_get( instance, "HOST_plugin_push_f", 0, &gpu );
|
||||
#ifdef STRICT_CHECKING
|
||||
assert( error == 0 );
|
||||
#endif
|
||||
(*gpu)( instance, (out ? "out_channels" : "in_channels" ), seq_num, frame );
|
||||
|
||||
if( error == VEVO_NO_ERROR )
|
||||
(*gpu)( instance, (out ? "out_channels" : "in_channels" ), seq_num, frame );
|
||||
}
|
||||
|
||||
|
||||
@@ -908,7 +894,7 @@ vj_effect *plug_get_plugin( int fx_id ) {
|
||||
size_t name_len = vevo_property_element_size( port, "name", 0);
|
||||
vje->description = (char*) vj_calloc(name_len);
|
||||
vevo_property_get( port, "name", 0 , &(vje->description));
|
||||
vevo_property_get( port, "n_params", 0, &(vje->num_params));
|
||||
vevo_property_get( port, "num_params", 0, &(vje->num_params));
|
||||
vevo_property_get( port, "mixer", 0, &(vje->extra_frame));
|
||||
|
||||
if( vje->num_params > 0 ) {
|
||||
@@ -925,12 +911,12 @@ vj_effect *plug_get_plugin( int fx_id ) {
|
||||
int valid_p = 0;
|
||||
char **param_descr = NULL;
|
||||
if( vje->num_params > 0 )
|
||||
param_descr = (char**) vj_malloc(sizeof(char*) * vje->num_params );
|
||||
param_descr = (char**) vj_calloc(sizeof(char*) * (vje->num_params+1) );
|
||||
|
||||
for( k = 0; k < vje->num_params;k++ )
|
||||
{
|
||||
char key[20];
|
||||
sprintf(key, "p%d", k );
|
||||
sprintf(key, "p%02d", k );
|
||||
void *parameter = NULL;
|
||||
vevo_property_get( port, key, 0, ¶meter );
|
||||
if(parameter)
|
||||
@@ -938,11 +924,12 @@ vj_effect *plug_get_plugin( int fx_id ) {
|
||||
vevo_property_get( parameter, "min", 0, &(vje->limits[0][k]));
|
||||
vevo_property_get( parameter, "max", 0, &(vje->limits[1][k]));
|
||||
vevo_property_get( parameter, "default", 0,&(vje->defaults[k]));
|
||||
param_descr[valid_p] = strdup( "Number" );
|
||||
param_descr[valid_p] = vevo_property_get_string(parameter,"name");
|
||||
if(param_descr[valid_p]==NULL)
|
||||
param_descr[valid_p] = strdup( "Number" );
|
||||
valid_p ++;
|
||||
}
|
||||
}
|
||||
vevo_property_set( port, "n_params",VEVO_ATOM_TYPE_INT, 1,&valid_p);
|
||||
vje->num_params = valid_p;
|
||||
vje->param_description = param_descr;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ void veejay_msg(int type, const char format[], ...)
|
||||
// parse arguments
|
||||
va_start(args, format);
|
||||
vsnprintf(buf, sizeof(buf) - 1, format, args);
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
gettimeofday( &timenow, NULL );
|
||||
|
||||
timeval_subtract( &timenow, &timenow, &_start_time );
|
||||
@@ -441,6 +441,77 @@ void veejay_msg(int type, const char format[], ...)
|
||||
_message_history.msg[_message_history.w_index ++ ] = strdup(sline);
|
||||
}*/
|
||||
}
|
||||
#else
|
||||
if(_color_level)
|
||||
{
|
||||
switch (type) {
|
||||
case 2: //info
|
||||
sprintf(prefix, "%sI: ", TXT_GRE);
|
||||
break;
|
||||
case 1: //warning
|
||||
sprintf(prefix, "%sW: ", TXT_YEL);
|
||||
break;
|
||||
case 0: // error
|
||||
sprintf(prefix, "%sE: ", TXT_RED);
|
||||
break;
|
||||
case 3:
|
||||
line = 1;
|
||||
break;
|
||||
case 4: // debug
|
||||
sprintf(prefix, "%sD: ", TXT_BLU);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!line)
|
||||
fprintf(out,"%s %s %s\n",prefix, buf, TXT_END);
|
||||
else
|
||||
fprintf(out,"%s%s%s", TXT_GRE, buf, TXT_END );
|
||||
/*
|
||||
if( _message_history.w_index < MAX_LINES )
|
||||
{
|
||||
if(type == 3)
|
||||
sprintf(sline, "%s", buf );
|
||||
else
|
||||
sprintf( sline, "%s\n", buf );
|
||||
_message_history.msg[_message_history.w_index ++ ] = strndup(sline,200);
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (type) {
|
||||
case 2: //info
|
||||
sprintf(prefix, "I: ");
|
||||
break;
|
||||
case 1: //warning
|
||||
sprintf(prefix, "W: ");
|
||||
break;
|
||||
case 0: // error
|
||||
sprintf(prefix, "E: ");
|
||||
break;
|
||||
case 3:
|
||||
line = 1;
|
||||
break;
|
||||
case 4: // debug
|
||||
sprintf(prefix, "D: ");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!line)
|
||||
fprintf(out,"%s %s\n", prefix, buf);
|
||||
else
|
||||
fprintf(out,"%s", buf );
|
||||
|
||||
/* if( _message_history.w_index < MAX_LINES )
|
||||
{
|
||||
if(type == 3 )
|
||||
sprintf(sline, "%s", buf );
|
||||
else
|
||||
sprintf(sline, "%s\n", buf );
|
||||
_message_history.msg[_message_history.w_index ++ ] = strdup(sline);
|
||||
}*/
|
||||
}
|
||||
|
||||
#endif
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1156,7 +1156,10 @@ void yuv_convert_and_scale_gray_rgb(void *sws,VJFrame *src, VJFrame *dst)
|
||||
void yuv_convert_and_scale_from_rgb(void *sws , VJFrame *src, VJFrame *dst)
|
||||
{
|
||||
vj_sws *s = (vj_sws*) sws;
|
||||
int src_stride[3] = { src->width*3,0,0};
|
||||
int n = 3;
|
||||
if( src->format == PIX_FMT_RGBA || src->format == PIX_FMT_BGRA )
|
||||
n = 4;
|
||||
int src_stride[3] = { src->width*n,0,0};
|
||||
int dst_stride[3] = { dst->width,dst->uv_width,dst->uv_width };
|
||||
|
||||
sws_scale( s->sws, src->data, src_stride, 0, src->height,
|
||||
@@ -1166,8 +1169,12 @@ void yuv_convert_and_scale_from_rgb(void *sws , VJFrame *src, VJFrame *dst)
|
||||
void yuv_convert_and_scale_rgb(void *sws , VJFrame *src, VJFrame *dst)
|
||||
{
|
||||
vj_sws *s = (vj_sws*) sws;
|
||||
int n = 3;
|
||||
if( dst->format == PIX_FMT_RGBA || dst->format == PIX_FMT_BGRA )
|
||||
n = 4;
|
||||
|
||||
int src_stride[3] = { src->width,src->uv_width,src->uv_width };
|
||||
int dst_stride[3] = { dst->width*3,0,0 };
|
||||
int dst_stride[3] = { dst->width*n,0,0 };
|
||||
|
||||
sws_scale( s->sws, src->data, src_stride, 0, src->height,
|
||||
dst->data, dst_stride );
|
||||
|
||||
@@ -56,8 +56,8 @@ static int override_pix_fmt = 0;
|
||||
static int switch_jpeg = 0;
|
||||
static char override_norm = 'p';
|
||||
static int auto_loop = 0;
|
||||
static int n_slots_ = 4;
|
||||
static int max_mem_ = 30;
|
||||
static int n_slots_ = 0;
|
||||
static int max_mem_ = 0;
|
||||
static int live =0;
|
||||
|
||||
static void CompiledWith()
|
||||
@@ -173,9 +173,9 @@ static void Usage(char *progname)
|
||||
fprintf(stderr,
|
||||
" --map-from-file <num>\tmap N frames to memory\n");
|
||||
fprintf(stderr,
|
||||
" -m/--memory <num>\t\tMaximum memory to use for cache (0=disable, default=30 max=100)\n");
|
||||
" -m/--memory <num>\t\tMaximum memory to use for cache (0=disable, default=0 max=100)\n");
|
||||
fprintf(stderr,
|
||||
" -j/--max_cache <num>\t\tDivide cache memory over N samples (default=4)\n");
|
||||
" -j/--max_cache <num>\t\tDivide cache memory over N samples (default=0)\n");
|
||||
|
||||
fprintf(stderr,
|
||||
" -Y/--yuv [01]\t\t\tForce YCbCr (defaults to YUV)\n");
|
||||
@@ -673,6 +673,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if( vj_el_get_mem_size() == 0 )
|
||||
prepare_cache_line( max_mem_, n_slots_ );
|
||||
|
||||
veejay_check_homedir( info );
|
||||
|
||||
sigsegfault_handler();
|
||||
|
||||
Reference in New Issue
Block a user