mirror of
https://github.com/game-stop/veejay.git
synced 2026-01-05 22:45:30 +01:00
add cosmichue fx
This commit is contained in:
@@ -209,6 +209,7 @@ libvje_la_SOURCES = libvje.c vjert.c \
|
||||
effects/camerabounce.c \
|
||||
effects/flashopacity.c \
|
||||
effects/colortemp.c \
|
||||
effects/cosmichue.c \
|
||||
effects/blackreplace.c
|
||||
|
||||
|
||||
|
||||
119
veejay-current/veejay-server/libvje/effects/cosmichue.c
Normal file
119
veejay-current/veejay-server/libvje/effects/cosmichue.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Linux VeeJay
|
||||
*
|
||||
* Copyright(C)2023 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 "common.h"
|
||||
#include <veejaycore/vjmem.h>
|
||||
#include "cosmichue.h"
|
||||
|
||||
vj_effect *cosmichue_init(int w, int h)
|
||||
{
|
||||
vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect));
|
||||
ve->num_params = 4;
|
||||
|
||||
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;
|
||||
ve->limits[1][0] = 2000;
|
||||
ve->defaults[0] = 100;
|
||||
|
||||
ve->limits[0][1] = 0;
|
||||
ve->limits[1][1] = 2000;
|
||||
ve->defaults[1] = 100;
|
||||
|
||||
ve->limits[0][2] = 0;
|
||||
ve->limits[1][2] = 255;
|
||||
ve->defaults[2] = 100;
|
||||
|
||||
ve->limits[0][3] = 0;
|
||||
ve->limits[1][3] = 3600;
|
||||
ve->defaults[3] = 0;
|
||||
|
||||
ve->description = "Cosmic Hue";
|
||||
ve->sub_format = 1;
|
||||
ve->extra_frame = 0;
|
||||
ve->parallel = 1;
|
||||
ve->has_user = 0;
|
||||
ve->param_description = vje_build_param_list( ve->num_params, "Amplitude", "Frequency", "Opacity", "Hue Shift" );
|
||||
return ve;
|
||||
}
|
||||
|
||||
void cosmichue_apply( void *ptr, VJFrame *frame, int *args ) {
|
||||
const int opacity = args[2];
|
||||
|
||||
int i;
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *U = frame->data[1];
|
||||
uint8_t *V = frame->data[2];
|
||||
|
||||
const float amplitude = args[0] * 0.1f;
|
||||
const float frequency = args[1] * 0.1f;
|
||||
float hue_shift = args[3] * 0.1f;
|
||||
|
||||
float sin_lut[256];
|
||||
float cos_lut[256];
|
||||
|
||||
float hsin_lut[256];
|
||||
float hcos_lut[256];
|
||||
|
||||
float angle_step = (2*M_PI/256.0f);
|
||||
|
||||
hue_shift = hue_shift * (M_PI/180.0f);
|
||||
hue_shift = fmod(hue_shift, 2 * M_PI);
|
||||
if (hue_shift < 0) {
|
||||
hue_shift += 2 * M_PI;
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i ++ ) {
|
||||
float luminance = i / 255.0f;
|
||||
float angle = i * angle_step;
|
||||
sin_lut[i] = amplitude * a_sin( frequency * luminance );
|
||||
cos_lut[i] = amplitude * a_cos( frequency * luminance );
|
||||
hsin_lut[i] = a_sin( angle );
|
||||
hcos_lut[i] = a_cos( angle );
|
||||
}
|
||||
|
||||
const int angle_index = (int)((hue_shift / (2 * M_PI)) * 256) % 256;
|
||||
|
||||
for (i = 0; i < frame->len; i++) {
|
||||
|
||||
int u = U[i] - 128;
|
||||
int v = V[i] - 128;
|
||||
|
||||
float u_offset = sin_lut[ Y[i] ];
|
||||
float v_offset = cos_lut[ Y[i] ];
|
||||
|
||||
u = (int)(u_offset + u);
|
||||
v = (int)(v_offset + v);
|
||||
|
||||
float cos_val = hcos_lut[angle_index];
|
||||
float sin_val = hsin_lut[angle_index];
|
||||
|
||||
int u_rotated = 128 + (int)(u * cos_val - v * sin_val);
|
||||
int v_rotated = 128 + (int)(u * sin_val + v * cos_val);
|
||||
|
||||
u_rotated = (u_rotated + (u_rotated >> 31)) ^ (u_rotated >> 31);
|
||||
v_rotated = (v_rotated + (v_rotated >> 31)) ^ (v_rotated >> 31);
|
||||
|
||||
U[i] = (uint8_t)((opacity * u_rotated + (0xff - opacity) * U[i]) >> 8);
|
||||
V[i] = (uint8_t)((opacity * v_rotated + (0xff - opacity) * V[i]) >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
25
veejay-current/veejay-server/libvje/effects/cosmichue.h
Normal file
25
veejay-current/veejay-server/libvje/effects/cosmichue.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Linux VeeJay
|
||||
*
|
||||
* Copyright(C)2023 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 COSMICHUE_H
|
||||
#define COSMICHUE_H
|
||||
vj_effect *cosmichue_init(int w, int h);
|
||||
void cosmichue_apply(void *ptr, VJFrame *frame, int *args);
|
||||
#endif
|
||||
@@ -220,8 +220,9 @@
|
||||
#include "./effects/camerabounce.h"
|
||||
#include "./effects/flashopacity.h"
|
||||
#include "./effects/colortemp.h"
|
||||
#include "./effects/cosmichue.h"
|
||||
|
||||
#define VJ_IMAGE_EFFECT_MIN 68
|
||||
#define VJ_IMAGE_EFFECT_MIN 67
|
||||
#define VJ_IMAGE_EFFECT_MAX 199
|
||||
|
||||
#define VJ_VIDEO_EFFECT_MIN 200
|
||||
@@ -475,6 +476,7 @@ enum {
|
||||
VJ_IMAGE_EFFECT_LUMINOUSWAVE = 70,
|
||||
VJ_IMAGE_EFFECT_CAMERABOUNCE = 69,
|
||||
VJ_IMAGE_EFFECT_COLORTEMP = 68,
|
||||
VJ_IMAGE_EFFECT_COSMICHUE = 67,
|
||||
VJ_IMAGE_EFFECT_DUMMY=0,
|
||||
};
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ static struct {
|
||||
{ neighbours5_init,neighbours5_malloc,neighbours5_free,NULL,NULL,neighbours5_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_NEIGHBOUR5 },
|
||||
{ negation_init,NULL,NULL,NULL,NULL,negation_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_NEGATION },
|
||||
{ colortemp_init,NULL,NULL,NULL,NULL,colortemp_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_COLORTEMP },
|
||||
{ cosmichue_init,NULL,NULL,NULL,NULL,cosmichue_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_COSMICHUE },
|
||||
{ rainbowshift_init, NULL,NULL,NULL,NULL, rainbowshift_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_RAINBOWSHIFT },
|
||||
{ vintagefilm_init,NULL,NULL,NULL,NULL, vintagefilm_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_VINTAGEFILM },
|
||||
{ mirrordistortion_init,mirrordistortion_malloc,mirrordistortion_free,NULL,NULL,mirrordistortion_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_MIRRORDISTORTION },
|
||||
|
||||
Reference in New Issue
Block a user