char file[ PATH_MAX ];
char servicetype[ 1024 ]="";
struct stat stat_buff;
-
+
switch ( type ) {
case filter_type:
strcpy ( servicetype , "filter" );
default:
strcpy ( servicetype , "" );
};
-
+
snprintf( file, PATH_MAX, "%s/frei0r/%s_%s.yml", mlt_environment( "MLT_DATA" ), servicetype, service_name );
stat(file,&stat_buff);
if (S_ISREG(stat_buff.st_mode)){
return mlt_properties_parse_yaml( file );
}
-
+
void* handle=dlopen(name,RTLD_LAZY);
if (!handle) return NULL;
void (*plginfo)(f0r_plugin_info_t*)=dlsym(handle,"f0r_get_plugin_info");
default:
break;
}
-
+
mlt_properties parameter = mlt_properties_new ( );
mlt_properties_set_data ( metadata , "parameters" , parameter , 0 , ( mlt_destructor )mlt_properties_close, NULL );
mlt_properties tags = mlt_properties_new ( );
mlt_properties_set_data ( metadata , "tags" , tags , 0 , ( mlt_destructor )mlt_properties_close, NULL );
mlt_properties_set ( tags , "0" , "Video" );
-
+
for (j=0;j<info.num_params;j++){
snprintf ( string , sizeof(string), "%d" , j );
mlt_properties pnum = mlt_properties_new ( );
mlt_properties_set ( pnum , "maximum" , "1" );
mlt_properties_set ( pnum , "readonly" , "no" );
}else
+ if ( paraminfo.type == F0R_PARAM_COLOR ){
+ mlt_properties_set ( pnum , "type" , "color" );
+ mlt_properties_set ( pnum , "readonly" , "no" );
+ }else
if ( paraminfo.type == F0R_PARAM_STRING ){
mlt_properties_set ( pnum , "type" , "string" );
mlt_properties_set ( pnum , "readonly" , "no" );
}
static void * load_lib( mlt_profile profile, mlt_service_type type , void* handle){
-
+
int i=0;
void (*f0r_get_plugin_info)(f0r_plugin_info_t*),
*f0r_construct , *f0r_update , *f0r_destruct,
(*f0r_get_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index),
(*f0r_update2) (f0r_instance_t instance, double time, const uint32_t* inframe1,
const uint32_t* inframe2,const uint32_t* inframe3, uint32_t* outframe);
-
- if ( ( f0r_construct = dlsym(handle, "f0r_construct") ) &&
- (f0r_update = dlsym(handle,"f0r_update") ) &&
- (f0r_destruct = dlsym(handle,"f0r_destruct") ) &&
- (f0r_get_plugin_info = dlsym(handle,"f0r_get_plugin_info") ) &&
- (f0r_get_param_info = dlsym(handle,"f0r_get_param_info") ) &&
+
+ if ( ( f0r_construct = dlsym(handle, "f0r_construct") ) &&
+ (f0r_update = dlsym(handle,"f0r_update") ) &&
+ (f0r_destruct = dlsym(handle,"f0r_destruct") ) &&
+ (f0r_get_plugin_info = dlsym(handle,"f0r_get_plugin_info") ) &&
+ (f0r_get_param_info = dlsym(handle,"f0r_get_param_info") ) &&
(f0r_set_param_value= dlsym(handle,"f0r_set_param_value" ) ) &&
(f0r_get_param_value= dlsym(handle,"f0r_get_param_value" ) ) &&
(f0r_init= dlsym(handle,"f0r_init" ) ) &&
- (f0r_deinit= dlsym(handle,"f0r_deinit" ) )
+ (f0r_deinit= dlsym(handle,"f0r_deinit" ) )
){
-
+
f0r_update2=dlsym(handle,"f0r_update2");
-
+
f0r_plugin_info_t info;
f0r_get_plugin_info(&info);
-
- void* ret=NULL;
+
+ void* ret=NULL;
mlt_properties properties=NULL;
-
+
if (type == filter_type && info.plugin_type == F0R_PLUGIN_TYPE_FILTER ){
mlt_filter this = mlt_filter_new( );
if ( this != NULL )
{
this->process = filter_process;
- this->close = filter_close;
+ this->close = filter_close;
f0r_init();
properties=MLT_FILTER_PROPERTIES ( this );
-
+
for (i=0;i<info.num_params;i++){
f0r_param_info_t pinfo;
f0r_get_param_info(&pinfo,i);
-
+
}
-
+
ret=this;
}
}else if (type == transition_type && info.plugin_type == F0R_PLUGIN_TYPE_MIXER2){
mlt_properties_set_data(properties, "f0r_get_param_info", f0r_get_param_info , sizeof(void*),NULL,NULL);
mlt_properties_set_data(properties, "f0r_set_param_value", f0r_set_param_value , sizeof(void*),NULL,NULL);
mlt_properties_set_data(properties, "f0r_get_param_value", f0r_get_param_value , sizeof(void*),NULL,NULL);
-
-
+
+
return ret;
}else{
printf("some was wrong\n");
void* ret=NULL;
while (dircount--){
char soname[1024]="";
-
+
char *save_firstptr = NULL;
char *firstname=strtok_r(strdup(id),".",&save_firstptr);
-
+
firstname=strtok_r(NULL,".",&save_firstptr);
sprintf(soname,"%s/%s.so", mlt_tokeniser_get_string( tokeniser , dircount ) , firstname );
if (firstname){
-
+
void* handle=dlopen(soname,RTLD_LAZY);
-
+
if (handle ){
ret=load_lib ( profile , type , handle );
}else{
getenv("MLT_FREI0R_PLUGIN_PATH") ? getenv("MLT_FREI0R_PLUGIN_PATH") : FREI0R_PLUGIN_PATH,
":"
);
-
+
while (dircount--){
-
+
mlt_properties direntries = mlt_properties_new();
char* dirname = mlt_tokeniser_get_string ( tokeniser , dircount ) ;
mlt_properties_dir_list(direntries, dirname ,"*.so",1);
-
+
for (i=0;i<mlt_properties_count(direntries);i++){
- char* name=mlt_properties_get_value(direntries,i);
+ char* name=mlt_properties_get_value(direntries,i);
char* shortname=name+strlen(dirname)+1;
char fname[1024]="";
-
+
strcat(fname,dirname);
strcat(fname,shortname);
-
+
char *save_firstptr = NULL;
char pluginname[1024]="frei0r.";
char* firstname = strtok_r ( shortname , "." , &save_firstptr );
strcat(pluginname,firstname);
-
+
void* handle=dlopen(strcat(name,".so"),RTLD_LAZY);
if (handle){
void (*plginfo)(f0r_plugin_info_t*)=dlsym(handle,"f0r_get_plugin_info");
-
+
if (plginfo){
f0r_plugin_info_t info;
plginfo(&info);
-
+
if (firstname && info.plugin_type==F0R_PLUGIN_TYPE_FILTER){
MLT_REGISTER( filter_type, pluginname, create_frei0r_item );
MLT_REGISTER_METADATA( filter_type, pluginname, fill_param_info, strdup(name) );
#include "frei0r_helper.h"
#include <frei0r.h>
#include <string.h>
+#include <stdlib.h>
+
+
+static void parse_color( char *color, f0r_param_color_t *fcolor )
+{
+ unsigned int temp = strtoul( color, &color, 0 );
+ if ( strlen( color ) > 6 )
+ temp >>= 8;
+ fcolor->r = ( temp >> 16 ) & 0xff;
+ fcolor->r /= 255;
+ fcolor->g = ( temp >> 8 ) & 0xff;
+ fcolor->g /= 255;
+ fcolor->b = ( temp >> 0 ) & 0xff;
+ fcolor->b /= 255;
+}
+
int process_frei0r_item( mlt_service_type type, double position , mlt_properties prop , mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ){
f0r_instance_t ( *f0r_construct ) ( unsigned int , unsigned int ) = mlt_properties_get_data( prop , "f0r_construct" ,NULL);
void (*f0r_update)(f0r_instance_t instance, double time, const uint32_t* inframe, uint32_t* outframe)=mlt_properties_get_data( prop , "f0r_update" ,NULL);
void (*f0r_destruct)(f0r_instance_t instance)=mlt_properties_get_data( prop , "f0r_destruct" ,NULL);
-
+
void (*f0r_get_plugin_info)(f0r_plugin_info_t*)=mlt_properties_get_data( prop, "f0r_get_plugin_info" ,NULL);
void (*f0r_get_param_info)(f0r_param_info_t* info, int param_index)=mlt_properties_get_data( prop , "f0r_get_param_info" ,NULL);
void (*f0r_set_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index)=mlt_properties_get_data( prop , "f0r_set_param_value" ,NULL);
void (*f0r_get_param_value)(f0r_instance_t instance, f0r_param_t param, int param_index)=mlt_properties_get_data( prop , "f0r_get_param_value" ,NULL);
void (*f0r_update2) (f0r_instance_t instance, double time,
const uint32_t* inframe1,const uint32_t* inframe2,const uint32_t* inframe3,
- uint32_t* outframe)=mlt_properties_get_data( prop , "f0r_update2" ,NULL);
-
-
+ uint32_t* outframe)=mlt_properties_get_data( prop , "f0r_update2" ,NULL);
+
+
//use as name the width and height
f0r_instance_t inst;
char ctorname[1024]="";
sprintf(ctorname,"ctor-%dx%d",*width,*height);
-
+
void* neu=mlt_properties_get_data( prop , ctorname ,NULL );
if (!f0r_construct){
//printf("no ctor\n");
mlt_geometry geom=mlt_geometry_init();
struct mlt_geometry_item_s item;
//set param if found
-
+
double t=0.0;
f0r_get_param_value(inst,&t,i);
char *val;
t=item.x;
f0r_set_param_value(inst,&t,i);
break;
- //case F0R_PARAM_COLOR:
- // t=mlt_properties_get_double( prop , pinfo.name );
-
+ case F0R_PARAM_COLOR:
+ {
+ f0r_param_color_t color;
+ parse_color(mlt_properties_get(prop , pinfo.name), &color);
+ f0r_set_param_value(inst, &color, i);
+ break;
+ }
+
}
}
-
+
mlt_geometry_close(geom);
}
}
-
+
int video_area = *width * *height;
uint32_t *img_a = mlt_pool_alloc( video_area * sizeof(uint32_t) );
uint32_t *img_b = mlt_pool_alloc( video_area * sizeof(uint32_t) );
-
+
if (type==filter_type){
mlt_convert_yuv422_to_rgb24a(*image, (uint8_t *)img_a, video_area);
f0r_update ( inst , position , img_a , img_b );
- mlt_convert_rgb24a_to_yuv422((uint8_t *)img_b , *width, *height, *width * sizeof(uint32_t),
- *image, NULL );
+ mlt_convert_rgb24a_to_yuv422((uint8_t *)img_b , *width, *height, *width * sizeof(uint32_t),
+ *image, NULL );
}else if (type==transition_type && f0r_update2 ){
uint32_t *result = mlt_pool_alloc( video_area * sizeof(uint32_t) );
-
+
mlt_convert_yuv422_to_rgb24a ( image[0] , (uint8_t *)img_a , video_area );
mlt_convert_yuv422_to_rgb24a ( image[1] , (uint8_t *)img_b , video_area );
f0r_update2 ( inst , position , img_a , img_b , NULL , result );
-
+
uint8_t * image_ptr=mlt_properties_get_data(MLT_FRAME_PROPERTIES(this), "image", NULL );
if (image_ptr)
mlt_convert_rgb24a_to_yuv422((uint8_t *)result, *width, *height, *width * sizeof(uint32_t), image_ptr , NULL );
-
+
mlt_pool_release(result);
}
mlt_pool_release(img_a);
mlt_pool_release(img_b);
-
+
return 0;
}
void destruct (mlt_properties prop ) {
-
+
void (*f0r_destruct)(f0r_instance_t instance)=mlt_properties_get_data( prop , "f0r_destruct" , NULL );
void (*f0r_deinit)(void)=mlt_properties_get_data ( prop , "f0r_deinit" , NULL);
int i=0;
-
+
if ( f0r_deinit != NULL )
f0r_deinit();
-
+
for ( i=0 ; i < mlt_properties_count ( prop ) ; i++ ){
if ( strstr ( mlt_properties_get_name ( prop , i ) , "ctor-" ) != NULL ){
void * inst=mlt_properties_get_data( prop , mlt_properties_get_name ( prop , i ) , NULL );
}
}
}
- void (*dlclose)(void*)=mlt_properties_get_data ( prop , "_dlclose" , NULL);
- void *handle=mlt_properties_get_data ( prop , "_dlclose_handle" , NULL);
-
+ void (*dlclose)(void*)=mlt_properties_get_data ( prop , "_dlclose" , NULL);
+ void *handle=mlt_properties_get_data ( prop , "_dlclose_handle" , NULL);
+
if (handle && dlclose ){
dlclose ( handle );
}
-
+
}