optimize smuck, add new mode to apply smuck on chroma as well

This commit is contained in:
veejay
2023-10-17 22:41:02 +02:00
parent 58b9d09dd8
commit a971868529

View File

@@ -25,19 +25,24 @@
vj_effect *smuck_init(int w,int h)
{
vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect));
ve->num_params = 1;
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->defaults[0] = 1;
ve->defaults[1] = 0;
ve->limits[0][0] = 0;
ve->limits[1][0] = 18;
ve->limits[0][1] = 0;
ve->limits[1][1] = 1;
ve->description = "SmuckTV (EffectTV)";
ve->sub_format = -1;
ve->sub_format = 1;
ve->extra_frame = 0;
ve->has_user = 0;
ve->param_description = vje_build_param_list( ve->num_params, "Smuck");
ve->param_description = vje_build_param_list( ve->num_params, "Smuck", "Mode");
return ve;
}
@@ -69,6 +74,7 @@ void smuck_apply( void *ptr, VJFrame *frame, int *args)
unsigned int yd, xd, x, y;
smuck_t *s = (smuck_t*) ptr;
int n = args[0];
int mode = args[1];
VJFrame *frame2 = frame;
@@ -77,15 +83,34 @@ void smuck_apply( void *ptr, VJFrame *frame, int *args)
{ 12, 21, 30, 60, 58, 59, 57, 56, 55, 54, 53, 89, 90, 88, 87, 86, 85, 114 };
uint8_t *Y = frame->data[0];
uint8_t *Y2 = frame2->data[0];
if( mode == 0 ) {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
yd = y + (smuck_fastrand(s) >> smuck[n]) - 2;
xd = x + (smuck_fastrand(s) >> smuck[n]) - 2;
if (xd > width)
xd = width-1;
if (yd > height)
yd = height;
yd = (y + (smuck_fastrand(s) >> smuck[n]) - 2) % height;
xd = (x + (smuck_fastrand(s) >> smuck[n]) - 2) % width;
Y[x + y * width] = Y2[xd + yd * width];
}
}
} else {
uint8_t *U = frame->data[1];
uint8_t *V = frame->data[2];
uint8_t *U2 = frame->data[1];
uint8_t *V2 = frame->data[2];
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
yd = (y + (smuck_fastrand(s) >> smuck[n]) - 2) % height;
xd = (x + (smuck_fastrand(s) >> smuck[n]) - 2) % width;
Y[x + y * width] = Y2[xd + yd * width];
U[x + y * width] = U2[xd + yd * width];
V[x + y * width] = V2[xd + yd * width];
}
}
}
}