mirror of
https://github.com/game-stop/veejay.git
synced 2026-01-06 15:05:28 +01:00
revert changes to luma key, create new FX luma key composite
This commit is contained in:
@@ -97,6 +97,6 @@ libvje_la_SOURCES = vj-effect.c vj-effman.c effects/common.c \
|
||||
effects/videowall.c effects/flare.c effects/radioactive.c effects/baltantv.c effects/constantblend.c effects/picinpic.c effects/bgsubtract.c effects/cali.c effects/median.c effects/average-blend.c effects/perspective.c \
|
||||
effects/toalpha.c effects/mixtoalpha.c effects/alpha2img.c effects/alphafill.c effects/alphaflatten.c \
|
||||
effects/magicalphaoverlays.c effects/travelmatte.c effects/feathermask.c effects/alphaselect.c \
|
||||
effects/alphaselect2.c effects/alphablend.c effects/porterduff.c effects/alphanegate.c
|
||||
effects/alphaselect2.c effects/alphablend.c effects/porterduff.c effects/alphanegate.c effects/lumakeyalpha.c
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ vj_effect *lumakey_init(int width, int height)
|
||||
ve->limits[0][3] = 1; /* distance */
|
||||
ve->limits[1][3] = width;
|
||||
ve->limits[0][4] = 0; /* type */
|
||||
ve->limits[1][4] = 3;
|
||||
ve->limits[1][4] = 2;
|
||||
ve->defaults[0] = 255;
|
||||
ve->defaults[1] = 150;
|
||||
ve->defaults[2] = 200;
|
||||
@@ -54,45 +54,6 @@ vj_effect *lumakey_init(int width, int height)
|
||||
return ve;
|
||||
}
|
||||
|
||||
|
||||
void lumakey_simple_alpha(uint8_t *yuv1[4], uint8_t *yuv2[4], int width,
|
||||
int height, int threshold, int threshold2, int opacity)
|
||||
{
|
||||
|
||||
unsigned int x, y, len = width * height;
|
||||
uint8_t a1, a2;
|
||||
unsigned int op0, op1;
|
||||
uint8_t Y, Cb, Cr, alpha;
|
||||
op1 = (opacity > 255) ? 255 : opacity;
|
||||
op0 = 255 - op1;
|
||||
|
||||
for (y = 0; y < len; y += width) {
|
||||
for (x = 0; x < width; x++) {
|
||||
alpha = yuv2[3][x + y];
|
||||
if( alpha == 0 ) // simply skip when alpha = 0
|
||||
continue;
|
||||
|
||||
a1 = yuv1[0][x + y];
|
||||
a2 = yuv2[0][x + y];
|
||||
|
||||
if (a1 >= threshold && a1 <= threshold2) {
|
||||
alpha = ((op0 * yuv1[3][x+y]) + (op1 * yuv2[3][x+y]) )>> 8;
|
||||
unsigned int aA = 255 - alpha;
|
||||
unsigned int aB = alpha;
|
||||
|
||||
Y = ((aA * a1) + (aB * a2)) >> 8;
|
||||
Cb = ((aA * yuv1[1][x + y]) + (aB * yuv2[1][x + y])) >> 8;
|
||||
Cr = ((aA * yuv1[2][x + y]) + (aB * yuv2[2][x + y])) >> 8;
|
||||
yuv1[0][x + y] = Y; // < 16 ? 16 : Y > 235 ? 235 : Y;
|
||||
yuv1[1][x + y] = Cb; // < 16 ? 16 : Cb > 240 ? 240 : Cb;
|
||||
yuv1[2][x + y] = Cr; // < 16 ? 16 : Cr > 240 ? 240 : Cr;
|
||||
yuv1[3][x + y] = alpha; // simply overwrite
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lumakey_simple(uint8_t * yuv1[3], uint8_t * yuv2[3], int width,
|
||||
int height, int threshold, int threshold2, int opacity)
|
||||
{
|
||||
@@ -357,10 +318,6 @@ void lumakey_apply( VJFrame *frame, VJFrame *frame2, int width,
|
||||
case 2:
|
||||
lumakey_smooth(frame->data, frame2->data, width, height, threshold, threshold2,feather, d);
|
||||
break;
|
||||
case 3:
|
||||
lumakey_simple_alpha(frame->data, frame2->data, width, height, threshold, threshold2,feather);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
void lumakey_free(){}
|
||||
|
||||
@@ -28,6 +28,4 @@ vj_effect *lumakey_init();
|
||||
void lumakey_apply( VJFrame *frame, VJFrame *frame2, int width,
|
||||
int height, int type, int threshold, int threshold2,
|
||||
int feather, int d);
|
||||
|
||||
void lumakey_free();
|
||||
#endif
|
||||
|
||||
170
veejay-current/veejay-server/libvje/effects/lumakeyalpha.c
Normal file
170
veejay-current/veejay-server/libvje/effects/lumakeyalpha.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Linux VeeJay
|
||||
*
|
||||
* Copyright(C)2015 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 <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <libvjmem/vjmem.h>
|
||||
#include "lumakeyalpha.h"
|
||||
#include "common.h"
|
||||
|
||||
vj_effect *lumakeyalpha_init(int width, int height)
|
||||
{
|
||||
vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect));
|
||||
ve->num_params = 2;
|
||||
ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */
|
||||
ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */
|
||||
ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */
|
||||
ve->limits[0][0] = 0; /* type */
|
||||
ve->limits[1][0] = 8;
|
||||
ve->limits[0][1] = 0; /* opacity */
|
||||
ve->limits[1][1] = 255;
|
||||
ve->defaults[0] = 0;
|
||||
ve->defaults[1] = 150;
|
||||
ve->description = "Alpha: Luma Key composite";
|
||||
ve->extra_frame = 1;
|
||||
ve->sub_format = 1;
|
||||
ve->parallel = 1;
|
||||
ve->has_user = 0;
|
||||
ve->param_description = vje_build_param_list(ve->num_params, "Selector Mode", "Opacity" );
|
||||
|
||||
return ve;
|
||||
}
|
||||
|
||||
void lumakeyalpha_apply( VJFrame *frame, VJFrame *frame2, int width,int height, int type, int opacity )
|
||||
{
|
||||
unsigned int i, len = width * height;
|
||||
unsigned int op1 = (opacity > 255) ? 255 : opacity;
|
||||
unsigned int op0 = 255 - op1;
|
||||
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *Y2 = frame2->data[0];
|
||||
uint8_t *aA = frame->data[3];
|
||||
uint8_t *aB = frame2->data[3];
|
||||
uint8_t *Cb = frame->data[1];
|
||||
uint8_t *Cb2 =frame2->data[1];
|
||||
uint8_t *Cr = frame->data[2];
|
||||
uint8_t *Cr2= frame2->data[2];
|
||||
|
||||
switch( type ) {
|
||||
case 0:
|
||||
for( i = 0; i < len; i ++ ) { /* skip alpha-IN 0 */
|
||||
if( aA[i] == 0 )
|
||||
continue;
|
||||
|
||||
Y[i] = (op0 * Y[i] + op1 * Y2[i]) >> 8;
|
||||
Cb[i]= (op0 * Cb[i] + op1 * Cb2[i])>> 8;
|
||||
Cr[i]= (op0 * Cr[i] + op1 * Cr2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
case 1: /* skip alpha-IN 1 */
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aB[i] == 0 )
|
||||
continue;
|
||||
|
||||
Y[i] = (op0 * Y[i] + op1 * Y2[i]) >> 8;
|
||||
Cb[i]= (op0 * Cb[i] + op1 * Cb2[i])>> 8;
|
||||
Cr[i]= (op0 * Cr[i] + op1 * Cr2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
case 2: /* skip alpa-IN 0 or alpha-IN 1 */
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aB[i] == 0 || aA[i] == 0 )
|
||||
continue;
|
||||
|
||||
Y[i] = (op0 * Y[i] + op1 * Y2[i]) >> 8;
|
||||
Cb[i]= (op0 * Cb[i] + op1 * Cb2[i])>> 8;
|
||||
Cr[i]= (op0 * Cr[i] + op1 * Cr2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
case 3: /* skip if both */
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aB[i] == 0 && aA[i] == 0 )
|
||||
continue;
|
||||
|
||||
Y[i] = (op0 * Y[i] + op1 * Y2[i]) >> 8;
|
||||
Cb[i]= (op0 * Cb[i] + op1 * Cb2[i])>> 8;
|
||||
Cr[i]= (op0 * Cr[i] + op1 * Cr2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: /* transparent */
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aA[i] == 0 )
|
||||
continue;
|
||||
uint8_t ab = (op0 * aB[i] + op1 * aA[i])>> 8;
|
||||
uint8_t aa = 0xff - ab;
|
||||
|
||||
Y[i] = (aa * Y[i] + ab * Y2[i]) >> 8;
|
||||
Cb[i]= (aa * Cb[i] + ab * Y2[i])>> 8;
|
||||
Cr[i]= (aa * Cr[i] + ab * Y2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aB[i] == 0 )
|
||||
continue;
|
||||
uint8_t ab = (op0 * aB[i] + op1 * aA[i])>> 8;
|
||||
uint8_t aa = 0xff - ab;
|
||||
|
||||
Y[i] = (aa * Y[i] + ab * Y2[i]) >> 8;
|
||||
Cb[i]= (aa * Cb[i] + ab * Y2[i])>> 8;
|
||||
Cr[i]= (aa * Cr[i] + ab * Y2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aA[i] == 0 || aB[i] == 0 )
|
||||
continue;
|
||||
uint8_t ab = (op0 * aB[i] + op1 * aA[i])>> 8;
|
||||
uint8_t aa = 0xff - ab;
|
||||
|
||||
Y[i] = (aa * Y[i] + ab * Y2[i]) >> 8;
|
||||
Cb[i]= (aa * Cb[i] + ab * Y2[i])>> 8;
|
||||
Cr[i]= (aa * Cr[i] + ab * Y2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aA[i] == 0 && aB[i] == 0 )
|
||||
continue;
|
||||
uint8_t ab = (op0 * aB[i] + op1 * aA[i])>> 8;
|
||||
uint8_t aa = 0xff - ab;
|
||||
|
||||
Y[i] = (aa * Y[i] + ab * Y2[i]) >> 8;
|
||||
Cb[i]= (aa * Cb[i] + ab * Y2[i])>> 8;
|
||||
Cr[i]= (aa * Cr[i] + ab * Y2[i])>> 8;
|
||||
}
|
||||
break;
|
||||
case 8: // write back
|
||||
for( i = 0; i < len; i ++ ) {
|
||||
if( aA[i] == 0 || aB[i] == 0 )
|
||||
continue;
|
||||
uint8_t ab = (op0 * aB[i] + op1 * aA[i])>> 8;
|
||||
uint8_t aa = 0xff - ab;
|
||||
|
||||
Y[i] = (aa * Y[i] + ab * Y2[i]) >> 8;
|
||||
Cb[i]= (aa * Cb[i] + ab * Y2[i])>> 8;
|
||||
Cr[i]= (aa * Cr[i] + ab * Y2[i])>> 8;
|
||||
aA[i]= aa;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
29
veejay-current/veejay-server/libvje/effects/lumakeyalpha.h
Normal file
29
veejay-current/veejay-server/libvje/effects/lumakeyalpha.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Linux VeeJay
|
||||
*
|
||||
* Copyright(C)2002-2015 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 LUMAKEYA_H
|
||||
#define LUMAKEYA_H
|
||||
#include <libvje/vje.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
vj_effect *lumakeyalpha_init(int w, int h);
|
||||
void lumakeyalpha_apply( VJFrame *frame, VJFrame *frame2, int width, int height, int type, int opacity );
|
||||
#endif
|
||||
@@ -30,7 +30,7 @@
|
||||
#define VJ_IMAGE_EFFECT_MAX 199
|
||||
|
||||
#define VJ_VIDEO_EFFECT_MIN 200
|
||||
#define VJ_VIDEO_EFFECT_MAX 253
|
||||
#define VJ_VIDEO_EFFECT_MAX 254
|
||||
|
||||
#define VJ_PLUGIN 500
|
||||
|
||||
@@ -135,7 +135,8 @@ enum {
|
||||
VJ_VIDEO_EFFECT_MAGICALPHA = 249,
|
||||
VJ_VIDEO_EFFECT_TRAVELMATTE = 250,
|
||||
VJ_VIDEO_EFFECT_ALPHABLEND = 251,
|
||||
VJ_VIDEO_EFFECT_PORTERDUFF = 252,
|
||||
VJ_VIDEO_EFFECT_PORTERDUFF = 252,
|
||||
VJ_VIDEO_EFFECT_LUMAKEYALPHA = 253,
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -653,6 +654,7 @@ extern void overlayalphamagic_apply(VJFrame *frame, VJFrame *frame2, int width,i
|
||||
extern void travelmatte_apply( VJFrame *frame, VJFrame *frame2, int width,int height, int mode);
|
||||
extern void feathermask_apply( VJFrame *frame, int width, int height );
|
||||
extern void alphaselect_apply( VJFrame *frame, int width,int height, int i_angle, int r, int g,int b, int swap);
|
||||
void alphaselect2_apply( VJFrame *frame, int width,int height, int tola, int r, int g,int b, int tolb, int show, int alpha);
|
||||
void alphablend_apply( VJFrame *frame, VJFrame *frame2, int width,int height);
|
||||
extern void alphaselect2_apply( VJFrame *frame, int width,int height, int tola, int r, int g,int b, int tolb, int show, int alpha);
|
||||
extern void alphablend_apply( VJFrame *frame, VJFrame *frame2, int width,int height);
|
||||
extern void lumakeyalpha_apply( VJFrame *frame, VJFrame *frame2, int width, int height, int type, int opacity );
|
||||
#endif
|
||||
|
||||
@@ -556,6 +556,7 @@ void vj_effect_initialize(int width, int height, int full_range)
|
||||
vj_effects[VJ_VIDEO_EFFECT_TRAVELMATTE] = travelmatte_init(width,height);
|
||||
vj_effects[VJ_VIDEO_EFFECT_ALPHABLEND] = alphablend_init(width,height);
|
||||
vj_effects[VJ_VIDEO_EFFECT_PORTERDUFF] = porterduff_init(width,height);
|
||||
vj_effects[VJ_VIDEO_EFFECT_LUMAKEYALPHA] = lumakeyalpha_init(width,height);
|
||||
|
||||
vj_effects[VJ_IMAGE_EFFECT_DUMMY] = dummy_init(width,height);
|
||||
|
||||
|
||||
@@ -676,6 +676,9 @@ void vj_effman_apply_video_effect( VJFrame **frames, vjp_kf *todo_info,int *arg,
|
||||
case VJ_VIDEO_EFFECT_PORTERDUFF:
|
||||
porterduff_apply(frames[0],frames[1],frames[0]->width,frames[0]->height,arg[0]);
|
||||
break;
|
||||
case VJ_VIDEO_EFFECT_LUMAKEYALPHA:
|
||||
lumakeyalpha_apply(frames[0],frames[1],frames[0]->width,frames[0]->height,arg[0],arg[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#define FX_LIMIT 1024
|
||||
|
||||
#define MAX_EFFECTS 155
|
||||
#define MAX_EFFECTS 156
|
||||
#define PARAM_WIDTH (1<<0x2)
|
||||
#define PARAM_HEIGHT (1<<0x3)
|
||||
#define PARAM_FADER (1<<0x1)
|
||||
|
||||
Reference in New Issue
Block a user