issue #42, add mean filter, constrain bg subtraction filters to 1 instance

This commit is contained in:
c0ntrol
2016-04-02 16:34:44 +02:00
parent 81da37e5f0
commit a2db1d5501
21 changed files with 493 additions and 144 deletions

View File

@@ -991,7 +991,7 @@ int sample_del(int sample_id)
if (sample_node) {
int i;
sample_chain_free( sample_id );
sample_chain_free( sample_id,1 );
if(si->soft_edl == 0 && si->edit_list != NULL)
vj_el_break_cache( si->edit_list ); //@ destroy cache, if any
@@ -1994,7 +1994,7 @@ int sample_chain_malloc(int s1)
return sum;
}
int sample_chain_free(int s1)
int sample_chain_free(int s1, int global)
{
sample_info *sample = sample_get(s1);
int i=0;
@@ -2009,11 +2009,11 @@ int sample_chain_free(int s1)
{
if(vj_effect_initialized(e_id, sample->effect_chain[i]->fx_instance))
{
vj_effect_deactivate(e_id, sample->effect_chain[i]->fx_instance);
vj_effect_deactivate(e_id, sample->effect_chain[i]->fx_instance, global);
sample->effect_chain[i]->fx_instance = NULL;
sample->effect_chain[i]->clear = 1;
sum++;
}
if( sample->effect_chain[i]->source_type == 1 &&
vj_tag_get_active( sample->effect_chain[i]->channel ) &&
vj_tag_get_type( sample->effect_chain[i]->channel ) == VJ_TAG_TYPE_NET ) {
@@ -2021,6 +2021,7 @@ int sample_chain_free(int s1)
}
}
}
}
return sum;
}
@@ -2124,11 +2125,8 @@ int sample_chain_add(int s1, int c, int effect_nr)
if (c < 0 || c >= SAMPLE_MAX_EFFECTS)
return 0;
/* if ( effect_nr < VJ_IMAGE_EFFECT_MIN ) return -1;
if ( effect_nr > VJ_IMAGE_EFFECT_MAX && effect_nr < VJ_VIDEO_EFFECT_MIN )
return -1;
*/
if( vj_effect_single_instance( effect_nr ))
return 0;
if( sample->effect_chain[c]->effect_id != -1 && sample->effect_chain[c]->effect_id != effect_nr )
{
@@ -2146,12 +2144,12 @@ int sample_chain_add(int s1, int c, int effect_nr)
}
if( frm == 1 ) {
vj_effect_deactivate( sample->effect_chain[c]->effect_id, sample->effect_chain[c]->fx_instance );
vj_effect_deactivate( sample->effect_chain[c]->effect_id, sample->effect_chain[c]->fx_instance,1 );
sample->effect_chain[c]->fx_instance = NULL;
sample->effect_chain[c]->clear = 1;
}
} else {
vj_effect_deactivate( sample->effect_chain[c]->effect_id, sample->effect_chain[c]->fx_instance );
vj_effect_deactivate( sample->effect_chain[c]->effect_id, sample->effect_chain[c]->fx_instance,1 );
sample->effect_chain[c]->fx_instance = NULL;
sample->effect_chain[c]->clear = 1;
}
@@ -2317,7 +2315,7 @@ int sample_chain_clear(int s1)
if(sample->effect_chain[i]->effect_id != -1)
{
if(vj_effect_initialized( sample->effect_chain[i]->effect_id, sample->effect_chain[i]->fx_instance )) {
vj_effect_deactivate( sample->effect_chain[i]->effect_id, sample->effect_chain[i]->fx_instance );
vj_effect_deactivate( sample->effect_chain[i]->effect_id, sample->effect_chain[i]->fx_instance,1 );
sample->effect_chain[i]->fx_instance = NULL;
sample->effect_chain[i]->clear = 1;
}
@@ -2441,7 +2439,7 @@ int sample_chain_remove(int s1, int position)
if(sample->effect_chain[position]->effect_id != -1)
{
if(vj_effect_initialized( sample->effect_chain[position]->effect_id, sample->effect_chain[position]->fx_instance ) && _sample_can_free( sample, position, sample->effect_chain[position]->effect_id) ) {
vj_effect_deactivate( sample->effect_chain[position]->effect_id, sample->effect_chain[position]->fx_instance);
vj_effect_deactivate( sample->effect_chain[position]->effect_id, sample->effect_chain[position]->fx_instance, 1);
sample->effect_chain[position]->fx_instance = NULL;
sample->effect_chain[position]->clear = 1;
}

View File

@@ -183,7 +183,7 @@ typedef struct sample_info_t {
#define SAMPLE_DEC_BIBBER 1
#define SAMPLE_DEC_FREEZE 2
extern int sample_chain_malloc(int sample_id);
extern int sample_chain_free(int sample_id);
extern int sample_chain_free(int sample_id, int global);
extern int sample_size();
extern int sample_verify();
extern int sample_init(int len, void *font, editlist *el);

View File

@@ -1277,7 +1277,7 @@ int vj_tag_del(int id)
break;
}
vj_tag_chain_free( tag->id );
vj_tag_chain_free( tag->id,1 );
if(tag->encoder_active)
vj_tag_stop_encoder( tag->id );
@@ -1952,7 +1952,7 @@ int vj_tag_chain_malloc(int t1)
return sum;
}
int vj_tag_chain_free(int t1)
int vj_tag_chain_free(int t1, int global)
{
vj_tag *tag = vj_tag_get(t1);
int i=0;
@@ -1966,7 +1966,7 @@ int vj_tag_chain_free(int t1)
{
if(vj_effect_initialized(e_id, tag->effect_chain[i]->fx_instance) )
{
vj_effect_deactivate(e_id, tag->effect_chain[i]->fx_instance);
vj_effect_deactivate(e_id, tag->effect_chain[i]->fx_instance, global);
tag->effect_chain[i]->fx_instance = NULL;
tag->effect_chain[i]->clear = 1;
if(tag->effect_chain[i]->kf)
@@ -1974,12 +1974,13 @@ int vj_tag_chain_free(int t1)
tag->effect_chain[i]->kf = vpn(VEVO_ANONYMOUS_PORT );
sum++;
}
if( tag->effect_chain[i]->source_type == 1 &&
vj_tag_get_active( tag->effect_chain[i]->channel ) &&
vj_tag_get_type( tag->effect_chain[i]->channel ) == VJ_TAG_TYPE_NET ) {
vj_tag_disable( tag->effect_chain[i]->channel );
}
}
}
}
@@ -2098,6 +2099,9 @@ int vj_tag_set_effect(int t1, int position, int effect_id)
if (position < 0 || position >= SAMPLE_MAX_EFFECTS)
return 0;
if( vj_effect_single_instance( effect_id ))
return 0;
if( tag->effect_chain[position]->effect_id != -1 && tag->effect_chain[position]->effect_id != effect_id )
{
//verify if the effect should be discarded
@@ -2112,13 +2116,13 @@ int vj_tag_set_effect(int t1, int position, int effect_id)
frm = 0;
}
if( frm == 1 ) {
vj_effect_deactivate( tag->effect_chain[position]->effect_id, tag->effect_chain[position]->fx_instance );
vj_effect_deactivate( tag->effect_chain[position]->effect_id, tag->effect_chain[position]->fx_instance,1 );
tag->effect_chain[position]->fx_instance = NULL;
tag->effect_chain[position]->clear = 1;
}
}
else {
vj_effect_deactivate( tag->effect_chain[position]->effect_id, tag->effect_chain[position]->fx_instance );
vj_effect_deactivate( tag->effect_chain[position]->effect_id, tag->effect_chain[position]->fx_instance,1 );
tag->effect_chain[position]->fx_instance = NULL;
tag->effect_chain[position]->clear = 1;
}
@@ -2671,7 +2675,7 @@ int vj_tag_chain_remove(int t1, int index)
{
if( vj_effect_initialized( tag->effect_chain[index]->effect_id, tag->effect_chain[index]->fx_instance ) && vj_tag_chain_can_delete( tag, index, tag->effect_chain[index]->effect_id ) )
{
vj_effect_deactivate( tag->effect_chain[index]->effect_id, tag->effect_chain[index]->fx_instance );
vj_effect_deactivate( tag->effect_chain[index]->effect_id, tag->effect_chain[index]->fx_instance,1 );
tag->effect_chain[index]->fx_instance = NULL;
tag->effect_chain[index]->clear = 1;
}

View File

@@ -144,7 +144,7 @@ void *vj_tag_get_dict( int id );
int vj_tag_set_composite(void *compiz,int id, int n);
int vj_tag_get_composite(int t1);
int vj_tag_chain_malloc(int e);
int vj_tag_chain_free(int e);
int vj_tag_chain_free(int e,int global);
int vj_tag_get_v4l_properties(int t1, int *arr );
int vj_tag_init(int w, int h, int pix_fmt, int driver);
int vj_tag_get_n_frames(int t1);

View File

@@ -58,6 +58,6 @@ libvje_la_SOURCES = vj-effect.c vj-effman.c effects/common.c \
effects/alphaselect2.c effects/alphablend.c effects/porterduff.c effects/alphanegate.c effects/lumakeyalpha.c \
effects/chromamagickalpha.c effects/magicoverlaysalpha.c effects/gaussblur.c effects/levelcorrection.c \
effects/masktransition.c effects/alphadampen.c effects/passthrough.c effects/alphatransition.c effects/randnoise.c \
effects/bgsubtractgauss.c effects/bwotsu.c
effects/bgsubtractgauss.c effects/bwotsu.c effects/meanfilter.c

View File

@@ -39,7 +39,7 @@ vj_effect *autoeq_init(int w, int h)
ve->limits[0][2] = 0;
ve->limits[1][2] = 255;
ve->defaults[0] = 0; // y only, v only, u only, all
ve->defaults[0] = 0; // show histogram
ve->defaults[1] = 200; // intensity
ve->defaults[2] = 132; // strength
@@ -47,7 +47,11 @@ vj_effect *autoeq_init(int w, int h)
ve->sub_format = 0;
ve->extra_frame = 0;
ve->has_user = 0;
ve->param_description = vje_build_param_list( ve->num_params, "Channel (Y,U,V,All)","Intensity","Strength");
ve->param_description = vje_build_param_list( ve->num_params, "Mode","Intensity","Strength");
ve->hints = vje_init_value_hint_list( ve->num_params );
vje_build_value_hint_list( ve->hints, ve->limits[1][0],0,
"Show Histogram", "Equalize Frame" );
return ve;
}

View File

@@ -32,6 +32,8 @@ static uint8_t *static_bg__ = NULL;
static uint8_t *bg_frame__[4] = { NULL,NULL,NULL,NULL };
static int bg_ssm = 0;
static unsigned int bg_n = 0;
static uint8_t instance = 0;
static int auto_hist = 1;
vj_effect *bgsubtract_init(int width, int height)
{
@@ -53,6 +55,7 @@ vj_effect *bgsubtract_init(int width, int height)
ve->defaults[1] = 0;
ve->defaults[2] = 0;
ve->defaults[3] = 0;
ve->defaults[4] = 0;
ve->description = "Subtract Background";
ve->extra_frame = 0;
@@ -61,6 +64,7 @@ vj_effect *bgsubtract_init(int width, int height)
ve->user_data = NULL;
ve->sub_format = 0;
ve->parallel = 1;
ve->global = 1; /* this effect is not freed when switching samples */
ve->param_description = vje_build_param_list( ve->num_params, "Threshold", "BG Method","Enable", "To Alpha");
@@ -72,9 +76,19 @@ vj_effect *bgsubtract_init(int width, int height)
ve->alpha = FLAG_ALPHA_OUT | FLAG_ALPHA_OPTIONAL;
const char *hist = getenv( "VEEJAY_BG_AUTO_HISTOGRAM_EQ" );
if( hist ) {
auto_hist = atoi( hist );
}
return ve;
}
int bgsubtract_instances()
{
return instance;
}
int bgsubtract_malloc(int width, int height)
{
if(static_bg__ == NULL){
@@ -85,6 +99,13 @@ int bgsubtract_malloc(int width, int height)
bg_frame__[3] = bg_frame__[2] + RUP8(width*height);
}
instance = 1;
veejay_msg( VEEJAY_MSG_INFO,
"You can enable/disable the histogram equalizer by setting env var VEEJAY_BG_AUTO_HISTOGRAM_EQ" );
veejay_msg( VEEJAY_MSG_INFO,
"Histogram equalization is %s", (auto_hist ? "enabled" : "disabled" ));
return 1;
}
@@ -98,8 +119,10 @@ void bgsubtract_free()
bg_frame__[2] = NULL;
bg_frame__[3] = NULL;
static_bg__ = NULL;
bg_ssm = 0;
}
bg_ssm = 0;
instance = 0;
}
int bgsubtract_prepare(VJFrame *frame)
@@ -109,8 +132,12 @@ int bgsubtract_prepare(VJFrame *frame)
return 0;
}
if( auto_hist )
vje_histogram_auto_eq( frame );
//@ copy the iamge
veejay_memcpy( bg_frame__[0], frame->data[0], frame->len );
if( frame->ssm ) {
veejay_memcpy( bg_frame__[1], frame->data[1], frame->len );
veejay_memcpy( bg_frame__[2], frame->data[2], frame->len );
@@ -170,6 +197,10 @@ static void bgsubtract_show_bg( VJFrame *frame )
void bgsubtract_apply(VJFrame *frame,int width, int height, int threshold, int method, int enabled, int alpha )
{
const int uv_len = (frame->ssm ? frame->len : frame->uv_len );
if( auto_hist )
vje_histogram_auto_eq( frame );
if( enabled == 0 ) {
switch( method ) {
case 0:

View File

@@ -25,6 +25,7 @@
#include <stdint.h>
vj_effect *bgsubtract_init(int width, int height);
int bgsubtract_instances();
void bgsubtract_free();
int bgsubtract_malloc(int w, int h);
int bgsubtract_prepare(VJFrame *frame);

View File

@@ -29,14 +29,17 @@
#include "bgsubtractgauss.h"
#include "common.h"
static uint8_t instance = 0;
static uint8_t *static_bg__ = NULL;
static uint8_t *fg_frame__ = NULL;
static uint8_t *static_bg_frame__[4] = { NULL,NULL,NULL,NULL };
static double *pMu = NULL;
static double *pVar = NULL;
static uint32_t bg_n = 0;
static double pNoise = 0.0;
static uint8_t *morph_frame__ = NULL;
static uint8_t *fg_frame__ = NULL;
static uint8_t *mean = NULL;
static int auto_hist = 1;
vj_effect *bgsubtractgauss_init(int width, int height)
{
@@ -71,6 +74,9 @@ vj_effect *bgsubtractgauss_init(int width, int height)
ve->has_user = 1;
ve->user_data = NULL;
ve->parallel = 1;
ve->global = 1; /* this FX is not freed when switching between samples */
ve->alpha = FLAG_ALPHA_OUT | FLAG_ALPHA_OPTIONAL;
ve->param_description = vje_build_param_list( ve->num_params, "Alpha Max", "Threshold", "Noise Level", "Mode", "Frame Period", "Morphology Level");
ve->hints = vje_init_value_hint_list( ve->num_params );
@@ -86,6 +92,11 @@ vj_effect *bgsubtractgauss_init(int width, int height)
"No Erosion/Dilation of FG",
"Erode/Dilate FG" );
const char *hist = getenv( "VEEJAY_BG_AUTO_HISTOGRAM_EQ" );
if( hist ) {
auto_hist = atoi( hist );
}
return ve;
}
@@ -99,10 +110,17 @@ static void bg_init( double noise, const int len )
pNoise = noise;
}
int bgsubtractgauss_instances()
{
return instance;
}
int bgsubtractgauss_malloc(int width, int height)
{
if(static_bg__ == NULL){
static_bg__ = (uint8_t*) vj_malloc( RUP8(width*height*4));
if(!static_bg__ )
return 0;
static_bg_frame__[0] = static_bg__;
static_bg_frame__[1] = static_bg_frame__[0] + RUP8(width*height);
static_bg_frame__[2] = static_bg_frame__[1] + RUP8(width*height);
@@ -113,23 +131,64 @@ int bgsubtractgauss_malloc(int width, int height)
}
if( fg_frame__ == NULL ) {
fg_frame__ = (uint8_t*) vj_calloc( RUP8(width*height) );
fg_frame__ = (uint8_t*) vj_calloc( RUP8(width*height*2) );
if(!fg_frame__ ) {
free(static_bg__);static_bg__ = NULL;
return 0;
}
}
if( morph_frame__ == NULL ) {
morph_frame__ = (uint8_t*) vj_calloc( RUP8(width*height));
if(!morph_frame__) {
free(static_bg__);static_bg__ = NULL;
free(fg_frame__);fg_frame__ = NULL;
return 0;
}
}
if( pMu == NULL ) {
pMu = (double*) vj_malloc( RUP8(sizeof(double) * width * height ));
if( pMu == NULL ) {
free(static_bg__); static_bg__ = NULL;
free(fg_frame__); fg_frame__ = NULL;
free(morph_frame__); morph_frame__ = NULL;
return 0;
}
}
if( pVar == NULL ) {
pVar = (double*) vj_malloc( RUP8(sizeof(double) * width * height ));
if( pVar == NULL ) {
free(static_bg__); static_bg__ = NULL;
free(fg_frame__); fg_frame__ = NULL;
free(morph_frame__); morph_frame__ = NULL;
free(pMu); pMu = NULL;
return 0;
}
bg_init( 50.0, width * height );
}
if( mean == NULL ) {
mean = (uint8_t*) vj_calloc( RUP8(width*height) );
if( mean == NULL ) {
free(static_bg__); static_bg__ = NULL;
free(fg_frame__); fg_frame__ = NULL;
free(morph_frame__); morph_frame__ = NULL;
free(pMu); pMu = NULL;
free(pVar); pVar = NULL;
return 0;
}
}
veejay_msg( VEEJAY_MSG_INFO,
"You can enable/disable the histogram equalizer by setting env var VEEJAY_BG_AUTO_HISTOGRAM_EQ" );
veejay_msg( VEEJAY_MSG_INFO,
"Histogram equalization is %s", (auto_hist ? "enabled" : "disabled" ));
bg_n = 0;
instance = 1;
return 1;
}
@@ -138,7 +197,6 @@ void bgsubtractgauss_free()
{
if( static_bg__ ) {
free(static_bg__ );
static_bg_frame__[0] = NULL;
static_bg_frame__[1] = NULL;
static_bg_frame__[2] = NULL;
@@ -165,6 +223,13 @@ void bgsubtractgauss_free()
free(pMu);
pMu = NULL;
}
if( mean ) {
free(mean);
mean = NULL;
}
instance = 0;
}
int bgsubtractgauss_prepare(VJFrame *frame)
@@ -202,6 +267,8 @@ uint8_t* bgsubtractgauss_get_bg_frame(unsigned int plane)
static void bgsubtractgauss_show_bg( VJFrame *frame )
{
veejay_memcpy( frame->data[0], static_bg_frame__[0], frame->len );
veejay_memset( frame->data[1], 128, frame->uv_len );
veejay_memset( frame->data[2], 128, frame->uv_len );
}
static void bgsubtractgauss_show_fg( VJFrame *frame )
@@ -214,21 +281,52 @@ static void bgsubtractgauss_show_fg( VJFrame *frame )
static void bg_subtract( VJFrame *frame, double threshold, uint8_t *A )
{
const int len = frame->len;
uint8_t *Y = frame->data[0];
int i;
const uint8_t *Y = frame->data[0];
unsigned int i;
vje_mean_filter( Y, mean, frame->width, frame->height );
for( i = 0; i < len; i ++ )
{
double dY = ((double) Y[i]) - pMu[i];
double dY = ((double) mean[i]) - pMu[i];
double d2 = (dY * dY) / pVar[i];
A[i] = (d2 < threshold ? 0: 0xff);
}
}
static void show_pMu( VJFrame *frame )
{
const int len = frame->len;
uint8_t *Y = frame->data[0];
unsigned int i;
for( i = 0; i < len; i ++ )
{
Y[i] = (uint8_t) pMu[i];
}
veejay_memset( frame->data[1], 128, frame->uv_len);
veejay_memset( frame->data[2], 128, frame->uv_len);
}
static void show_pVar( VJFrame *frame )
{
const int len = frame->len;
uint8_t *Y = frame->data[0];
unsigned int i;
for( i = 0; i < len; i ++ )
{
Y[i] = (uint8_t) pVar[i];
}
veejay_memset( frame->data[1], 128, frame->uv_len);
veejay_memset( frame->data[2], 128, frame->uv_len);
}
static void fg_erode( uint8_t *I, const int w, const int h, uint8_t *O )
{
unsigned int x,y;
const int len = w * h;
const int len = (w * h) - w;
const int aw = w - 1;
for( y = w; y < len; y += w )
@@ -260,7 +358,7 @@ static void fg_erode( uint8_t *I, const int w, const int h, uint8_t *O )
static void fg_dilate( uint8_t *I, const int w, const int h, uint8_t *O )
{
unsigned int x,y;
const int len = w * h;
const int len = (w * h) - w;
const int aw = w - 1;
for( y = w; y < len; y += w )
@@ -301,9 +399,12 @@ static void bg_update( VJFrame *frame, double threshold, double alpha, double no
uint8_t *bg = static_bg_frame__[0];
unsigned int i;
/* mean filter on BG */
vje_mean_filter( Y, mean, frame->width, frame->height );
for( i = 0; i < len; i ++ )
{
double src = (double) Y[i];
double src = (double) mean[i];
double d = (src - pMu[i]) * (src - pMu[i]) - pVar[i];
pMu[i] += (alpha * (src - pMu[i]));
@@ -328,6 +429,9 @@ void bgsubtractgauss_apply(VJFrame *frame, int alpha_max, int threshold, int noi
double g_noise = ( (double) noise ) / 10.0;
double g_threshold = ( (double) threshold) / 100.0;
if( auto_hist )
vje_histogram_auto_eq( frame );
switch( mode )
{
case 0:
@@ -337,8 +441,7 @@ void bgsubtractgauss_apply(VJFrame *frame, int alpha_max, int threshold, int noi
break;
case 1:
/* show foreground, no update of bg */
bg_subtract( frame, g_threshold, fg_frame__ );
bg_subtract( frame, g_threshold,fg_frame__ );
if( morphology ) {
bgsubtractgauss_morph( frame, fg_frame__, fg_frame__ );
}
@@ -346,20 +449,20 @@ void bgsubtractgauss_apply(VJFrame *frame, int alpha_max, int threshold, int noi
bgsubtractgauss_show_fg( frame );
break;
case 2:
/* fill alpha channel with foreground, no update of bg */
bg_subtract( frame, g_threshold, frame->data[3] );
// fill alpha channel with foreground, no update of bg
bg_subtract( frame, g_threshold,frame->data[3] );
if( morphology ) {
bgsubtractgauss_morph( frame, frame->data[3], frame->data[3] );
}
break;
case 3:
/* show foreground, update bg every period frames*/
// show foreground, update bg every period frames
bg_subtract( frame, g_threshold,fg_frame__ );
if( (bg_n % period) == 0 ) {
bg_update( frame, g_threshold, g_alphaMax, g_noise );
}
bg_subtract( frame, g_threshold, fg_frame__ );
if( morphology ) {
bgsubtractgauss_morph( frame, fg_frame__, fg_frame__ );
@@ -370,13 +473,12 @@ void bgsubtractgauss_apply(VJFrame *frame, int alpha_max, int threshold, int noi
bg_n ++;
break;
case 4:
/* fill alpha channel with foreground, update bg every period frames */
// fill alpha channel with foreground, update bg every period frames
bg_subtract( frame, g_threshold,frame->data[3] );
if( (bg_n % period) == 0 ) {
bg_update( frame, g_threshold, g_alphaMax, g_noise );
}
bg_subtract( frame, g_threshold, frame->data[3] );
if( morphology ) {
bgsubtractgauss_morph( frame, frame->data[3], frame->data[3] );
}

View File

@@ -25,6 +25,7 @@
#include <stdint.h>
vj_effect *bgsubtractgauss_init(int width, int height);
int bgsubtractgauss_instances();
void bgsubtractgauss_free();
int bgsubtractgauss_malloc(int w, int h);
int bgsubtractgauss_prepare(VJFrame *frame);

View File

@@ -41,7 +41,7 @@ vj_effect *bwotsu_init(int w, int h)
ve->limits[0][2] = 0;
ve->limits[1][2] = 1;
ve->description = "Binary Threshold via Otsu's method";
ve->description = "Black and White Mask by Otsu's method";
ve->sub_format = -1;
ve->extra_frame = 0;

View File

@@ -94,7 +94,6 @@ static inline void linearBlend(unsigned char *src, int stride)
//#endif
}
matrix_t matrix_placementA(int photoindex, int size, int w , int h)
{
matrix_t m;
@@ -1717,6 +1716,32 @@ void veejay_histogram_equalize( void *his, VJFrame *f , int intensity, int stren
y[i] = LUT[ y[i] ];
}
void vje_histogram_auto_eq( VJFrame *frame )
{
const int len = frame->len;
const double alpha = 255.0 / len;
unsigned int i;
uint32_t H[GREY_LEVELS];
double C[GREY_LEVELS];
uint8_t *Y = frame->data[0];
veejay_memset( H, 0, sizeof(H));
for( i = 0; i < len; i ++ ) {
H[ Y[i] ] ++;
}
C[0] = round(alpha * H[0]);
for( i = 1; i < GREY_LEVELS; i ++ ) {
C[i] = round( C[i - 1] + alpha * H[i] );
}
for( i = 0; i < len; i ++ )
{
Y[i] = (uint8_t) C[ Y[i] ];
}
}
void veejay_histogram_analyze_rgb( void *his, uint8_t *rgb, VJFrame *f )
{
histogram_t *h = (histogram_t*) his;
@@ -2067,3 +2092,62 @@ uint8_t veejay_component_labeling_8(int w, int h, uint8_t *I , uint32_t *M,
return n_labels;
}
void vje_mean_filter( const uint8_t *src, uint8_t *dst, const int w, const int h )
{
const int len = w * h;
unsigned int x,y;
const int aw = w - 1;
for( y = w; y < len; y += w )
{
for(x = 1; x < aw; x++ )
{
dst[x+y] = (
src[x - 1 + y - w ] +
src[x + y - w ] +
src[x + 1 + y - w ] +
src[x - 1 + y ] +
src[x + y] +
src[x + 1 + y ] +
src[x - 1 + y + w ] +
src[x + y + w] +
src[x + 1 + y + w ] ) / 9;
}
}
}
void vje_weighted_average_bin( const uint8_t *src, uint8_t *dst, const int w, const int h )
{
const int len = w * h;
unsigned int x,y;
const int aw = w - 1;
/* 1 2 1
* 2 4 2
* 1 2 1
*/
for( y = w; y < len; y += w )
{
for(x = 1; x < aw; x++ )
{
if( src[x+y] > 0 ) {
dst[x+y] = (
src[x - 1 + y - w ] +
(2* src[x + y - w ]) +
src[x + 1 + y - w ] +
(2*src[x - 1 + y ]) +
(4*src[x + y]) +
(2*src[x + 1 + y ]) +
src[x - 1 + y + w ] +
(2*src[x + y + w]) +
src[x + 1 + y + w ] ) / 16;
}
else {
dst[x+y] = 0;
}
}
}
}

View File

@@ -28,6 +28,7 @@
#include <libvje/vje.h>
#include <math.h>
#define MAX_SCRATCH_FRAMES 50
#define GREY_LEVELS 256
#define func_opacity(a,b,p,q) ( ((a * p) + (b * q)) >> 8 )
#define limit_luma(c) ( c < 16 ? 16 : ( c > 235 ? 235 : c) )
#define limit_chroma(c) ( c < 16 ? 16 : ( c > 240 ? 240 : c) )
@@ -363,7 +364,7 @@ void veejay_histogram_del(void *his);
void *veejay_histogram_new();
void veejay_histogram_draw( void *his, VJFrame *src, VJFrame *dst , int intensity, int strength );
void veejay_histogram_equalize( void *his, VJFrame *f, int intensity, int strength );
void vje_histogram_auto_eq( VJFrame *frame );
void veejay_histogram_analyze_rgb( void *his, uint8_t *rgb, VJFrame *f );
void veejay_histogram_equalize_rgb( void *his, VJFrame *f, uint8_t *rgb, int in, int st, int mode );
void veejay_histogram_draw_rgb( void *his, VJFrame *f, uint8_t *rgb, int in, int st, int mode );
@@ -376,6 +377,7 @@ uint8_t veejay_component_labeling_8(int w, int h, uint8_t *I , uint32_t *M, uint
void vj_diff_plane( uint8_t *A, uint8_t *B, uint8_t *O, int threshold, int len );
void binarify_1src( uint8_t *dst, uint8_t *src, uint8_t threshold,int reverse, int w, int h );
void binarify( uint8_t *bm, uint8_t *bg, uint8_t *src,int threshold,int reverse, const int len);
void vje_mean_filter( const uint8_t *src, uint8_t *dst, const int w, const int h );
#ifdef HAVE_ASM_MMX
void vje_load_mask(uint8_t val);
void vje_mmx_negate_frame(uint8_t *dst, uint8_t *in, uint8_t val, int len );

View File

@@ -0,0 +1,66 @@
/*
* Linux VeeJay
*
* Copyright(C)2016 Niels Elburg <nwelburg@gmail.com>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307 , USA.
*/
#include <config.h>
#include <stdint.h>
#include <stdio.h>
#include <libvjmem/vjmem.h>
#include "common.h"
#include "meanfilter.h"
static uint8_t *mean = NULL;
vj_effect *meanfilter_init(int w, int h)
{
vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect));
ve->num_params = 0;
ve->description = "Mean Filter (3x3)";
ve->sub_format = -1;
ve->extra_frame = 0;
ve->parallel = 1;
ve->has_user = 0;
return ve;
}
int meanfilter_malloc(int w, int h)
{
if( mean == NULL ) {
mean = (uint8_t*) vj_calloc( RUP8(w*h) );
if( mean == NULL )
return 0;
}
return 1;
}
void meanfilter_free()
{
if( mean ) {
free(mean);
mean = NULL;
}
}
void meanfilter_apply( VJFrame *frame )
{
vje_mean_filter( frame->data[0], mean, frame->width, frame->height );
veejay_memcpy( frame->data[0], mean, frame->len );
}

View File

@@ -0,0 +1,32 @@
/*
* Linux VeeJay
*
* Copyright(C)2016 Niels Elburg <nwelburg@gmail.com>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307 , USA.
*/
#ifndef MEANFILTER_H
#define MEANFTILER_H
#include <libvje/vje.h>
#include <sys/types.h>
#include <stdint.h>
vj_effect *meanfilter_init(int w, int h);
void meanfilter_apply( VJFrame *frame );
int meanfilter_malloc(int w, int h);
void meanfilter_free();
#endif

View File

@@ -27,21 +27,6 @@
p4 = Decay
*/
/*
* This FX relies on gcc's auto vectorization.
* To use the plain C version, define NO_AUTOVECTORIZATION
*/
/* TODO:
*
*
* create mask of foreground object (aproximate IR)
* put mask into alpha-channel
* apply secundary effect on alpha-channel
* apply secundary effect on whole frame, using alpha channel
*
*/
#include <config.h>
#include <stdint.h>
#include <stdio.h>
@@ -67,7 +52,7 @@ vj_effect *motionmap_init(int w, int h)
ve->limits[0][0] = 0;
ve->limits[1][0] = 255; /* threshold */
ve->limits[0][1] = 1;
ve->limits[1][1] = (w*h)/2;
ve->limits[1][1] = (w*h)/20;
ve->limits[0][2] = 0;
ve->limits[1][2] = 1;
ve->limits[0][4] = 1;
@@ -385,12 +370,14 @@ int motionmap_prepare( uint8_t *map[4], int width, int height )
return 1;
}
void motionmap_apply( VJFrame *frame, int width, int height, int threshold, int limit, int draw, int history, int decay, int interpol, int last_act_level )
void motionmap_apply( VJFrame *frame, int width, int height, int threshold, int limit1, int draw, int history, int decay, int interpol, int last_act_level )
{
unsigned int i;
const unsigned int len = (width * height);
uint8_t *Cb = frame->data[1];
uint8_t *Cr = frame->data[2];
const int limit = limit1 * 10;
// uint8_t *alpha = frame->data[3];
if(!have_bg) {

View File

@@ -26,7 +26,7 @@
#define VJE_SUCCESS 0
#include <libvje/vje.h>
#define VJ_IMAGE_EFFECT_MIN 93
#define VJ_IMAGE_EFFECT_MIN 92
#define VJ_IMAGE_EFFECT_MAX 199
#define VJ_VIDEO_EFFECT_MIN 200
@@ -253,6 +253,7 @@ enum {
VJ_IMAGE_EFFECT_RANDNOISE = 95,
VJ_IMAGE_EFFECT_BGSUBTRACTGAUSS = 94,
VJ_IMAGE_EFFECT_BWOTSU = 93,
VJ_IMAGE_EFFECT_MEANFILTER = 92,
VJ_IMAGE_EFFECT_DUMMY=0,
};
@@ -463,6 +464,8 @@ extern void bwselect_apply(VJFrame *frame, int w, int h, int a , int b, int c, i
extern void bwotsu_apply(VJFrame *frame, int mode, int skew,int invert);
extern void meanfilter_apply(VJFrame *frame);
extern void complexinvert_apply(VJFrame *frame, int w, int h, int angle, int r, int g, int b, int i_noise);
extern void complexsaturation_apply(VJFrame *frame, int w, int h, int angle, int r, int g, int b, int adj, int adjv, int inoise);

View File

@@ -196,6 +196,7 @@
#include "effects/passthrough.h"
#include "effects/alphatransition.h"
#include "effects/randnoise.h"
#include "effects/meanfilter.h"
#include "effects/common.h"
#include <libplugger/plugload.h>
#include <veejay/vims.h>
@@ -224,72 +225,74 @@ static struct
{
int (*mem_init)(int width, int height);
void (*free)(void);
int (*num_instances)();
int effect_id;
} simple_effect_index[] = {
{ bathroom_malloc, bathroom_free ,VJ_IMAGE_EFFECT_BATHROOM },
{ chromascratcher_malloc, chromascratcher_free,VJ_IMAGE_EFFECT_CHROMASCRATCHER},
{ complexsync_malloc , complexsync_free ,VJ_VIDEO_EFFECT_COMPLEXSYNC },
{ dices_malloc , dices_free ,VJ_IMAGE_EFFECT_DICES },
{ colorhis_malloc, colorhis_free ,VJ_IMAGE_EFFECT_COLORHIS },
{ autoeq_malloc, autoeq_free ,VJ_IMAGE_EFFECT_AUTOEQ },
{ magicscratcher_malloc, magicscratcher_free ,VJ_IMAGE_EFFECT_MAGICSCRATCHER },
{ lumamask_malloc , lumamask_free ,VJ_VIDEO_EFFECT_LUMAMASK },
{ motionblur_malloc , motionblur_free ,VJ_IMAGE_EFFECT_MOTIONBLUR },
{ magicmirror_malloc , magicmirror_free ,VJ_IMAGE_EFFECT_MAGICMIRROR },
{ mtracer_malloc , mtracer_free ,VJ_VIDEO_EFFECT_MTRACER },
{ noiseadd_malloc , noiseadd_free ,VJ_IMAGE_EFFECT_NOISEADD },
{ noisepencil_malloc , noisepencil_free ,VJ_IMAGE_EFFECT_NOISEPENCIL },
{ reflection_malloc , reflection_free ,VJ_IMAGE_EFFECT_REFLECTION },
{ ripple_malloc , ripple_free ,VJ_IMAGE_EFFECT_RIPPLE },
{ rotozoom_malloc , rotozoom_free ,VJ_IMAGE_EFFECT_ROTOZOOM },
{ scratcher_malloc , scratcher_free ,VJ_IMAGE_EFFECT_SCRATCHER },
{ sinoids_malloc , sinoids_free ,VJ_IMAGE_EFFECT_SINOIDS },
{ slice_malloc , slice_free ,VJ_IMAGE_EFFECT_SLICE },
{ split_malloc , split_free ,VJ_VIDEO_EFFECT_SPLIT },
{ tracer_malloc , tracer_free ,VJ_VIDEO_EFFECT_TRACER },
{ zoom_malloc , zoom_free ,VJ_IMAGE_EFFECT_ZOOM },
{ crosspixel_malloc , crosspixel_free ,VJ_IMAGE_EFFECT_CROSSPIXEL },
{ fisheye_malloc, fisheye_free ,VJ_IMAGE_EFFECT_FISHEYE },
{ swirl_malloc , swirl_free ,VJ_IMAGE_EFFECT_SWIRL },
{ radialblur_malloc, radialblur_free, VJ_IMAGE_EFFECT_RADIALBLUR },
{ uvcorrect_malloc, uvcorrect_free, VJ_IMAGE_EFFECT_UVCORRECT },
{ overclock_malloc, overclock_free, VJ_IMAGE_EFFECT_OVERCLOCK },
{ nervous_malloc, nervous_free, VJ_IMAGE_EFFECT_NERVOUS },
{ morphology_malloc, morphology_free, VJ_IMAGE_EFFECT_MORPHOLOGY },
{ differencemap_malloc, differencemap_free, VJ_VIDEO_EFFECT_EXTDIFF },
{ threshold_malloc, threshold_free, VJ_VIDEO_EFFECT_EXTTHRESHOLD },
{ motionmap_malloc, motionmap_free, VJ_IMAGE_EFFECT_MOTIONMAP },
{ colmorphology_malloc, colmorphology_free, VJ_IMAGE_EFFECT_COLMORPH },
{ blob_malloc, blob_free, VJ_IMAGE_EFFECT_VIDBLOB },
{ boids_malloc, boids_free, VJ_IMAGE_EFFECT_VIDBOIDS },
{ ghost_malloc, ghost_free, VJ_IMAGE_EFFECT_GHOST },
{ neighbours_malloc, neighbours_free, VJ_IMAGE_EFFECT_NEIGHBOUR },
{ neighbours2_malloc, neighbours2_free, VJ_IMAGE_EFFECT_NEIGHBOUR2 },
{ neighbours3_malloc, neighbours3_free, VJ_IMAGE_EFFECT_NEIGHBOUR3 },
{ neighbours4_malloc, neighbours4_free, VJ_IMAGE_EFFECT_NEIGHBOUR4 },
{ neighbours5_malloc, neighbours5_free, VJ_IMAGE_EFFECT_NEIGHBOUR5 },
{ cutstop_malloc, cutstop_free, VJ_IMAGE_EFFECT_CUTSTOP },
{ maskstop_malloc, maskstop_free, VJ_IMAGE_EFFECT_MASKSTOP },
{ photoplay_malloc, photoplay_free, VJ_IMAGE_EFFECT_PHOTOPLAY },
{ videoplay_malloc, videoplay_free, VJ_VIDEO_EFFECT_VIDEOPLAY },
{ videowall_malloc, videowall_free, VJ_VIDEO_EFFECT_VIDEOWALL },
{ flare_malloc, flare_free, VJ_IMAGE_EFFECT_FLARE },
{ timedistort_malloc, timedistort_free, VJ_IMAGE_EFFECT_TIMEDISTORT },
{ chameleon_malloc, chameleon_free, VJ_IMAGE_EFFECT_CHAMELEON },
{ chameleonblend_malloc, chameleonblend_free,VJ_VIDEO_EFFECT_CHAMBLEND },
{ baltantv_malloc, baltantv_free, VJ_IMAGE_EFFECT_BALTANTV },
{ radcor_malloc, radcor_free, VJ_IMAGE_EFFECT_LENSCORRECTION },
{ radioactivetv_malloc, radioactivetv_free, VJ_VIDEO_EFFECT_RADIOACTIVE },
{ waterrippletv_malloc, waterrippletv_free, VJ_IMAGE_EFFECT_RIPPLETV },
{ bgsubtract_malloc, bgsubtract_free, VJ_IMAGE_EFFECT_BGSUBTRACT },
{ bgsubtractgauss_malloc, bgsubtractgauss_free, VJ_IMAGE_EFFECT_BGSUBTRACTGAUSS },
{ slicer_malloc, slicer_free, VJ_VIDEO_EFFECT_SLICER },
{ perspective_malloc, perspective_free, VJ_IMAGE_EFFECT_PERSPECTIVE },
{ feathermask_malloc, feathermask_free, VJ_IMAGE_EFFECT_ALPHAFEATHERMASK },
{ average_malloc, average_free, VJ_IMAGE_EFFECT_AVERAGE },
{ rgbkey_malloc, rgbkey_free, VJ_VIDEO_EFFECT_RGBKEY },
{ gaussblur_malloc, gaussblur_free, VJ_IMAGE_EFFECT_CHOKEMATTE },
{ NULL , NULL ,0 },
{ bathroom_malloc,bathroom_free,NULL,VJ_IMAGE_EFFECT_BATHROOM },
{ chromascratcher_malloc, chromascratcher_free,NULL,VJ_IMAGE_EFFECT_CHROMASCRATCHER},
{ complexsync_malloc,complexsync_free,NULL,VJ_VIDEO_EFFECT_COMPLEXSYNC },
{ dices_malloc,dices_free,NULL,VJ_IMAGE_EFFECT_DICES},
{ colorhis_malloc,colorhis_free,NULL,VJ_IMAGE_EFFECT_COLORHIS},
{ autoeq_malloc,autoeq_free,NULL,VJ_IMAGE_EFFECT_AUTOEQ},
{ magicscratcher_malloc,magicscratcher_free,NULL,VJ_IMAGE_EFFECT_MAGICSCRATCHER},
{ lumamask_malloc,lumamask_free,NULL,VJ_VIDEO_EFFECT_LUMAMASK},
{ motionblur_malloc,motionblur_free,NULL,VJ_IMAGE_EFFECT_MOTIONBLUR },
{ magicmirror_malloc,magicmirror_free,NULL,VJ_IMAGE_EFFECT_MAGICMIRROR },
{ mtracer_malloc,mtracer_free,NULL,VJ_VIDEO_EFFECT_MTRACER},
{ noiseadd_malloc,noiseadd_free,NULL,VJ_IMAGE_EFFECT_NOISEADD},
{ noisepencil_malloc,noisepencil_free,NULL,VJ_IMAGE_EFFECT_NOISEPENCIL},
{ reflection_malloc,reflection_free,NULL,VJ_IMAGE_EFFECT_REFLECTION},
{ ripple_malloc,ripple_free,NULL,VJ_IMAGE_EFFECT_RIPPLE},
{ rotozoom_malloc,rotozoom_free,NULL,VJ_IMAGE_EFFECT_ROTOZOOM},
{ scratcher_malloc,scratcher_free,NULL,VJ_IMAGE_EFFECT_SCRATCHER},
{ sinoids_malloc, sinoids_free,NULL,VJ_IMAGE_EFFECT_SINOIDS},
{ slice_malloc,slice_free,NULL,VJ_IMAGE_EFFECT_SLICE},
{ split_malloc,split_free,NULL,VJ_VIDEO_EFFECT_SPLIT},
{ tracer_malloc,tracer_free,NULL,VJ_VIDEO_EFFECT_TRACER},
{ zoom_malloc,zoom_free,NULL,VJ_IMAGE_EFFECT_ZOOM},
{ crosspixel_malloc,crosspixel_free,NULL,VJ_IMAGE_EFFECT_CROSSPIXEL},
{ fisheye_malloc, fisheye_free,NULL,VJ_IMAGE_EFFECT_FISHEYE},
{ swirl_malloc,swirl_free,NULL,VJ_IMAGE_EFFECT_SWIRL},
{ radialblur_malloc,radialblur_free,NULL,VJ_IMAGE_EFFECT_RADIALBLUR},
{ uvcorrect_malloc,uvcorrect_free,NULL,VJ_IMAGE_EFFECT_UVCORRECT},
{ overclock_malloc,overclock_free,NULL,VJ_IMAGE_EFFECT_OVERCLOCK},
{ nervous_malloc,nervous_free,NULL,VJ_IMAGE_EFFECT_NERVOUS},
{ morphology_malloc,morphology_free,NULL,VJ_IMAGE_EFFECT_MORPHOLOGY},
{ differencemap_malloc,differencemap_free,NULL,VJ_VIDEO_EFFECT_EXTDIFF},
{ threshold_malloc,threshold_free,NULL,VJ_VIDEO_EFFECT_EXTTHRESHOLD},
{ motionmap_malloc,motionmap_free,NULL,VJ_IMAGE_EFFECT_MOTIONMAP},
{ colmorphology_malloc,colmorphology_free,NULL,VJ_IMAGE_EFFECT_COLMORPH},
{ blob_malloc,blob_free,NULL,VJ_IMAGE_EFFECT_VIDBLOB},
{ boids_malloc,boids_free,NULL,VJ_IMAGE_EFFECT_VIDBOIDS},
{ ghost_malloc,ghost_free,NULL,VJ_IMAGE_EFFECT_GHOST},
{ neighbours_malloc,neighbours_free,NULL,VJ_IMAGE_EFFECT_NEIGHBOUR},
{ neighbours2_malloc,neighbours2_free,NULL,VJ_IMAGE_EFFECT_NEIGHBOUR2},
{ neighbours3_malloc,neighbours3_free,NULL,VJ_IMAGE_EFFECT_NEIGHBOUR3},
{ neighbours4_malloc,neighbours4_free,NULL,VJ_IMAGE_EFFECT_NEIGHBOUR4},
{ neighbours5_malloc,neighbours5_free,NULL,VJ_IMAGE_EFFECT_NEIGHBOUR5},
{ cutstop_malloc,cutstop_free,NULL,VJ_IMAGE_EFFECT_CUTSTOP},
{ maskstop_malloc,maskstop_free,NULL,VJ_IMAGE_EFFECT_MASKSTOP},
{ photoplay_malloc,photoplay_free,NULL,VJ_IMAGE_EFFECT_PHOTOPLAY},
{ videoplay_malloc,videoplay_free,NULL,VJ_VIDEO_EFFECT_VIDEOPLAY},
{ videowall_malloc,videowall_free,NULL,VJ_VIDEO_EFFECT_VIDEOWALL},
{ flare_malloc,flare_free,NULL,VJ_IMAGE_EFFECT_FLARE},
{ timedistort_malloc,timedistort_free,NULL,VJ_IMAGE_EFFECT_TIMEDISTORT},
{ chameleon_malloc,chameleon_free,NULL,VJ_IMAGE_EFFECT_CHAMELEON},
{ chameleonblend_malloc,chameleonblend_free,NULL,VJ_VIDEO_EFFECT_CHAMBLEND},
{ baltantv_malloc,baltantv_free,NULL,VJ_IMAGE_EFFECT_BALTANTV},
{ radcor_malloc,radcor_free,NULL,VJ_IMAGE_EFFECT_LENSCORRECTION},
{ radioactivetv_malloc,radioactivetv_free,NULL,VJ_VIDEO_EFFECT_RADIOACTIVE},
{ waterrippletv_malloc,waterrippletv_free,NULL,VJ_IMAGE_EFFECT_RIPPLETV},
{ bgsubtract_malloc,bgsubtract_free,bgsubtract_instances,VJ_IMAGE_EFFECT_BGSUBTRACT},
{ bgsubtractgauss_malloc,bgsubtractgauss_free,bgsubtractgauss_instances,VJ_IMAGE_EFFECT_BGSUBTRACTGAUSS},
{ slicer_malloc,slicer_free,NULL,VJ_VIDEO_EFFECT_SLICER},
{ perspective_malloc,perspective_free,NULL,VJ_IMAGE_EFFECT_PERSPECTIVE},
{ feathermask_malloc,feathermask_free,NULL,VJ_IMAGE_EFFECT_ALPHAFEATHERMASK },
{ average_malloc,average_free,NULL,VJ_IMAGE_EFFECT_AVERAGE},
{ rgbkey_malloc,rgbkey_free,NULL,VJ_VIDEO_EFFECT_RGBKEY},
{ gaussblur_malloc,gaussblur_free,NULL,VJ_IMAGE_EFFECT_CHOKEMATTE},
{ meanfilter_malloc,meanfilter_free,NULL,VJ_IMAGE_EFFECT_MEANFILTER},
{ NULL,NULL,NULL,0},
};
// complex effects have a buffer per instance
@@ -366,9 +369,9 @@ int vj_effect_initialized(int effect_id, void *instance_ptr )
return 0;
return 1;
}
else if ( _no_mem_required( effect_id ) || vj_effect_ready[ effect_id ] == 1 )
else if ( _no_mem_required( effect_id ) || vj_effect_ready[ effect_id ] == 1 ) {
return 1;
}
return 0;
}
@@ -394,6 +397,26 @@ int vj_effect_is_parallel(int effect_id)
int seq = vj_effect_real_to_sequence(effect_id);
return vj_effects[seq]->parallel;
}
int vj_effect_single_instance(int effect_id)
{
int seq = vj_effect_real_to_sequence(effect_id);
if( seq < 0 ) {
return 0;
}
if(!vj_effect_ready[seq] )
return 0;
int index = _get_simple_effect(effect_id);
if( index >= 0 && simple_effect_index[index].num_instances != NULL &&
simple_effect_index[index].num_instances() > 0 ) {
veejay_msg(0, "FX %d can only be used once ...", effect_id );
return 1;
}
return 0;
}
void *vj_effect_activate(int effect_id, int *result)
{
int seq = vj_effect_real_to_sequence(effect_id);
@@ -438,6 +461,7 @@ void *vj_effect_activate(int effect_id, int *result)
return NULL;
}
}
if(!simple_effect_index[index].mem_init( max_width, max_height ))
{
*result = 0;
@@ -459,7 +483,7 @@ void *vj_effect_get_data( int seq_id ) {
return vj_effects[seq_id]->user_data;
}
int vj_effect_deactivate(int effect_id, void *ptr)
int vj_effect_deactivate(int effect_id, void *ptr, int global)
{
int seq = vj_effect_real_to_sequence(effect_id);
@@ -473,6 +497,10 @@ int vj_effect_deactivate(int effect_id, void *ptr)
return 1;
}
} else if( vj_effect_ready[seq] == 1 ) {
if( vj_effects[seq]->global && !global )
return 1; //do not free this effect
int index = _get_simple_effect(effect_id);
if(index==-1) {
index = _get_complex_effect(effect_id);
@@ -499,7 +527,7 @@ static void vj_effect_deactivate_all()
{
if( vj_effects[ i ] == NULL )
continue;
vj_effect_deactivate( i, NULL );
vj_effect_deactivate( i, NULL,1 );
}
}
@@ -686,6 +714,7 @@ void vj_effect_initialize(int width, int height, int full_range)
vj_effects[VJ_IMAGE_EFFECT_LEVELCORRECTION] = levelcorrection_init(width,height);
vj_effects[VJ_IMAGE_EFFECT_ALPHADAMPEN] = alphadampen_init(width,height);
vj_effects[VJ_IMAGE_EFFECT_RANDNOISE] = randnoise_init(width,height);
vj_effects[VJ_IMAGE_EFFECT_MEANFILTER] = meanfilter_init(width,height);
max_width = width;
max_height = height;

View File

@@ -455,6 +455,9 @@ static void vj_effman_apply_image_effect(
case VJ_IMAGE_EFFECT_RANDNOISE:
randnoise_apply( frames[0], arg[0],arg[1] );
break;
case VJ_IMAGE_EFFECT_MEANFILTER:
meanfilter_apply( frames[0] );
break;
}
}

View File

@@ -104,6 +104,7 @@ typedef struct vj_effect_t {
int rgba_only;
int motion;
int alpha;
int global;
} vj_effect;
extern unsigned int get_pixel_range_min_Y();
@@ -117,6 +118,7 @@ extern const char *vj_effect_get_description(int effect_id);
extern const char *vj_effect_get_param_description(int effect_id, int param_nr);
extern int vj_effect_get_extra_frame(int effect_id);
extern int vj_effect_get_num_params(int effect_id);
extern int vj_effect_single_instance(int effect_id);
extern int vj_effect_get_default(int effect_id, int param_nr);
extern int vj_effect_get_min_limit(int effect_id, int param_nr);
extern int vj_effect_get_max_limit(int effect_id, int param_nr);
@@ -128,7 +130,7 @@ extern int vj_effect_is_valid(int effect_id);
extern int vj_effect_get_summary(int entry, char *dst);
extern int vj_effect_get_summary_len(int entry);
extern void *vj_effect_activate(int e, int *retcode);
extern int vj_effect_deactivate(int e, void *ptr);
extern int vj_effect_deactivate(int e, void *ptr, int global);
extern int vj_effect_initialized(int e, void *ptr);
extern int vj_effect_get_by_name(char *name);
extern int vj_effect_apply( VJFrame **frames, VJFrameInfo *frameinfo, vjp_kf *kf, int selector, int *arguments, void *ptr);

View File

@@ -567,7 +567,7 @@ static int veejay_stop_playing_sample( veejay_t *info, int new_sample_id )
}
}
sample_chain_free( info->uc->sample_id );
sample_chain_free( info->uc->sample_id,0);
sample_set_framedups(info->uc->sample_id,0);
sample_set_resume(info->uc->sample_id, info->settings->current_frame_num );
@@ -582,7 +582,7 @@ static void veejay_stop_playing_stream( veejay_t *info, int new_stream_id )
}
}
vj_tag_chain_free( info->uc->sample_id );
vj_tag_chain_free( info->uc->sample_id, 0);
}
static int veejay_start_playing_sample( veejay_t *info, int sample_id )
{