mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-20 14:50:01 +01:00
280 lines
9.0 KiB
C
280 lines
9.0 KiB
C
/*
|
|
* LIBVJE - veejay fx library
|
|
*
|
|
* Copyright(C)2015 Niels Elburg <nwelburg@gmail.com>
|
|
* See COPYING for software license and distribution details
|
|
*
|
|
*/
|
|
|
|
#ifndef IS_LIVIDO_PLUGIN
|
|
#define IS_LIVIDO_PLUGIN
|
|
#endif
|
|
|
|
#include "livido.h"
|
|
LIVIDO_PLUGIN
|
|
#include "utils.h"
|
|
#include "livido-utils.c"
|
|
#include "lvd_common.h"
|
|
#include "lvdgmicglue.h"
|
|
|
|
|
|
int init_instance( livido_port_t *my_instance )
|
|
{
|
|
Clvdgmic *gmic = lvdgmic_new(1);
|
|
if(!gmic) {
|
|
return LIVIDO_ERROR_MEMORY_ALLOCATION;
|
|
}
|
|
|
|
livido_property_set( my_instance, "PLUGIN_private",
|
|
LIVIDO_ATOM_TYPE_VOIDPTR,1,&gmic );
|
|
|
|
return LIVIDO_NO_ERROR;
|
|
}
|
|
|
|
livido_deinit_f deinit_instance( livido_port_t *my_instance )
|
|
{
|
|
Clvdgmic *gmic = NULL;
|
|
if(livido_property_get( my_instance, "PLUGIN_private",0, &gmic) == LIVIDO_NO_ERROR) {
|
|
lvdgmic_delete(gmic);
|
|
}
|
|
|
|
return LIVIDO_NO_ERROR;
|
|
}
|
|
|
|
int process_instance( livido_port_t *my_instance, double timecode )
|
|
{
|
|
uint8_t *A[4] = {NULL,NULL,NULL,NULL};
|
|
uint8_t *O[4]= {NULL,NULL,NULL,NULL};
|
|
char cmd[256];
|
|
int palette;
|
|
int w;
|
|
int h;
|
|
|
|
int error = lvd_extract_channel_values( my_instance, "out_channels", 0, &w,&h, O,&palette );
|
|
if( error != LIVIDO_NO_ERROR )
|
|
return LIVIDO_ERROR_NO_OUTPUT_CHANNELS;
|
|
Clvdgmic *gmic = NULL;
|
|
livido_property_get( my_instance, "PLUGIN_private",0, &gmic);
|
|
|
|
lvd_extract_channel_values( my_instance, "in_channels" , 0, &w, &h, A, &palette );
|
|
|
|
int p1 = lvd_extract_param_index( my_instance,"in_parameters", 0 );
|
|
int p2 = lvd_extract_param_index( my_instance,"in_parameters", 1 );
|
|
int p3 = lvd_extract_param_index(my_instance, "in_parameters",2);
|
|
int p4 = lvd_extract_param_index(my_instance, "in_parameters",3);
|
|
int p5 = lvd_extract_param_index(my_instance, "in_parameters",4);
|
|
int p6 = lvd_extract_param_index(my_instance, "in_parameters",5);
|
|
int p7 = lvd_extract_param_index(my_instance, "in_parameters",6);
|
|
int p8 = lvd_extract_param_index(my_instance, "in_parameters",7);
|
|
int p9 = lvd_extract_param_index(my_instance, "in_parameters",8);
|
|
int p10 = lvd_extract_param_index(my_instance, "in_parameters",9);
|
|
int p11 = lvd_extract_param_index(my_instance, "in_parameters",10);
|
|
|
|
|
|
snprintf(cmd,sizeof(cmd),"-gimp_light_relief %f,%f,%f,%f,%d,%f,%f,%d,%f,%d,%d",
|
|
(float) p1/100.0f,
|
|
(float) p2/100.0f,
|
|
(float) p3/100.0f,
|
|
(float) p4/100.0f,
|
|
p5,
|
|
(float) p6/100.0f,
|
|
(float) p7/100.0f,
|
|
p8,
|
|
(float) p9/100.0f,
|
|
p10,
|
|
p11);
|
|
|
|
lvdgmic_push( gmic, w, h, 0, A, 0);
|
|
|
|
lvdgmic_gmic( gmic, cmd );
|
|
|
|
lvdgmic_pull( gmic, 0, O );
|
|
|
|
return LIVIDO_NO_ERROR;
|
|
}
|
|
|
|
livido_port_t *livido_setup(livido_setup_t list[], int version)
|
|
|
|
{
|
|
LIVIDO_IMPORT(list);
|
|
|
|
livido_port_t *port = NULL;
|
|
livido_port_t *in_params[11];
|
|
livido_port_t *in_chans[3];
|
|
livido_port_t *out_chans[1];
|
|
livido_port_t *info = NULL;
|
|
livido_port_t *filter = NULL;
|
|
|
|
//@ setup root node, plugin info
|
|
info = livido_port_new( LIVIDO_PORT_TYPE_PLUGIN_INFO );
|
|
port = info;
|
|
|
|
livido_set_string_value( port, "maintainer", "Niels");
|
|
livido_set_string_value( port, "version","1");
|
|
|
|
filter = livido_port_new( LIVIDO_PORT_TYPE_FILTER_CLASS );
|
|
livido_set_int_value( filter, "api_version", LIVIDO_API_VERSION );
|
|
|
|
//@ setup function pointers
|
|
livido_set_voidptr_value( filter, "deinit_func", &deinit_instance );
|
|
livido_set_voidptr_value( filter, "init_func", &init_instance );
|
|
livido_set_voidptr_value( filter, "process_func", &process_instance );
|
|
port = filter;
|
|
|
|
//@ meta information
|
|
livido_set_string_value( port, "name", "G'MIC/GREYs Light Relief");
|
|
livido_set_string_value( port, "description", "Apply Light Relief");
|
|
livido_set_string_value( port, "author", "GREYC's Magic for Image Computing");
|
|
|
|
livido_set_int_value( port, "flags", LIVIDO_FILTER_NON_REALTIME);
|
|
livido_set_string_value( port, "license", "GPL2");
|
|
livido_set_int_value( port, "version", 1);
|
|
|
|
//@ some palettes veejay-classic uses
|
|
int palettes0[] = {
|
|
LIVIDO_PALETTE_YUV444P,
|
|
0,
|
|
};
|
|
|
|
//@ setup output channel
|
|
out_chans[0] = livido_port_new( LIVIDO_PORT_TYPE_CHANNEL_TEMPLATE );
|
|
port = out_chans[0];
|
|
|
|
livido_set_string_value( port, "name", "Output Channel");
|
|
livido_set_int_array( port, "palette_list", 2, palettes0);
|
|
livido_set_int_value( port, "flags", 0);
|
|
|
|
in_chans[0] = livido_port_new( LIVIDO_PORT_TYPE_CHANNEL_TEMPLATE );
|
|
port = in_chans[0];
|
|
livido_set_string_value( port, "name", "Input Channel");
|
|
livido_set_int_array( port, "palette_list", 2, palettes0);
|
|
livido_set_int_value( port, "flags", 0);
|
|
|
|
in_params[0] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[0];
|
|
|
|
livido_set_string_value(port, "name", "Ambient lightness" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 500 );
|
|
livido_set_int_value( port, "default", 30 );
|
|
livido_set_string_value( port, "description" ,"Ambient lightness");
|
|
|
|
|
|
in_params[1] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[1];
|
|
|
|
livido_set_string_value(port, "name", "Specular lightness" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 200 );
|
|
livido_set_int_value( port, "default", 20 );
|
|
livido_set_string_value( port, "description" ,"Specular lightness");
|
|
|
|
in_params[2] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[2];
|
|
|
|
livido_set_string_value(port, "name", "Specular size" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 100 );
|
|
livido_set_int_value( port, "default", 10 );
|
|
livido_set_string_value( port, "description" ,"Specular size");
|
|
|
|
in_params[3] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[3];
|
|
|
|
livido_set_string_value(port, "name", "Darkness" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 100 );
|
|
livido_set_int_value( port, "default",0 );
|
|
livido_set_string_value( port, "description" ,"Darkness");
|
|
|
|
in_params[4] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[4];
|
|
|
|
livido_set_string_value(port, "name", "Light smoothness" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 5 );
|
|
livido_set_int_value( port, "default",1 );
|
|
livido_set_string_value( port, "description" ,"Light smoothness");
|
|
|
|
in_params[5] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[5];
|
|
|
|
livido_set_string_value(port, "name", "X-light" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 100 );
|
|
livido_set_int_value( port, "default",50 );
|
|
livido_set_string_value( port, "description" ,"X-light");
|
|
|
|
|
|
in_params[6] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[6];
|
|
|
|
livido_set_string_value(port, "name", "Y-light" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 100 );
|
|
livido_set_int_value( port, "default",50 );
|
|
livido_set_string_value( port, "description" ,"Y-light");
|
|
|
|
|
|
|
|
in_params[7] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[7];
|
|
|
|
livido_set_string_value(port, "name", "Z-light" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 20 );
|
|
livido_set_int_value( port, "default",5 );
|
|
livido_set_string_value( port, "description" ,"Z-light");
|
|
|
|
|
|
in_params[8] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[8];
|
|
|
|
livido_set_string_value(port, "name", "Z-scale" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max", 300 );
|
|
livido_set_int_value( port, "default",50 );
|
|
livido_set_string_value( port, "description" ,"Z-scale");
|
|
|
|
|
|
|
|
in_params[9] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[9];
|
|
|
|
livido_set_string_value(port, "name", "Opacity" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max",1 );
|
|
livido_set_int_value( port, "default",0 );
|
|
livido_set_string_value( port, "description" ,"Opacity as heightmap");
|
|
|
|
|
|
in_params[10] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[10];
|
|
|
|
livido_set_string_value(port, "name", "Smoothness" );
|
|
livido_set_string_value(port, "kind", "INDEX" );
|
|
livido_set_int_value( port, "min", 0 );
|
|
livido_set_int_value( port, "max",10 );
|
|
livido_set_int_value( port, "default",0 );
|
|
livido_set_string_value( port, "description" ,"Image smoothness");
|
|
|
|
|
|
//@ setup the nodes
|
|
livido_set_portptr_array( filter, "in_parameter_templates",11, in_params );
|
|
livido_set_portptr_array( filter, "out_channel_templates", 1, out_chans );
|
|
livido_set_portptr_array( filter, "in_channel_templates",1, in_chans );
|
|
|
|
livido_set_portptr_value(info, "filters", filter);
|
|
return info;
|
|
}
|