mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-19 06:10:01 +01:00
188 lines
5.8 KiB
C
188 lines
5.8 KiB
C
/*
|
|
* LIBVJE - veejay fx library
|
|
*
|
|
* Copyright(C)2006 Niels Elburg <nelburg@looze.net>
|
|
* See COPYING for software license and distribution details
|
|
*/
|
|
|
|
|
|
#define IS_LIVIDO_PLUGIN
|
|
#include <livido.h>
|
|
LIVIDO_PLUGIN
|
|
#include "utils.h"
|
|
#include "livido-utils.c"
|
|
|
|
livido_init_f init_instance( livido_port_t *my_instance )
|
|
{
|
|
return LIVIDO_NO_ERROR;
|
|
}
|
|
|
|
|
|
livido_deinit_f deinit_instance( livido_port_t *my_instance )
|
|
{
|
|
return LIVIDO_NO_ERROR;
|
|
}
|
|
|
|
livido_process_f process_instance( livido_port_t *my_instance, double timecode )
|
|
{
|
|
int len =0;
|
|
int i = 0;
|
|
uint8_t *A[4] = {NULL,NULL,NULL,NULL};
|
|
uint8_t *O[4]= {NULL,NULL,NULL,NULL};
|
|
|
|
int palette[3];
|
|
int w[3];
|
|
int h[3];
|
|
|
|
int error = lvd_extract_channel_values( my_instance, "in_channels", 0, &w[0], &h[0], A, &palette[0] );
|
|
if( error != LIVIDO_NO_ERROR )
|
|
return LIVIDO_ERROR_HARDWARE; //@ error codes in livido flanky
|
|
|
|
error = lvd_extract_channel_values( my_instance, "out_channels", 0, &w[1],&h[1], O,&palette[1] );
|
|
if( error != LIVIDO_NO_ERROR )
|
|
return LIVIDO_ERROR_HARDWARE; //@ error codes in livido flanky
|
|
|
|
#ifdef STRICT_CHECKING
|
|
assert( w[0] == w[1] );
|
|
assert( h[0] == h[1] );
|
|
assert( palette[0] == palette[1] );
|
|
assert( A[0] != NULL );
|
|
assert( A[1] != NULL );
|
|
assert( A[2] != NULL );
|
|
assert( O[0] != NULL );
|
|
assert( O[1] != NULL );
|
|
assert( O[2] != NULL );
|
|
#endif
|
|
|
|
int uv_len = lvd_uv_plane_len( palette[0],w[0],h[0] );
|
|
len = w[0] * h[0];
|
|
|
|
double db[3];
|
|
for( i = 0; i < 3 ; i ++ )
|
|
db[i] = lvd_extract_param_number( my_instance, "in_parameters",i);
|
|
int base = (const int) (db[0] * 255.0);
|
|
int ubase = (const int) (db[1] * 255.0);
|
|
int vbase = (const int) (db[2] * 255.0);
|
|
if( ubase <= 0 )
|
|
ubase = 1;
|
|
if( vbase <= 0 )
|
|
vbase = 1;
|
|
if( base <= 0)
|
|
base = 1;
|
|
uint8_t tmp;
|
|
int p;
|
|
|
|
for( i = 0; i < len; i ++ )
|
|
{
|
|
tmp = A[0][i];
|
|
O[0][i] = (tmp/base) * base;
|
|
}
|
|
|
|
if( db[1] > 0.0 )
|
|
for( i = 0; i < uv_len ; i ++ )
|
|
{
|
|
p = A[1][i] - 128;
|
|
O[1][i] = (p / ubase) * ubase + 128;
|
|
}
|
|
if( db[2] > 0.0 )
|
|
for( i = 0; i < uv_len ; i ++ )
|
|
{
|
|
p = A[2][i] - 128;
|
|
O[2][i] = (p / vbase) * vbase + 128;
|
|
}
|
|
|
|
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[3];
|
|
livido_port_t *in_chans[1];
|
|
livido_port_t *out_chans[1];
|
|
livido_port_t *info = NULL;
|
|
livido_port_t *filter = NULL;
|
|
|
|
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 );
|
|
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;
|
|
|
|
livido_set_string_value( port, "name", "Cartonize");
|
|
livido_set_string_value( port, "description", "Reduces pixel depth");
|
|
livido_set_string_value( port, "author", "Niels Elburg");
|
|
|
|
livido_set_int_value( port, "flags", 0);
|
|
livido_set_string_value( port, "license", "GPL2");
|
|
livido_set_int_value( port, "version", 1);
|
|
|
|
int palettes0[] = {
|
|
LIVIDO_PALETTE_YUV420P,
|
|
LIVIDO_PALETTE_YUV422P,
|
|
LIVIDO_PALETTE_YUV444P,
|
|
0
|
|
};
|
|
|
|
in_chans[0] = livido_port_new( LIVIDO_PORT_TYPE_CHANNEL_TEMPLATE );
|
|
port = in_chans[0];
|
|
|
|
livido_set_string_value( port, "name", "Channel A");
|
|
livido_set_int_array( port, "palette_list", 3, palettes0);
|
|
livido_set_int_value( port, "flags", 0);
|
|
|
|
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", 3, 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", "Y base" );
|
|
livido_set_string_value(port, "kind", "NUMBER" );
|
|
livido_set_double_value( port, "min", 0.0 );
|
|
livido_set_double_value( port, "max", 1.0 );
|
|
livido_set_double_value( port, "default", 1.0 );
|
|
livido_set_string_value( port, "description" ,"Scale all luminance pixels to a set value");
|
|
|
|
in_params[1] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[1];
|
|
|
|
livido_set_string_value(port, "name", "U base" );
|
|
livido_set_string_value(port, "kind", "NUMBER" );
|
|
livido_set_double_value( port, "min", 0.0 );
|
|
livido_set_double_value( port, "max", 1.0 );
|
|
livido_set_double_value( port, "default", 1.0 );
|
|
livido_set_string_value( port, "description" ,"Scale all pixels to a set value");
|
|
|
|
in_params[2] = livido_port_new( LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE );
|
|
port = in_params[2];
|
|
|
|
livido_set_string_value(port, "name", "V base" );
|
|
livido_set_string_value(port, "kind", "NUMBER" );
|
|
livido_set_double_value( port, "min", 0.0 );
|
|
livido_set_double_value( port, "max", 1.0 );
|
|
livido_set_double_value( port, "default", 1.0 );
|
|
livido_set_string_value( port, "description" ,"Scale all pixels to a set value");
|
|
|
|
livido_set_portptr_array( filter, "in_channel_templates", 1 , in_chans );
|
|
livido_set_portptr_array( filter, "out_parameter_templates",0, NULL );
|
|
livido_set_portptr_array( filter, "in_parameter_templates",3, in_params );
|
|
livido_set_portptr_array( filter, "out_channel_templates", 1, out_chans );
|
|
|
|
livido_set_portptr_value(info, "filters", filter);
|
|
return info;
|
|
}
|