mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-23 08:09:58 +01:00
add luminous wave, ripplewave and rewrite rotozoom
This commit is contained in:
@@ -202,6 +202,9 @@ libvje_la_SOURCES = libvje.c vjert.c \
|
|||||||
effects/shutterdrag.c \
|
effects/shutterdrag.c \
|
||||||
effects/pointilism.c \
|
effects/pointilism.c \
|
||||||
effects/smartblur.c \
|
effects/smartblur.c \
|
||||||
|
effects/wave.c \
|
||||||
|
effects/ripplewave.c \
|
||||||
|
effects/luminouswave.c \
|
||||||
effects/blackreplace.c
|
effects/blackreplace.c
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,28 +86,21 @@ extern int vje_get_rgb_parameter_conversion_type();
|
|||||||
#define do_emms __asm__ __volatile__ ( "emms":::"memory" )
|
#define do_emms __asm__ __volatile__ ( "emms":::"memory" )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const double __B = 4.0 / M_PI;
|
||||||
|
static const double __C = -4.0 / (M_PI * M_PI);
|
||||||
|
static const double __P = 0.225;
|
||||||
|
|
||||||
static inline double a_sin( double x ) {
|
static inline double a_sin( double x ) {
|
||||||
const double B = 4.0 / M_PI;
|
|
||||||
const double C = -4.0 / (M_PI * M_PI);
|
|
||||||
const double P = 0.225;
|
|
||||||
|
|
||||||
x = fmod( x + M_PI, 2.0 * M_PI ) - M_PI;
|
x = fmod( x + M_PI, 2.0 * M_PI ) - M_PI;
|
||||||
|
|
||||||
double y = B * x + C * x * fabs(x);
|
double y = __B * x + __C * x * fabs(x);
|
||||||
|
|
||||||
return P * (y * fabs(y) - y) + y;
|
return __P * (y * fabs(y) - y) + y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double a_cos( double x ) {
|
static inline double a_cos( double x ) {
|
||||||
const double B = 4.0 / M_PI;
|
return a_sin( x + M_PI_2 );
|
||||||
const double C = -4.0 / (M_PI * M_PI);
|
|
||||||
const double P = 0.225;
|
|
||||||
|
|
||||||
x = fmod( x + M_PI , 2.0 * M_PI ) - M_PI;
|
|
||||||
|
|
||||||
double y = B * x + C * x * fabs(x);
|
|
||||||
|
|
||||||
return P * (y * fabs(y) - y) + y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCH_X86_64
|
#ifdef ARCH_X86_64
|
||||||
|
|||||||
148
veejay-current/veejay-server/libvje/effects/luminouswave.c
Normal file
148
veejay-current/veejay-server/libvje/effects/luminouswave.c
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* Linux VeeJay
|
||||||
|
*
|
||||||
|
* Copyright(C)2004 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 "luminouswave.h"
|
||||||
|
|
||||||
|
vj_effect *luminouswave_init(int w, int h) {
|
||||||
|
vj_effect *ve = (vj_effect *)vj_calloc(sizeof(vj_effect));
|
||||||
|
ve->num_params = 6;
|
||||||
|
|
||||||
|
ve->defaults = (int *)vj_calloc(sizeof(int) * ve->num_params);
|
||||||
|
ve->limits[0] = (int *)vj_calloc(sizeof(int) * ve->num_params);
|
||||||
|
ve->limits[1] = (int *)vj_calloc(sizeof(int) * ve->num_params);
|
||||||
|
|
||||||
|
ve->limits[0][0] = 0;
|
||||||
|
ve->limits[1][0] = 100;
|
||||||
|
ve->defaults[0] = 4;
|
||||||
|
ve->limits[0][1] = 1;
|
||||||
|
ve->limits[1][1] = 100;
|
||||||
|
ve->defaults[1] = 5;
|
||||||
|
|
||||||
|
ve->limits[0][2] = 0;
|
||||||
|
ve->limits[1][2] = 45;
|
||||||
|
ve->defaults[2] = 30;
|
||||||
|
|
||||||
|
ve->limits[0][3] = 0;
|
||||||
|
ve->limits[1][3] = 100;
|
||||||
|
ve->defaults[3] = 10;
|
||||||
|
|
||||||
|
ve->limits[0][4] = 0;
|
||||||
|
ve->limits[1][4] = 360;
|
||||||
|
ve->defaults[4] = 33;
|
||||||
|
|
||||||
|
ve->limits[0][5] = 0;
|
||||||
|
ve->limits[1][5] = 360;
|
||||||
|
ve->defaults[5] = 10;
|
||||||
|
|
||||||
|
ve->description = "Luminous Wave";
|
||||||
|
ve->sub_format = 1;
|
||||||
|
ve->extra_frame = 0;
|
||||||
|
ve->parallel = 0;
|
||||||
|
ve->has_user = 0;
|
||||||
|
ve->param_description = vje_build_param_list(ve->num_params, "Frequency X", "Frequency Y", "Amplitude", "Speed", "Angle X", "Angle Y" );
|
||||||
|
|
||||||
|
return ve;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float cos_lut[360];
|
||||||
|
float sin_lut[360];
|
||||||
|
uint8_t *buf[3];
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
float speed;
|
||||||
|
} luminouswave_t;
|
||||||
|
|
||||||
|
#define SIN_TABLE_SIZE 360
|
||||||
|
void* luminouswave_malloc(int w, int h) {
|
||||||
|
luminouswave_t *data = (luminouswave_t*) vj_malloc(sizeof(luminouswave_t));
|
||||||
|
if (!data)
|
||||||
|
return NULL;
|
||||||
|
data->buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 3);
|
||||||
|
if(!data->buf[0]) {
|
||||||
|
free(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->buf[1] = data->buf[0] + (w*h);
|
||||||
|
data->buf[2] = data->buf[1] + (w*h);
|
||||||
|
|
||||||
|
data->width = w;
|
||||||
|
data->height = h;
|
||||||
|
data->speed = 1.0;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void luminouswave_free(void *ptr) {
|
||||||
|
luminouswave_t *data = (luminouswave_t*) ptr;
|
||||||
|
if (data != NULL) {
|
||||||
|
free(data->buf[0]);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void luminouswave_apply(void *ptr, VJFrame *frame, int *args) {
|
||||||
|
luminouswave_t *data = (luminouswave_t*)ptr;
|
||||||
|
|
||||||
|
const int width = frame->width;
|
||||||
|
const int height = frame->height;
|
||||||
|
|
||||||
|
int x = 0, y;
|
||||||
|
|
||||||
|
const float frequencyX = args[0] * 0.01f;
|
||||||
|
const float frequencyY = args[1] * 0.01f;
|
||||||
|
const float amplitude = args[2];
|
||||||
|
const float speed = args[3] * 0.1f;
|
||||||
|
const int waveAngleX = args[4];
|
||||||
|
const int waveAngleY = args[5];
|
||||||
|
|
||||||
|
uint8_t *Y = frame->data[0];
|
||||||
|
|
||||||
|
float *sin_lut = data->sin_lut;
|
||||||
|
float *cos_lut = data->cos_lut;
|
||||||
|
|
||||||
|
data->speed += 0.1f;
|
||||||
|
if( data->speed > speed ) {
|
||||||
|
data->speed = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 360; i ++ ) {
|
||||||
|
sin_lut[i] = a_sin( i * (M_PI/180.0f) );
|
||||||
|
cos_lut[i] = a_cos( i * (M_PI/180.0f) );
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y = 0; y < height; y++) {
|
||||||
|
float offsetY = amplitude * a_sin(frequencyY * (x * sin_lut[waveAngleX] + y * cos_lut[waveAngleY]) + data->speed);
|
||||||
|
for (x = 0; x < width; x++) {
|
||||||
|
|
||||||
|
float offsetX = amplitude * a_sin(frequencyX * (x * cos_lut[waveAngleX] + y * sin_lut[waveAngleY]) + data->speed);
|
||||||
|
|
||||||
|
int luma = Y[y * width + x] + offsetX + offsetY;
|
||||||
|
|
||||||
|
Y[y*width+x] = (luma < pixel_Y_lo_) ? pixel_Y_lo_ : (luma > pixel_Y_hi_) ? pixel_Y_hi_ : luma;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
180
veejay-current/veejay-server/libvje/effects/ripplewave.c
Normal file
180
veejay-current/veejay-server/libvje/effects/ripplewave.c
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* Linux VeeJay
|
||||||
|
*
|
||||||
|
* Copyright(C)2004 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 "ripplewave.h"
|
||||||
|
|
||||||
|
vj_effect *ripplewave_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);
|
||||||
|
ve->limits[0] = (int *)vj_calloc(sizeof(int) * ve->num_params);
|
||||||
|
ve->limits[1] = (int *)vj_calloc(sizeof(int) * ve->num_params);
|
||||||
|
|
||||||
|
ve->limits[0][0] = 0;
|
||||||
|
ve->limits[1][0] = 100;
|
||||||
|
ve->defaults[0] = 10;
|
||||||
|
ve->limits[0][1] = 1;
|
||||||
|
ve->limits[1][1] = 100;
|
||||||
|
ve->defaults[1] = 15;
|
||||||
|
|
||||||
|
ve->limits[0][2] = 0;
|
||||||
|
ve->limits[1][2] = 45;
|
||||||
|
ve->defaults[2] = 30;
|
||||||
|
|
||||||
|
ve->limits[0][3] = 0;
|
||||||
|
ve->limits[1][3] = 100;
|
||||||
|
ve->defaults[3] = 10;
|
||||||
|
|
||||||
|
ve->description = "Wave Patterns (H/V)";
|
||||||
|
ve->sub_format = 1;
|
||||||
|
ve->extra_frame = 0;
|
||||||
|
ve->parallel = 0;
|
||||||
|
ve->has_user = 0;
|
||||||
|
ve->param_description = vje_build_param_list(ve->num_params, "Frequency X", "Frequency Y", "Amplitude", "Speed" );
|
||||||
|
|
||||||
|
return ve;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t *buf[3];
|
||||||
|
float *lut_x;
|
||||||
|
float *lut_y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
float factor;
|
||||||
|
float speed;
|
||||||
|
int deformX;
|
||||||
|
int deformY;
|
||||||
|
} ripplewave_t;
|
||||||
|
|
||||||
|
#define SIN_TABLE_SIZE 360
|
||||||
|
void* ripplewave_malloc(int w, int h) {
|
||||||
|
ripplewave_t *data = (ripplewave_t*) vj_malloc(sizeof(ripplewave_t));
|
||||||
|
if (!data)
|
||||||
|
return NULL;
|
||||||
|
data->buf[0] = (uint8_t*) vj_malloc(sizeof(uint8_t) * w * h * 3);
|
||||||
|
if(!data->buf[0]) {
|
||||||
|
free(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
data->lut_x = (float*) vj_malloc(sizeof(float) * w);
|
||||||
|
if(!data->lut_x) {
|
||||||
|
free(data->buf[0]);
|
||||||
|
free(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
data->lut_y = (float*) vj_malloc(sizeof(float) * h);
|
||||||
|
if(!data->lut_y) {
|
||||||
|
free(data->buf[0]);
|
||||||
|
free(data->lut_x);
|
||||||
|
free(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->buf[1] = data->buf[0] + (w*h);
|
||||||
|
data->buf[2] = data->buf[1] + (w*h);
|
||||||
|
|
||||||
|
data->width = w;
|
||||||
|
data->height = h;
|
||||||
|
data->factor = 10.0;
|
||||||
|
data->speed = 1.0;
|
||||||
|
data->deformX = 1;
|
||||||
|
data->deformY = 1;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ripplewave_free(void *ptr) {
|
||||||
|
ripplewave_t *data = (ripplewave_t*) ptr;
|
||||||
|
if (data != NULL) {
|
||||||
|
free(data->buf[0]);
|
||||||
|
free(data->lut_x);
|
||||||
|
free(data->lut_y);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ripplewave_apply(void *ptr, VJFrame *frame, int *args) {
|
||||||
|
ripplewave_t *data = (ripplewave_t*)ptr;
|
||||||
|
|
||||||
|
int width = frame->width;
|
||||||
|
int height = frame->height;
|
||||||
|
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
float frequencyX = args[0] * 0.01f;
|
||||||
|
float frequencyY = args[1] * 0.01f;
|
||||||
|
float amplitude = args[2];
|
||||||
|
float speed = args[3] * 0.1f;
|
||||||
|
|
||||||
|
data->speed += 0.1f;
|
||||||
|
if( data->speed > speed ) {
|
||||||
|
data->speed = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *Y = frame->data[0];
|
||||||
|
uint8_t *U = frame->data[1];
|
||||||
|
uint8_t *V = frame->data[2];
|
||||||
|
|
||||||
|
uint8_t *dstY = data->buf[0] + frame->offset;
|
||||||
|
uint8_t *dstU = data->buf[1] + frame->offset;
|
||||||
|
uint8_t *dstV = data->buf[2] + frame->offset;
|
||||||
|
|
||||||
|
float *lut_x = data->lut_x;
|
||||||
|
float *lut_y = data->lut_y;
|
||||||
|
|
||||||
|
for( y = 0; y < height; y ++ ) {
|
||||||
|
lut_y[y] = a_sin( frequencyY * y + data->speed );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( x = 0; x < width; x ++ ) {
|
||||||
|
lut_x[x] = a_cos( frequencyX * x + data->speed );
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y = 0; y < height; y++) {
|
||||||
|
float offset_y = amplitude * lut_y[y];
|
||||||
|
for (x = 0; x < width; x++) {
|
||||||
|
float offset_x = amplitude * lut_x[x];
|
||||||
|
|
||||||
|
int srcX = (int) ( x + offset_x ) % width;
|
||||||
|
int srcY = (int) ( y + offset_y ) % height;
|
||||||
|
|
||||||
|
srcX = (srcX < 0) ? (width + srcX) : srcX;
|
||||||
|
srcY = (srcY < 0) ? (height + srcY) : srcY;
|
||||||
|
|
||||||
|
int srcIndex = srcY * width + srcX;
|
||||||
|
int dstIndex = y * width + x;
|
||||||
|
|
||||||
|
dstY[dstIndex] = Y[srcIndex];
|
||||||
|
dstU[dstIndex] = U[srcIndex];
|
||||||
|
dstV[dstIndex] = V[srcIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
veejay_memcpy( Y, dstY, frame->len );
|
||||||
|
veejay_memcpy( U, dstU, frame->len );
|
||||||
|
veejay_memcpy( V, dstV, frame->len );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
27
veejay-current/veejay-server/libvje/effects/ripplewave.h
Normal file
27
veejay-current/veejay-server/libvje/effects/ripplewave.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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 RIPPLEWAVEFX_H
|
||||||
|
#define RIPPLEWAVEFX_H
|
||||||
|
vj_effect *ripplewave_init(int w, int h);
|
||||||
|
void *ripplewave_malloc(int w, int h);
|
||||||
|
void ripplewave_free(void *ptr);
|
||||||
|
void ripplewave_apply(void *ptr, VJFrame *frame, int *args);
|
||||||
|
#endif
|
||||||
@@ -18,19 +18,18 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 , USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 , USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* distortion effects */
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <veejaycore/vjmem.h>
|
#include <veejaycore/vjmem.h>
|
||||||
#include "rotozoom.h"
|
#include "rotozoom.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int *test_roto[9];
|
|
||||||
int *test_roto2[9];
|
|
||||||
int new_zpath;
|
|
||||||
int new_path;
|
|
||||||
int roto_old_p;
|
|
||||||
int roto_old_z;
|
|
||||||
uint8_t *rotobuffer[4];
|
uint8_t *rotobuffer[4];
|
||||||
|
float sin_lut[360];
|
||||||
|
float cos_lut[360];
|
||||||
|
double zoom;
|
||||||
|
double rotate;
|
||||||
|
int frameCount;
|
||||||
|
int direction;
|
||||||
} rotozoom_t;
|
} rotozoom_t;
|
||||||
|
|
||||||
vj_effect *rotozoom_init(int width, int height)
|
vj_effect *rotozoom_init(int width, int height)
|
||||||
@@ -40,30 +39,24 @@ vj_effect *rotozoom_init(int width, int height)
|
|||||||
ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */
|
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[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */
|
||||||
ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */
|
ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */
|
||||||
ve->defaults[0] = 0;
|
ve->defaults[0] = 30;
|
||||||
ve->defaults[1] = 1;
|
ve->defaults[1] = 2;
|
||||||
ve->defaults[2] = 1;
|
ve->defaults[2] = 1;
|
||||||
ve->defaults[3] = 1;
|
ve->defaults[3] = 100;
|
||||||
ve->limits[0][0] = 0;
|
ve->limits[0][0] = 0;
|
||||||
ve->limits[1][0] = 8;
|
ve->limits[1][0] = 360;
|
||||||
ve->limits[0][1] = 0;
|
ve->limits[0][1] = -1000;
|
||||||
ve->limits[1][1] = 255;
|
ve->limits[1][1] = 1000;
|
||||||
ve->limits[0][2] = 0;
|
ve->limits[0][2] = 0;
|
||||||
ve->limits[1][2] = 255;
|
ve->limits[1][2] = 1;
|
||||||
ve->limits[0][3] = 0;
|
ve->limits[0][3] = 1;
|
||||||
ve->limits[1][3] = 1;
|
ve->limits[1][3] = 1500;
|
||||||
ve->description = "Rotozoom";
|
ve->description = "Rotozoom";
|
||||||
ve->sub_format = 1;
|
ve->sub_format = 1;
|
||||||
ve->extra_frame = 0;
|
ve->extra_frame = 0;
|
||||||
ve->param_description = vje_build_param_list(ve->num_params, "Mode", "Rotate", "Zoom" , "Automatic");
|
ve->param_description = vje_build_param_list(ve->num_params, "Rotate", "Zoom" , "Automatic", "Duration");
|
||||||
ve->has_user = 0;
|
ve->has_user = 0;
|
||||||
|
|
||||||
ve->hints = vje_init_value_hint_list( ve->num_params );
|
|
||||||
|
|
||||||
vje_build_value_hint_list( ve->hints, ve->limits[1][0], 0, "Normal", "Rotozoom II",
|
|
||||||
"Rotozoom III", "Rotozoom IV", "Rotozoom V", "Rotozoom VI", "Rotozoom VII", "Rotozoom VIII", "Rotozoom IX");
|
|
||||||
|
|
||||||
|
|
||||||
return ve;
|
return ve;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,72 +77,12 @@ void *rotozoom_malloc(int width, int height)
|
|||||||
r->rotobuffer[1] = r->rotobuffer[0] + (width * height);
|
r->rotobuffer[1] = r->rotobuffer[0] + (width * height);
|
||||||
r->rotobuffer[2] = r->rotobuffer[1] + (width * height);
|
r->rotobuffer[2] = r->rotobuffer[1] + (width * height);
|
||||||
|
|
||||||
int j;
|
r->direction = 1;
|
||||||
for (j = 0; j < 9; j++) {
|
|
||||||
r->test_roto[j] = (int *) vj_malloc(sizeof(int) * 256);
|
|
||||||
r->test_roto2[j] = (int *) vj_malloc(sizeof(int) * 256);
|
|
||||||
if(!r->test_roto[j] || r->test_roto2[j]) {
|
|
||||||
rotozoom_free(r);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 1.41176 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[0][i] = (c + 0.8) * 4096.0;
|
|
||||||
r->test_roto2[0][i] = (2.0 * c) * 4096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 2.41176 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[1][i] = (c + 0.8) * 4096.0;
|
|
||||||
r->test_roto2[1][i] = (2.0 * c) * 4096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 3.41576 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[2][i] = (c + 0.8) * 4096.0;
|
|
||||||
r->test_roto2[2][i] = (2.0 * c) * 4096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 4.74176 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[3][i] = (c + 0.8) * 4096.0;
|
|
||||||
r->test_roto2[3][i] = (2.0 * c) * 4096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 5.91176 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[4][i] = (c + 0.8) * 4096.0;
|
|
||||||
r->test_roto2[4][i] = (2.0 * c) * 4096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 9.12345 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[5][i] = (c + 0.8) * 4096.0;
|
|
||||||
r->test_roto2[5][i] = (2.0 * c) * 4096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 9.12345 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[6][i] = (c + 0.8) * 8096.0;
|
|
||||||
r->test_roto2[6][i] = (2.0 * c) * 8096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 1.41176 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[7][i] = c * 4096.0;
|
|
||||||
r->test_roto2[7][i] = c * 4096.0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
float rad = (float) i * 1.0 * 0.0174532;
|
|
||||||
float c = sin(rad);
|
|
||||||
r->test_roto[8][i] = c * 4096.0;
|
|
||||||
r->test_roto2[8][i] = c * 4096.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
for( i = 0; i < 360; i ++ ) {
|
||||||
|
r->sin_lut[i] = a_sin( i * M_PI / 180.0 );
|
||||||
|
r->cos_lut[i] = a_cos( i * M_PI / 180.0 );
|
||||||
|
}
|
||||||
|
|
||||||
return (void*) r;
|
return (void*) r;
|
||||||
}
|
}
|
||||||
@@ -161,103 +94,89 @@ void rotozoom_free(void *ptr) {
|
|||||||
if(r->rotobuffer[0])
|
if(r->rotobuffer[0])
|
||||||
free(r->rotobuffer[0]);
|
free(r->rotobuffer[0]);
|
||||||
|
|
||||||
int j;
|
|
||||||
for( j = 0; j < 9; j ++ ) {
|
|
||||||
if( r->test_roto[j] )
|
|
||||||
free(r->test_roto[j]);
|
|
||||||
if( r->test_roto2[j] )
|
|
||||||
free(r->test_roto2[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(r);
|
free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rotozoomer, from the demo effects collection, works in supersampled YCbCr space.
|
|
||||||
printf("Retro Rotozoom Effect - B. Ellacott, W.P. van Paassen - 2002\n");
|
|
||||||
*/
|
|
||||||
static void draw_tile(int stepx, int stepy, int zoom, int w, int h,
|
|
||||||
uint8_t * src1[3], uint8_t * src2[3])
|
|
||||||
{
|
|
||||||
|
|
||||||
int x, y, i, j, xd, yd, a, b, sx, sy;
|
|
||||||
|
|
||||||
sx = sy = 0;
|
|
||||||
xd = (stepx * zoom) >> 12;
|
|
||||||
yd = (stepy * zoom) >> 12;
|
|
||||||
|
|
||||||
for (j = 0; j < h; j++) {
|
|
||||||
x = sx;
|
|
||||||
y = sy;
|
|
||||||
for (i = 0; i < w; i++) {
|
|
||||||
a = (x >> 12) & 255;
|
|
||||||
b = (y >> 12) & 255;
|
|
||||||
src1[0][(j * w) + i] = src2[0][b * w + a];
|
|
||||||
src1[1][(j * w) + i] = src2[1][b * w + a];
|
|
||||||
src1[2][(j * w) + i] = src2[2][b * w + a];
|
|
||||||
x += xd;
|
|
||||||
y += yd;
|
|
||||||
}
|
|
||||||
sx -= yd;
|
|
||||||
sy += xd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rotozoom2_apply(rotozoom_t *r, VJFrame *frame, uint8_t *data[3], int width,
|
|
||||||
int height, int n, int p, int z)
|
|
||||||
{
|
|
||||||
draw_tile(r->test_roto[n][p],
|
|
||||||
r->test_roto[n][(p + 128) & 0xFF],
|
|
||||||
r->test_roto2[n][z], width, height, frame->data, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rotozoom1_apply(rotozoom_t *r, VJFrame *frame, uint8_t *data[3], int w, int h,
|
|
||||||
int n, int p, int z)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (r->roto_old_p != p) {
|
|
||||||
r->roto_old_p = p;
|
|
||||||
r->new_path = p & 255;
|
|
||||||
}
|
|
||||||
if (r->roto_old_z != z) {
|
|
||||||
r->roto_old_z = z;
|
|
||||||
r->new_zpath = z & 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_tile(
|
|
||||||
r->test_roto[n][r->new_path],
|
|
||||||
r->test_roto[n][(r->new_path + 128) & 0xff],
|
|
||||||
r->test_roto2[n][r->new_zpath], w, h, frame->data, data);
|
|
||||||
|
|
||||||
r->new_path = (r->new_path - 1) & 255;
|
|
||||||
r->new_zpath = (r->new_zpath + 1) & 255;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void rotozoom_apply( void *ptr, VJFrame *frame, int *args )
|
void rotozoom_apply( void *ptr, VJFrame *frame, int *args )
|
||||||
{
|
{
|
||||||
|
rotozoom_t *r = (rotozoom_t*) ptr;
|
||||||
|
|
||||||
const unsigned int width = frame->width;
|
const unsigned int width = frame->width;
|
||||||
const unsigned int height = frame->height;
|
const unsigned int height = frame->height;
|
||||||
const int len = frame->len;
|
const int len = frame->len;
|
||||||
int strides[4] = {len ,len ,len ,0};
|
|
||||||
|
|
||||||
int mode = args[0];
|
double rotate = args[0];
|
||||||
int rotate = args[1];
|
double zoom1 = args[1];
|
||||||
int zoom = args[2];
|
int autom = args[2];
|
||||||
int autom = args[3];
|
int maxFrames = args[3];
|
||||||
|
|
||||||
rotozoom_t *r = (rotozoom_t*) ptr;
|
double zoom;
|
||||||
|
if( zoom1 > 0) {
|
||||||
|
zoom = 1.0 / (1.0 + zoom1 / 100.0);
|
||||||
|
}
|
||||||
|
else if(zoom1 < 0) {
|
||||||
|
zoom = pow( 2.0, -zoom1 / 200.0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
zoom = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
switch (autom) {
|
if( autom ) {
|
||||||
case 0:
|
zoom1 = r->zoom;
|
||||||
vj_frame_copy( frame->data, r->rotobuffer, strides );
|
rotate = r->rotate;
|
||||||
rotozoom2_apply(r,frame, r->rotobuffer, width, height, mode, rotate, zoom);
|
|
||||||
break;
|
r->zoom += (r->direction * (2000.0 / maxFrames));
|
||||||
case 1:
|
r->rotate += (r->direction * (360.0 / maxFrames));
|
||||||
vj_frame_copy( frame->data,r->rotobuffer, strides );
|
|
||||||
rotozoom1_apply(r,frame, r->rotobuffer, width, height, mode, rotate, zoom);
|
r->frameCount ++;
|
||||||
break;
|
|
||||||
|
if( r->frameCount % maxFrames == 0 || (r->rotate <= 0 || r->rotate >= 360)) {
|
||||||
|
r->direction *= -1;
|
||||||
|
r->frameCount = 0;
|
||||||
|
}
|
||||||
|
r->zoom = fmin(1000, fmax(-1000, r->zoom));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *dstY = frame->data[0];
|
||||||
|
uint8_t *dstU = frame->data[1];
|
||||||
|
uint8_t *dstV = frame->data[2];
|
||||||
|
|
||||||
|
uint8_t *srcY = r->rotobuffer[0];
|
||||||
|
uint8_t *srcU = r->rotobuffer[1];
|
||||||
|
uint8_t *srcV = r->rotobuffer[2];
|
||||||
|
|
||||||
|
veejay_memcpy( r->rotobuffer[0], frame->data[0], frame->len );
|
||||||
|
veejay_memcpy( r->rotobuffer[1], frame->data[1], frame->len );
|
||||||
|
veejay_memcpy( r->rotobuffer[2], frame->data[2], frame->len );
|
||||||
|
|
||||||
|
const int centerX = width / 2;
|
||||||
|
const int centerY = height / 2;
|
||||||
|
|
||||||
|
|
||||||
|
float *cos_lut = r->cos_lut;
|
||||||
|
float *sin_lut = r->sin_lut;
|
||||||
|
|
||||||
|
for (int y = 0; y < height; ++y) {
|
||||||
|
for (int x = 0; x < width; ++x) {
|
||||||
|
|
||||||
|
int rotatedX = (int)((x - centerX) * cos_lut[(int)rotate % 360] - (y - centerY) * sin_lut[(int)rotate % 360] + centerX);
|
||||||
|
int rotatedY = (int)((x - centerX) * sin_lut[(int)rotate % 360] + (y - centerY) * cos_lut[(int)rotate % 360] + centerY);
|
||||||
|
|
||||||
|
int newX = (int)((rotatedX - centerX) * zoom + centerX);
|
||||||
|
int newY = (int)((rotatedY - centerY) * zoom + centerY);
|
||||||
|
|
||||||
|
newX = (newX < 0) ? 0 : ((newX > width - 1) ? width - 1 : newX);
|
||||||
|
newY = (newY < 0) ? 0 : ((newY > height - 1) ? height - 1 : newY);
|
||||||
|
|
||||||
|
int srcIndex = newY * width + newX;
|
||||||
|
int dstIndex = y * width + x;
|
||||||
|
|
||||||
|
|
||||||
|
dstY[dstIndex] = srcY[srcIndex];
|
||||||
|
dstU[dstIndex] = srcU[srcIndex];
|
||||||
|
dstV[dstIndex] = srcV[srcIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,8 +213,11 @@
|
|||||||
#include "./effects/shutterdrag.h"
|
#include "./effects/shutterdrag.h"
|
||||||
#include "./effects/pointilism.h"
|
#include "./effects/pointilism.h"
|
||||||
#include "./effects/smartblur.h"
|
#include "./effects/smartblur.h"
|
||||||
|
#include "./effects/wave.h"
|
||||||
|
#include "./effects/ripplewave.h"
|
||||||
|
#include "./effects/luminouswave.h"
|
||||||
|
|
||||||
#define VJ_IMAGE_EFFECT_MIN 73
|
#define VJ_IMAGE_EFFECT_MIN 70
|
||||||
#define VJ_IMAGE_EFFECT_MAX 199
|
#define VJ_IMAGE_EFFECT_MAX 199
|
||||||
|
|
||||||
#define VJ_VIDEO_EFFECT_MIN 200
|
#define VJ_VIDEO_EFFECT_MIN 200
|
||||||
@@ -461,7 +464,10 @@ enum {
|
|||||||
VJ_IMAGE_EFFECT_SHUTTERDRAG = 75,
|
VJ_IMAGE_EFFECT_SHUTTERDRAG = 75,
|
||||||
VJ_IMAGE_EFFECT_POINTILISM = 74,
|
VJ_IMAGE_EFFECT_POINTILISM = 74,
|
||||||
VJ_IMAGE_EFFECT_SMARTBLUR = 73,
|
VJ_IMAGE_EFFECT_SMARTBLUR = 73,
|
||||||
VJ_IMAGE_EFFECT_DUMMY=0,
|
VJ_IMAGE_EFFECT_WAVE = 72,
|
||||||
|
VJ_IMAGE_EFFECT_RIPPLEWAVE = 71,
|
||||||
|
VJ_IMAGE_EFFECT_LUMINOUSWAVE = 70,
|
||||||
|
VJ_IMAGE_EFFECT_DUMMY=0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ static struct {
|
|||||||
{ shutterdrag_init,shutterdrag_malloc,shutterdrag_free,NULL,NULL,shutterdrag_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_SHUTTERDRAG },
|
{ shutterdrag_init,shutterdrag_malloc,shutterdrag_free,NULL,NULL,shutterdrag_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_SHUTTERDRAG },
|
||||||
{ pointilism_init,pointilism_malloc,pointilism_free,NULL,NULL,pointilism_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_POINTILISM },
|
{ pointilism_init,pointilism_malloc,pointilism_free,NULL,NULL,pointilism_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_POINTILISM },
|
||||||
{ smartblur_init,smartblur_malloc,smartblur_free,NULL,NULL,smartblur_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_SMARTBLUR },
|
{ smartblur_init,smartblur_malloc,smartblur_free,NULL,NULL,smartblur_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_SMARTBLUR },
|
||||||
|
{ wave_init,wave_malloc,wave_free,NULL,NULL,wave_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_WAVE },
|
||||||
|
{ ripplewave_init,ripplewave_malloc,ripplewave_free,NULL,NULL,ripplewave_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_RIPPLEWAVE },
|
||||||
|
{ luminouswave_init,luminouswave_malloc,luminouswave_free,NULL,NULL,luminouswave_apply,NULL,NULL,NULL,NULL,VJ_IMAGE_EFFECT_LUMINOUSWAVE },
|
||||||
{ negatechannel_init,NULL,NULL,NULL,NULL,negatechannel_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_NEGATECHANNEL },
|
{ negatechannel_init,NULL,NULL,NULL,NULL,negatechannel_apply,NULL,NULL,NULL,NULL, VJ_IMAGE_EFFECT_NEGATECHANNEL },
|
||||||
{ mtracer_init,mtracer_malloc,mtracer_free,NULL,NULL,NULL,mtracer_apply,NULL,NULL,NULL, VJ_VIDEO_EFFECT_MTRACER },
|
{ mtracer_init,mtracer_malloc,mtracer_free,NULL,NULL,NULL,mtracer_apply,NULL,NULL,NULL, VJ_VIDEO_EFFECT_MTRACER },
|
||||||
{ overlaymagic_init,NULL,NULL,NULL,NULL,NULL,overlaymagic_apply,NULL,NULL,NULL,VJ_VIDEO_EFFECT_OVERLAYMAGIC },
|
{ overlaymagic_init,NULL,NULL,NULL,NULL,NULL,overlaymagic_apply,NULL,NULL,NULL,VJ_VIDEO_EFFECT_OVERLAYMAGIC },
|
||||||
|
|||||||
Reference in New Issue
Block a user