mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-19 22:30:06 +01:00
vje fix raster and flip
This commit is contained in:
@@ -39,7 +39,7 @@ vj_effect *flip_init(int w, int h)
|
||||
ve->limits[1][1] = 1;
|
||||
|
||||
ve->description = "Flip Frame";
|
||||
ve->sub_format = 0;
|
||||
ve->sub_format = 1;
|
||||
ve->extra_frame = 0;
|
||||
ve->has_user = 0;
|
||||
ve->param_description = vje_build_param_list(ve->num_params, "Horizontal", "Vertical");
|
||||
@@ -170,49 +170,35 @@ static void flip_y_yuvdata(VJFrame *frame)
|
||||
**********************************************************************************************/
|
||||
void flip_both_yuvdata(VJFrame *frame)
|
||||
{
|
||||
unsigned int x, x2, pos_a = 0, pos_b;
|
||||
uint8_t temp;
|
||||
unsigned int w1 = frame->width - 1;
|
||||
unsigned int y = frame->height >> 1;
|
||||
unsigned int uy = y >> frame->shift_v;
|
||||
const unsigned int uv_height = frame->uv_height;
|
||||
const unsigned int uv_width = frame->uv_width;
|
||||
const unsigned int uw1 = ( frame->width >> frame->shift_h ) - 1;
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *Cb = frame->data[1];
|
||||
uint8_t *Cr = frame->data[2];
|
||||
const unsigned int h2 = (frame->height >> 1);
|
||||
unsigned int x, y, pos_a, pos_b;
|
||||
|
||||
/* Luminance */
|
||||
pos_b = (frame->height ) * frame->width;
|
||||
do {
|
||||
x = w1;
|
||||
do {
|
||||
temp = Y[pos_a + x];
|
||||
Y[pos_a + x] = Y[pos_b + w1 - x];
|
||||
Y[pos_b + w1 - x] = temp;
|
||||
} while (x--);
|
||||
pos_a += frame->width;
|
||||
pos_b -= frame->width;
|
||||
} while (--y);
|
||||
|
||||
/* Chrominance */
|
||||
pos_a = 0;
|
||||
pos_b = (uv_height ) * uv_width;
|
||||
do {
|
||||
x = uw1;
|
||||
do {
|
||||
pos_b = (frame->height * frame->width)-1;
|
||||
/* Luminance & Chrominance*/
|
||||
for (y = 0 ; y < h2 ; y++)
|
||||
{
|
||||
for (x = 0 ; x < frame->width ; x++ )
|
||||
{
|
||||
temp = Y[pos_a + x];
|
||||
Y[pos_a + x] = Y[pos_b - x];
|
||||
Y[pos_b - x] = temp;
|
||||
|
||||
temp = Cb[pos_a + x];
|
||||
Cb[pos_a + x] = Cb[pos_b + uw1 - x];
|
||||
Cb[pos_b + uw1 - x] = temp;
|
||||
Cb[pos_a + x] = Cb[pos_b - x];
|
||||
Cb[pos_b - x] = temp;
|
||||
|
||||
temp = Cr[pos_a + x];
|
||||
Cr[pos_a + x] = Cr[pos_b + uw1 - x];
|
||||
Cr[pos_b + uw1 - x] = temp;
|
||||
|
||||
} while (x--);
|
||||
pos_a += uv_width;
|
||||
pos_b -= uv_width;
|
||||
} while (--uy);
|
||||
Cr[pos_a + x] = Cr[pos_b - x];
|
||||
Cr[pos_b - x] = temp;
|
||||
}
|
||||
pos_a += frame->width;
|
||||
pos_b -= frame->width;
|
||||
}
|
||||
}
|
||||
|
||||
void flip_apply(VJFrame *frame, int h, int v)
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <libvjmem/vjmem.h>
|
||||
#include "raster.h"
|
||||
|
||||
static int *xval;
|
||||
|
||||
vj_effect *raster_init(int w, int h)
|
||||
{
|
||||
vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect));
|
||||
@@ -37,7 +39,7 @@ vj_effect *raster_init(int w, int h)
|
||||
ve->defaults[0] = 4;
|
||||
ve->defaults[1] = 1;
|
||||
ve->description = "Grid";
|
||||
ve->sub_format = 0;
|
||||
ve->sub_format = 1;
|
||||
ve->extra_frame = 0;
|
||||
ve->has_user = 0;
|
||||
ve->param_description = vje_build_param_list( ve->num_params, "Grid size", "Mode");
|
||||
@@ -48,9 +50,22 @@ vj_effect *raster_init(int w, int h)
|
||||
return ve;
|
||||
}
|
||||
|
||||
int raster_malloc (int w , int h)
|
||||
{
|
||||
xval = vj_malloc(sizeof(int)*w);
|
||||
if (xval == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void raster_free()
|
||||
{
|
||||
if (xval == NULL) free(xval);
|
||||
}
|
||||
|
||||
void raster_apply(VJFrame *frame, int val, int mode)
|
||||
{
|
||||
int x,y;
|
||||
int x,y, yval;
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *Cb= frame->data[1];
|
||||
uint8_t *Cr= frame->data[2];
|
||||
@@ -60,118 +75,21 @@ void raster_apply(VJFrame *frame, int val, int mode)
|
||||
if(val == 0 )
|
||||
return;
|
||||
|
||||
for(x=0; x < width; x++)
|
||||
{
|
||||
xval[x] = x%val;
|
||||
}
|
||||
|
||||
uint8_t pixel_color = mode ? pixel_Y_hi_ : pixel_Y_lo_;
|
||||
|
||||
for(y=0; y < height; y++)
|
||||
{
|
||||
yval = y%val;
|
||||
for(x=0; x < width; x++)
|
||||
{
|
||||
Y[y*width+x] = ((x%val>1)? ((y%val>1) ? Y[y*width+x]: pixel_color):pixel_color);
|
||||
Y[y*width+x] = ((xval[x]>1)? ((yval>1) ? Y[y*width+x]: pixel_color):pixel_color);
|
||||
Cb[y*width+x] = ((xval[x]>1)? ((yval>1) ? Cb[y*width+x]:128):128);
|
||||
Cr[y*width+x] = ((xval[x]>1)? ((yval>1) ? Cr[y*width+x]:128):128);
|
||||
}
|
||||
}
|
||||
|
||||
const unsigned int uv_width= frame->uv_width;
|
||||
const unsigned int uv_height= frame->uv_height;
|
||||
|
||||
for(y=0; y < uv_height; y++)
|
||||
{
|
||||
for(x=0; x < uv_width; x++)
|
||||
{
|
||||
Cb[y*uv_width+x] = ((x%val>1)? ((y%val>1) ? Cb[y*uv_width+x]:128):128);
|
||||
Cr[y*uv_width+x] = ((x%val>1)? ((y%val>1) ? Cr[y*uv_width+x]:128):128);
|
||||
}
|
||||
}
|
||||
/*
|
||||
int x,y;
|
||||
int px,py;
|
||||
int i,j;
|
||||
double r,a;
|
||||
unsigned int R = h/2;
|
||||
double curve; //curve
|
||||
double coeef;
|
||||
int w2 = w/2;
|
||||
int h2 = h/2;
|
||||
int n1=0,n2=0,n3=0;
|
||||
int k,l,m,o1=0,o2=0;
|
||||
|
||||
double (*pf)(double a, double b, double c);
|
||||
|
||||
if( v==0) v =1;
|
||||
if( v < 0 ) {
|
||||
pf = &__fisheye_i;
|
||||
v = v * -1;
|
||||
}
|
||||
else {
|
||||
pf = &__fisheye;
|
||||
}
|
||||
|
||||
curve = 0.001 * v; //curve
|
||||
coeef = R / log(curve * R + 1);
|
||||
|
||||
if(!buf)
|
||||
{
|
||||
buf = (uint8_t*)vj_calloc(sizeof(uint8_t) * w * h );
|
||||
if(!buf)return;
|
||||
}
|
||||
memcpy(buf, Y,(w*h));
|
||||
|
||||
for(y= (-1*h2); y < (h-h2); y++)
|
||||
// for(y=0; y < h; y++)
|
||||
//for(y=0; y < h; y++)
|
||||
{
|
||||
for(x = (-1*w2); x < (w-w2); x++)
|
||||
// for(x=0 ;x < w; x++)
|
||||
{
|
||||
//if(x > 0 && y > 0)
|
||||
//
|
||||
if(x==0 && y==0) r = 0;
|
||||
else r = sqrt( y*y+x*x);
|
||||
if(x==0 && y==0)
|
||||
a= 1;
|
||||
else
|
||||
a = atan2( (float)y,x);
|
||||
|
||||
//if(x > 0 && y < 0) a += 240;
|
||||
|
||||
//if(x < 0 && y > 0) a+= 180;
|
||||
|
||||
//if(x < 0 && y < 0) a+= 180;
|
||||
|
||||
i = (y+h2)*w+(w2+x);
|
||||
if( r <= R)
|
||||
{
|
||||
//r = coeef * log(1 + curve * r);
|
||||
r = pf( r, coeef, curve);
|
||||
//px en py ook zonder +
|
||||
px = (int) ( r * cos(a) );
|
||||
py = (int) ( r * sin(a) );
|
||||
px += w2;
|
||||
py += h2;
|
||||
if(px < 0) px =0;
|
||||
if(px > w) px = w;
|
||||
if(py < 0) py = 0;
|
||||
if(py > (h-1)) py = h-1;
|
||||
j = px + py * w;
|
||||
//k = py * w + (w - px);
|
||||
Y[i] = buf[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
Y[i] = 16;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
printf(" n1 = %d n2 = %d n3 = %d \n",n1,n2,n3);
|
||||
|
||||
|
||||
memset(Cb,128,(w*h)/4);
|
||||
memset(Cr,128,(w*h)/4);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -22,4 +22,6 @@
|
||||
#define RASTER_H
|
||||
vj_effect *raster_init(int w, int h);
|
||||
void raster_apply( VJFrame *frame, int val, int mode);
|
||||
int raster_malloc (int w , int h);
|
||||
void raster_free(void);
|
||||
#endif
|
||||
|
||||
@@ -126,6 +126,7 @@ static struct
|
||||
{ distortion_malloc,distortion_free, NULL, VJ_IMAGE_EFFECT_DISTORTION },
|
||||
{ pixelsort_malloc,pixelsort_free,NULL,VJ_IMAGE_EFFECT_PIXELSORT },
|
||||
{ pixelsortalpha_malloc,pixelsortalpha_free,NULL,VJ_IMAGE_EFFECT_PIXELSORTALPHA },
|
||||
{ raster_malloc,raster_free,NULL,VJ_IMAGE_EFFECT_RASTER },
|
||||
{ NULL,NULL,NULL,0},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user