diff --git a/veejay-current/libstream/vj-tag.c b/veejay-current/libstream/vj-tag.c index bcd6e4ec..6cc9f382 100644 --- a/veejay-current/libstream/vj-tag.c +++ b/veejay-current/libstream/vj-tag.c @@ -223,7 +223,7 @@ int vj_tag_init(int width, int height, int pix_fmt) _temp_buffer[2] = (uint8_t*) malloc(sizeof(uint8_t)*width*height); - if( pix_fmt == FMT_422 ) + if( pix_fmt == FMT_422 || pix_fmt == FMT_422F ) { _tmp.uv_width = width; _tmp.uv_height = height/2; @@ -617,7 +617,7 @@ int vj_tag_new(int type, char *filename, int stream_nr, editlist * el, if(type == VJ_TAG_TYPE_MCAST || type == VJ_TAG_TYPE_NET) tag->private = net_threader(); - palette = (pix_fmt == FMT_420 ? VIDEO_PALETTE_YUV420P : VIDEO_PALETTE_YUV422P); + palette = ( (pix_fmt == FMT_420||pix_fmt == FMT_420F) ? VIDEO_PALETTE_YUV420P : VIDEO_PALETTE_YUV422P); switch (type) { @@ -1778,7 +1778,7 @@ int vj_tag_enable(int t1) { vj_picture *p = vj_tag_input->picture[ tag->index ]; p->pic = vj_picture_open( tag->source_name, vj_tag_input->width, vj_tag_input->height, - vj_tag_input->pix_fmt == FMT_420 ? 1:0); + vj_tag_input->pix_fmt ); if(!p->pic) return -1; @@ -2235,8 +2235,10 @@ int vj_tag_get_frame(int t1, uint8_t *buffer[3], uint8_t * abuffer) vj_client *v; if(!tag) return -1; - if( vj_tag_input->pix_fmt == FMT_420) uv_len = uv_len / 4; - if( vj_tag_input->pix_fmt == FMT_422) uv_len = uv_len / 2; + if( vj_tag_input->pix_fmt == FMT_420|| vj_tag_input->pix_fmt == FMT_420F) + uv_len = uv_len / 4; + else + uv_len = uv_len / 2; switch (tag->source_type) { #ifdef USE_UNICAP @@ -2302,7 +2304,7 @@ int vj_tag_get_frame(int t1, uint8_t *buffer[3], uint8_t * abuffer) break; case VJ_TAG_TYPE_YUV4MPEG: // only for 4:2:0 , must convert to 4:2:2 - if( vj_tag_input->pix_fmt == FMT_420) + if( vj_tag_input->pix_fmt == FMT_420 || vj_tag_input->pix_fmt == FMT_420F) { if (vj_yuv_get_frame(vj_tag_input->stream[tag->index], buffer) != 0) { diff --git a/veejay-current/libvje/effects/average.c b/veejay-current/libvje/effects/average.c index b99e1f56..d72528b2 100644 --- a/veejay-current/libvje/effects/average.c +++ b/veejay-current/libvje/effects/average.c @@ -20,7 +20,7 @@ #include "average.h" #include - +#include "common.h" vj_effect *average_init(int w, int h) { vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); @@ -52,19 +52,16 @@ void average_apply(VJFrame *frame, int width, int height, int val) for (i = 0; i < len; i++) { a = Y[i]; b = ((val-1) * a + a)/val; - if(b < 16) b = 16; else if (b > 240) b = 240; - Y[i] = b; + Y[i] = CLAMP_Y(b); } for (i = 0; i < uv_len; i++) { a = Cb[i]; b = ((val-1) * a + a)/val; - if(b < 16) b = 16; else if (b > 235) b = 235; - Cb[i] = b; + Cb[i] = CLAMP_UV(b); a = Cr[i]; b = ((val-1) * a + a )/val; - if(b < 16) b = 16; else if (b > 235) b = 235; - Cr[i] = b; + Cr[i] = CLAMP_UV(b); } } void average_free(){} diff --git a/veejay-current/libvje/effects/chromamagick.c b/veejay-current/libvje/effects/chromamagick.c index 33f1b172..c69a1977 100644 --- a/veejay-current/libvje/effects/chromamagick.c +++ b/veejay-current/libvje/effects/chromamagick.c @@ -28,6 +28,7 @@ #include #include "chromamagick.h" #include +#include "common.h" // fixme: mode 8 and 9 corrupt (green/purple cbcr) vj_effect *chromamagick_init(int w, int h) @@ -92,15 +93,8 @@ void chromamagic_addsubselectlum(VJFrame *frame, VJFrame *frame2, for (i = 0; i < len; i++) { a = (Y[i] * op_a) >> 8; b = (Y2[i] * op_b) >> 8; - if (b < 16) - b = 16; - if (b > 235) - b = 235; - if (a < 16) - a = 16; - if (a > 235) - a = 235; - + a = CLAMP_Y(a); + b = CLAMP_Y(b); if (b < a) { c = (a + b) >> 1; Y[i] = c; @@ -228,14 +222,11 @@ void chromamagic_selectdiffneg(VJFrame *frame, VJFrame *frame2, b = (Y2[i] * op_b) >> 8; if (a > b) { c = 255 - abs(255 - a - b); - if( c < 16 ) c = 16; else if ( c > 240) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); c = ((Cb[i] * op_a) + (Cb2[i]*op_b) )>>8; - if( c < 16 ) c = 16; else if ( c > 235) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); c = ((Cr[i] * op_a) + (Cr2[i]*op_b) )>>8; - if( c < 16) c = 16; else if ( c > 235) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } } @@ -258,12 +249,12 @@ void chromamagic_selectunfreeze(VJFrame *frame, VJFrame *frame2, a = (Y[i] * op_a) >> 8; b = (Y2[i] * op_b) >> 8; if (a > b) { - if (a < 16) - c = 16; + if (a < pixel_Y_lo_) + c = pixel_Y_lo_; else - c = 255 - ((255 - b) * (255 - b)) / a; - if (c < 16) - c = 16; + c = 255 - ((256 - b) * (256 - b)) / a; + if (c < pixel_Y_lo_) + c = pixel_Y_lo_; Y[i] = c; Cb[i] = (Cb[i] + Cb2[i]) >> 1; Cr[i] = (Cr[i] + Cr2[i]) >> 1; @@ -289,20 +280,9 @@ void chromamagic_addlum(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { a = (Y[i] * op_a) >> 8; b = (Y2[i] * op_b) >> 8; - if (b < 16) - b = 16; - if (b > 235) - b = 235; - if (a < 16) - a = 16; - if (a > 235) - a = 235; - c = (a * a) / (255 - b); - if (c > 235) - c = 235; - if (c < 16) - c = 16; - Y[i] = c; + a = CLAMP_Y(a); + c = (a * a) / (256- b); + Y[i] = CLAMP_Y(c); Cb[i] = (Cb[i] + Cb2[i]) >> 1; Cr[i] = (Cr[i] + Cr2[i]) >> 1; } @@ -326,9 +306,8 @@ void chromamagic_exclusive(VJFrame *frame, VJFrame *frame2, int width, int heigh a = Y[i]; b = Y2[i]; - - if(a < 16) a = 16; else if(a > 235) a = 235; - if(b < 16) b = 16; else if(b > 235) b = 235; + a = CLAMP_Y(a); + b = CLAMP_Y(b); a *= o1; b *= o2; @@ -336,23 +315,20 @@ void chromamagic_exclusive(VJFrame *frame, VJFrame *frame2, int width, int heigh b = b >> 8; c = (a+b) - ((a * b) >> 8); - if( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]-128; b = Cb2[i]-128; c = (a + b) - (( a * b) >> 8); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]-128; b = Cr2[i]-128; c = (a + b) - ((a*b) >> 8); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -372,9 +348,6 @@ void chromamagic_diffnegate(VJFrame *frame, VJFrame *frame2, int width, int heig const unsigned int o2 = 255 - o1; #define MAGIC_THRESHOLD 40 for(i=0; i < len; i++) { - //a = (( 255 - Y[i]) * o1) >> 7; /* negation */ - // b = (Y2[i] * o2) >> 7; - // d = abs( a - b ); a = Y[i]; b = Y2[i]; d = abs( a - b ); @@ -383,31 +356,18 @@ void chromamagic_diffnegate(VJFrame *frame, VJFrame *frame2, int width, int heig a = Y[i] * o1; b = Cb2[i] * o2; c = 255 - ( (a + b) >>8 ); - if( c < 16 ) c = 16; else if ( c > 240) c = 240; - Y[i] = c; - - // a = (( 255 - Cb[i]) * o1) >> 7; - // b = (Cb2[i] * o2) >> 7; - // c = 255 - abs(a - b); - // if ( c < 16) c = 16; else if ( c > 235 ) c = 235; - // Cb[i] = c; - + Y[i] = CLAMP_Y(c); a = (Cb[i]-128) * o1; b = (Cb2[i]-128) * o2; c = 255 - ( 128 + (( a + b ) >> 8 )); - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = (Cr[i]-128) * o1; b = (Cr2[i]-128) * o2; c = 255 - ( 128 + (( a + b ) >> 8 )); - - // a = (( 255 - Cr[i]) * o1) >> 7; - // b = (Cr2[i] * o2) >> 7; - // c = 255 - abs( a- b); - if ( c < 16) c = 16; else if ( c > 235) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -432,24 +392,19 @@ void chromamagic_additive(VJFrame *frame, VJFrame *frame2, int width, a = (Y[i]*o1) >> 7; b = (Y2[i]*o2) >> 7; c = a + (( 2 * b ) - 255); - if( c < 16) c = 16; else if ( c > 235 ) c = 235; - - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]; b = Cb2[i]; c = a + ( ( 2 * b ) - 255 ); - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Cb[i] = c ; + Cb[i] = CLAMP_UV(c) ; a = Cr[i] ; b = Cr2[i] ; c = a + ( ( 2 * b ) - 255 ); - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - - Cr[i] = c ; + Cr[i] = CLAMP_UV(c) ; } @@ -474,25 +429,22 @@ void chromamagic_basecolor(VJFrame *frame, VJFrame *frame2, b = o1 - Y2[i]; c = a * b >> 8; d = c + a * ((255 - (((255 - a) * (255 - b)) >> 8) - c) >> 8); //8 - if ( d < 16 ) d = 16; else if ( d > 240 ) d = 240; - Y[i] = d; + + Y[i] = CLAMP_Y(d); a = Cb[i]-128; b = Cb2[i]-128; c = a * b >> 8; d = c + a * ((255 - (((255-a) * (255-b)) >> 8) -c) >> 8); d += 128; - if ( d < 16 ) d = 16; else if ( d > 235 ) d = 235; - Cb[i] = d; + Cb[i] = CLAMP_UV(d); a = Cr[i]-128; b = Cr2[i]-128; c = a * b >> 8; d = c + a * ((255 - (((255-a) * (255-b)) >> 8) -c ) >> 8); d += 128; - if ( d < 16 ) d = 16; else if ( d > 235 ) d = 235; - Cr[i] = d; - + Cr[i] = CLAMP_UV(d); } } @@ -516,28 +468,26 @@ void chromamagic_freeze(VJFrame *frame, VJFrame *frame2, int w, int h, int op_a) for(i=0; i < len; i++) { a = Y[i]; b = Y2[i]; - if ( a < 16 ) a = 16; - if ( b < 16 ) b = 16; + if ( a < pixel_Y_lo_ ) a = pixel_Y_lo_; + if ( b < pixel_Y_lo_ ) b = pixel_Y_lo_; c = 255 - ((op_a -a ) * (op_a - a)) / b; - if ( c < 16) c = 16; else if ( c > 240 ) c = 240; - - Y[i] = c; + + Y[i] = CLAMP_Y(c); a = Cb[i]; b = Cb2[i]; - if ( a < 16 ) a = 16; - if ( b < 16 ) b = 16; - c = 255 - ((255-a) * (255 - a)) / b; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + if ( a < pixel_U_lo_ ) a = pixel_U_lo_; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; + c = 255 - ((256-a) * (256 - a)) / b; + Cb[i] = CLAMP_UV(c); a = Cr[i]; b = Cr2[i]; - if ( a < 16 ) a = 16; - if ( b < 16 ) b = 16; - c = 255 - (( 255 - a ) * ( 255 - a )) / b; - if ( c < 16 ) c = 16; else if ( c> 235 ) c = 235; - Cr[i] = c; + if ( a < pixel_U_lo_ ) a = pixel_U_lo_; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; + + c = 255 - (( 256 - a ) * ( 256 - a )) / b; + Cr[i] = CLAMP_UV(c); } } @@ -557,28 +507,24 @@ void chromamagic_unfreeze( VJFrame *frame, VJFrame *frame2, int w, int h, int op for(i=0; i < len; i++) { a = Y[i]; b = Y2[i]; - if ( a < 16 ) a = 16; - if ( b < 16 ) b = 16; + if ( a < pixel_Y_lo_ ) a = pixel_Y_lo_; + if ( b < pixel_Y_lo_ ) b = pixel_Y_lo_; c = 255 - (( op_a - b) * (op_a - b)) / a; - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]; b = Cb2[i]; - if ( a < 16) a = 16; - if ( b < 16) b = 16; - c = 255 - (( 255 - b) * ( 255 - b )) / a; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + if ( a < pixel_U_lo_ ) a = pixel_U_lo_; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; + c = 255 - (( 256 - b) * ( 256 - b )) / a; + Cb[i] = CLAMP_UV(c); a = Cr[i]; b = Cr2[i]; - if ( a < 16 ) a = 16; - if ( b < 16 ) b = 16; - c = 255 - ((255 -b ) * (255 - b)) /a ; - if ( c < 16 ) c = 16; else if ( c > 235) c = 235; - Cr[i] = c; - + if ( a < pixel_U_lo_ ) a = pixel_U_lo_; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; + c = 255 - ((256 -b ) * (256 - b)) /a ; + Cr[i] = CLAMP_UV(c); } } @@ -604,24 +550,21 @@ void chromamagic_hardlight( VJFrame *frame, VJFrame *frame2, int w, int h, int o else { c = 255 - (( op_a - b) * ( op_a - a ) >> 8); } - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] =CLAMP_Y( c); a = Cb[i]-128; b = Cb2[i]-128; if ( b < 128 ) c = ( a * b ) >> 8; - else c = 255 - (( 255 - b) * ( 255 - a) >> 8); + else c = 255 - (( 256 - b) * ( 256 - a) >> 8); c += 128; - if ( c < 16) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]-128; b = Cr2[i]-128; if ( b < 128) c = ( a * b ) >> 8; - else c = 255 - (( 255 - b) * ( 255 - a) >> 8 ); + else c = 255 - (( 256 - b) * ( 256 - a) >> 8 ); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -644,22 +587,19 @@ void chromamagic_multiply( VJFrame *frame, VJFrame *frame2, int w, int h,int op_ a = (Y[i] * o1) >> 8; b = (Y2[i] * o2) >> 8; c = (a * b) >> 8; - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]-128; b = Cb2[i]-128; c = ( a * b ) >> 8; c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i] - 128; b = Cr2[i] - 128; c = ( a * b ) >> 8; c += 128; - if ( c < 16 ) c = 16; else if ( c> 235) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -681,25 +621,22 @@ void chromamagic_divide(VJFrame *frame, VJFrame *frame2, int w, int h, int op_a for(i=0; i < len; i++) { a = Y[i] * Y[i]; b = o1 - Y2[i]; - if ( b < 16 ) b = 16; + if ( b < pixel_Y_lo_ ) b = pixel_Y_lo_; c = a / b; - if ( c < 16 ) c = 16; else if (c > 240) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i] * Cb2[i]; b = 255 - Cb2[i]; - if ( b < 16 ) b = 16; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; c = a / b; - if ( c < 16) c= 16; else if ( c > 235) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i] * Cr[i];; b = 255 - Cr2[i]; - if ( b < 16 ) b = 16; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; c = ( a / b ); - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -723,23 +660,18 @@ void chromamagic_substract(VJFrame *frame, VJFrame *frame2, int w, int h, int op b = Y2[i]; c = a - ((b * o1) >> 8); - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]; b = Cb2[i]; c = (((a * o2) + (b * o1))>>8); - - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - + CLAMP_UV(c); Cb[i] = c; a = Cr[i]; b = Cr2[i]; c = (((a * o2) + (b * o1)) >> 8); - - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - + CLAMP_UV(c); Cr[i] = c; } @@ -763,23 +695,19 @@ void chromamagic_add(VJFrame *frame, VJFrame *frame2, int width, a = Y[i]; b = Y2[i]; c = a + (( 2 * b ) - op_a); - if( c < 16) c = 16; else if ( c > 240 ) c = 240; - - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]-128; b = Cb2[i]-128; c = a + ( 2 * b ); c += 128; - if( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]-128; b = Cr2[i]-128; c = a + ( 2 * b ); c += 128; - if( c < 16 ) c = 16; else if ( c > 235) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -798,20 +726,17 @@ void chromamagic_screen(VJFrame *frame, VJFrame *frame2, int w, int h, int op_a) a = Y[i]; b = Y2[i]; c = 255 - ( (op_a-a) * (op_a-b) >> 8); - if( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]-128; b = Cb2[i]-128; - c = 255 - ( ( 255-a) * (255 - b) >> 8); + c = 255 - ( ( 256-a) * (256 - b) >> 8); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]-128; b = Cr2[i]-128; - c = 255 - ( ( 255 -a) * (255 - b)>>8); + c = 255 - ( ( 256 -a) * (256 - b)>>8); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -832,22 +757,19 @@ void chromamagic_difference(VJFrame *frame, VJFrame *frame2, int w, int h, int o a = (Y[i] * o1)>>7; b = (Y2[i] * o2)>>7; c = abs ( a - b ); - if( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = (Cb[i]-128); b = (Cb2[i]-128); c = abs ( a - b ); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = (Cr[i]-128); b = (Cr2[i]-128); c = abs( a - b ); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -871,26 +793,21 @@ void chromamagic_softlightmode(VJFrame *frame,VJFrame *frame2, if ( a < op_a ) { c = (a * b) >> 8; d = (c + a * ( 255 - ( (255-a)*(255-b) >> 8) - c)) >> 8; - if ( d < 16 ) d = 16; else if ( d > 240) d = 240; - - /* deal with chroma red/blue in a magical way - range gets narrowed. - */ + Y[i] = CLAMP_Y(d); + a = abs(Cb[i]-128); b = abs(Cb2[i]-128); c = (a * b); d = (c + a * ( 255 - ( (a * b) >> 7) - c)) >> 7; d += 128; - if ( d < 16) d = 16; else if ( d > 235 ) d = 235; - Cb[i] = d; + Cb[i] = CLAMP_UV(d); a = abs(Cr[i]-128); b = abs(Cr2[i]-128); c = (a * b) >> 7; d = (c + a * ( 255 - ( (a * b) >> 7) -c)) >> 7; d += 128; - if( d < 16) d= 16; else if ( d > 235 ) d= 235; - Cr[i] = d; + Cr[i] = CLAMP_UV(d); } } } @@ -912,27 +829,24 @@ void chromamagic_dodge(VJFrame *frame, VJFrame *frame2, int w, int h, b = Y2[i]; if( a >= op_a) c = a; else { - if( b > 240 ) b = 240; - if( a < 16) a = 16; - c = (a << 8) / ( 255 - b ); - if ( c < 16 ) c = 16; else if (c > 240 ) c = 240; - Y[i] = c; + if( b > pixel_Y_hi_ ) b = pixel_Y_hi_ - 5; + if( a < pixel_Y_lo_) a = pixel_Y_lo_; + c = (a << 8) / ( 256 - b ); + Y[i] = CLAMP_Y(c); a = Cb[i] - 128; b = Cb2[i] - 128; if ( b > 127 ) b = 127; c = ( a << 7 ) / ( 128 - b ); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i] - 128; b = Cr2[i] - 128; if ( b > 127 ) b = 127; c = ( a << 7 ) / ( 128 - b); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } } @@ -1011,35 +925,32 @@ void chromamagic_reflect(VJFrame *frame, VJFrame *frame2, if ( b > op_a ) c = b; else { - if ( b > 240 ) b = 240; - if ( a < 16 ) a = 16; - c = (a * a) / ( 255 - b ); - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + if ( b > pixel_Y_hi_ ) b = pixel_Y_hi_ -5; + if ( a < pixel_Y_lo_ ) a = pixel_Y_lo_; + c = (a * a) / ( 256 - b ); + Y[i] = CLAMP_Y(c); a = Cb[i]; b = Cb2[i]; - if ( a < 16 ) a = 16; - if ( b < 16 ) b = 16; + if ( a < pixel_U_lo_) a = pixel_U_lo_; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; a -= 128; b -= 128; if ( b == 128 ) b = 127; c = ( a * a ) / ( 128 - b); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]; b = Cr2[i]; - if ( a < 16 ) a = 16; - if ( b < 16 ) b = 16; + if ( a < pixel_U_lo_ ) a = pixel_U_lo_; + if ( b < pixel_U_lo_ ) b = pixel_U_lo_; a -= 128; b -= 128; if ( b == 128) b = 127; c = ( a * a ) / ( 128 - b); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } diff --git a/veejay-current/libvje/effects/chromapalette.c b/veejay-current/libvje/effects/chromapalette.c index b4b04e19..2d7dec2e 100644 --- a/veejay-current/libvje/effects/chromapalette.c +++ b/veejay-current/libvje/effects/chromapalette.c @@ -155,11 +155,9 @@ void chromapalette_apply(VJFrame *frame, int width, int height, int angle, int r if( _chroma_key( Cb[i] , Cr[i], colorKeycb,colorKeycr, accept_angle)) { U = 128+(int)( (float) (color_cb - Y[i]) * cb_mul ); - if(U < 16) U = 16; else if ( U > 240 ) U = 240; + Cb[i] = CLAMP_UV( U ); V = 128+(int)( (float) (color_cr - Y[i]) * cr_mul ); - if(V < 16) V = 16; else if ( V > 240 ) V = 240; - Cb[i] = U; - Cr[i] = V; + Cr[i] = CLAMP_UV( V ); } } } @@ -170,8 +168,7 @@ void chromapalette_apply(VJFrame *frame, int width, int height, int angle, int r if( _chroma_key( Cb[i], Cr[i], colorKeycb, colorKeycr, accept_angle)) { V = 128+(int)( (float) (color_cr - Y[i]) * cr_mul ); - if( V < 16 ) V = 16; else if ( V > 240 ) V = 240; - Cr[i] = V; + Cr[i] = CLAMP_UV( V ); } } } @@ -182,8 +179,7 @@ void chromapalette_apply(VJFrame *frame, int width, int height, int angle, int r if( _chroma_key( Cb[i] , Cr[i], colorKeycb,colorKeycr, accept_angle)) { U = 128 + (int)( (float) (color_cb - Y[i]) * cb_mul ); - if( U < 16 ) U = 16; else if ( U > 240 ) U = 240; - Cb[i] = U; + Cb[i] = CLAMP_UV(U); } } } diff --git a/veejay-current/libvje/effects/common.c b/veejay-current/libvje/effects/common.c index 3f8158f6..78a6f107 100644 --- a/veejay-current/libvje/effects/common.c +++ b/veejay-current/libvje/effects/common.c @@ -679,8 +679,8 @@ uint8_t bl_pix_divide_Y(uint8_t y1, uint8_t y2) { int c = y1 * y2; int b = 0xff - y2; - if( b < 16 || c < 16 ) - return 16; + if( b < pixel_Y_lo_ || c < pixel_Y_lo_ ) + return pixel_Y_lo_; return ( c / b ); } @@ -700,15 +700,15 @@ uint8_t bl_pix_softburn_Y(uint8_t y1, uint8_t y2) uint8_t a, b, new_Y; a = y1; b = y2; - if( a < 16) a = 16; - if( b < 16) b = 16; + if( a < pixel_Y_lo_) a = pixel_Y_lo_; + if( b < pixel_Y_lo_) b = pixel_Y_lo_; if (a + b < 0xff) { - if (a > 235) { - new_Y = 235; + if (a > pixel_Y_hi_) { + new_Y = pixel_Y_hi_; } else { new_Y = (b >> 7) / (0xff - a); - if (new_Y > 235) - new_Y = 235; + if (new_Y > pixel_Y_hi_) + new_Y = pixel_Y_hi_; } } else { new_Y = 0xff - (((0xff - a) >> 7) / b); @@ -721,8 +721,8 @@ uint8_t bl_pix_inverseburn_Y(uint8_t y1, uint8_t y2) uint8_t a, b, new_Y; a = y1; b = y2; - if (a < 16) { - new_Y = 16; + if (a < pixel_Y_lo_) { + new_Y = pixel_Y_lo_; } else { new_Y = 0xff - (((0xff - b) >> 8) / a); } @@ -732,9 +732,9 @@ uint8_t bl_pix_inverseburn_Y(uint8_t y1, uint8_t y2) uint8_t bl_pix_colordodge_Y(uint8_t y1, uint8_t y2) { - if(y2 < 16) y2 = 16; - if(y1 > 235) y1 = 235; - return ((y2 >> 8) / (0xff - y1)); + if(y1 > pixel_Y_hi_ ) + y1 = pixel_Y_hi_; + return ((y2 >> 8) / (256 - y1)); } uint8_t bl_pix_mulsub_Y(uint8_t y1, uint8_t y2) diff --git a/veejay-current/libvje/effects/common.h b/veejay-current/libvje/effects/common.h index f005ba55..babe41fe 100644 --- a/veejay-current/libvje/effects/common.h +++ b/veejay-current/libvje/effects/common.h @@ -33,6 +33,17 @@ #define func_additive(a,b) ( a + (2 * b) - 235 ) #define func_substractive(a,b) ( a + (b - 235) ) + +extern int pixel_Y_hi_; +extern int pixel_U_hi_; +extern int pixel_Y_lo_; +extern int pixel_U_lo_; + +#define CLAMP_Y( a ) ( a < pixel_Y_lo_ ? pixel_Y_lo_ : (a > pixel_Y_hi_ ? pixel_Y_hi_ : a ) ) +#define CLAMP_UV( a )( a < pixel_U_lo_ ? pixel_U_lo_ : (a > pixel_U_hi_ ? pixel_U_hi_ : a ) ) + +extern void set_pixel_range(uint8_t Yhi,uint8_t Uhi, uint8_t lo); + #ifdef HAVE_MMX #define MMX_load8byte_mm7(data)__asm__("\n\t movq %0,%%mm7\n": "=m" (data):) #endif diff --git a/veejay-current/libvje/effects/complexinvert.c b/veejay-current/libvje/effects/complexinvert.c index fa0f48cb..a5a4801d 100644 --- a/veejay-current/libvje/effects/complexinvert.c +++ b/veejay-current/libvje/effects/complexinvert.c @@ -84,7 +84,7 @@ void complexinvert_apply(VJFrame *frame, int width, uint8_t *Y2 = frame->data[0]; uint8_t *Cb2= frame->data[1]; uint8_t *Cr2= frame->data[2]; - int iy=16,iu=128,iv=128; + int iy=pixel_Y_lo_,iu=128,iv=128; _rgb2yuv( r,g,b, iy,iu,iv ); _y = (float) iy; aa = (float) iu; @@ -170,28 +170,15 @@ void complexinvert_apply(VJFrame *frame, int width, kbg = 255; } - val = 255 - ((Y[pos] + (kbg * bg_y[pos])) >> 8); - if (val < 16) - val = 16; - else if (val > 235) - val = 235; - Y[pos] = val; + + val = 255 - ((Y[pos] + (kbg * bg_y[pos])) >> 8); + Y[pos] = CLAMP_Y(val); val = 255 - ((Cb[pos] + (kbg * bg_cb[pos])) >> 8); - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cb[pos] = val; - - val = 255 - ( (Cr[pos] + (kbg * bg_cr[pos])) >> 8); - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cr[pos] = val; - + Cb[pos] = CLAMP_UV(val); + val = 255 - ( (Cr[pos] + (kbg * bg_cr[pos])) >> 8); + Cr[pos] = CLAMP_UV(val); } } } diff --git a/veejay-current/libvje/effects/complexsaturate.c b/veejay-current/libvje/effects/complexsaturate.c index 1be90715..ea90c04d 100644 --- a/veejay-current/libvje/effects/complexsaturate.c +++ b/veejay-current/libvje/effects/complexsaturate.c @@ -93,7 +93,7 @@ void complexsaturation_apply(VJFrame *frame, int width, uint8_t *Y2 = frame->data[0]; uint8_t *Cb2= frame->data[1]; uint8_t *Cr2= frame->data[2]; - int iy=16,iu=128,iv=128; + int iy=pixel_Y_lo_,iu=128,iv=128; _rgb2yuv( r,g,b, iy,iu,iv ); _y = (float) iy; aa = (float) iu; @@ -179,25 +179,13 @@ void complexsaturation_apply(VJFrame *frame, int width, } val = (Y[pos] + (kbg * bg_y[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 235) - val = 235; - Y[pos] = val; + Y[pos] = CLAMP_Y(val); val = (Cb[pos] + (kbg * bg_cb[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cb[pos] = val; + Cb[pos] = CLAMP_UV(val); val = (Cr[pos] + (kbg * bg_cr[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cr[pos] = val; + Cr[pos] = CLAMP_UV(val); int _cb = Cb[pos] - 128; int _cr = Cr[pos] - 128; diff --git a/veejay-current/libvje/effects/complexthreshold.c b/veejay-current/libvje/effects/complexthreshold.c index d6c0e285..4897d380 100644 --- a/veejay-current/libvje/effects/complexthreshold.c +++ b/veejay-current/libvje/effects/complexthreshold.c @@ -259,25 +259,13 @@ void complexthreshold_apply(VJFrame *frame, VJFrame *frame2, int width, } val = Y[pos] + (kbg * bg_y[pos]) >> 8; - if (val < 16) - val = 16; - else if (val > 235) - val = 235; - Y[pos] = val; + Y[pos] = CLAMP_Y(val); val = Cb[pos] + (kbg * bg_cb[pos]) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cb[pos] = val; + Cb[pos] = CLAMP_UV(val); val = Cr[pos] + (kbg * bg_cr[pos]) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cr[pos] = val; + Cr[pos] = CLAMP_UV(val); } } } diff --git a/veejay-current/libvje/effects/constantblend.c b/veejay-current/libvje/effects/constantblend.c index b30ecbdd..b1353da7 100644 --- a/veejay-current/libvje/effects/constantblend.c +++ b/veejay-current/libvje/effects/constantblend.c @@ -41,8 +41,8 @@ vj_effect *constantblend_init(int w, int h) ve->limits[1][0] = 31; ve->limits[0][1] = 0; // scale from 0.0 to 5.0 (only luma) ve->limits[1][1] = 500; - ve->limits[0][2] = 16; - ve->limits[1][2] = 235; + ve->limits[0][2] = pixel_Y_lo_; + ve->limits[1][2] = pixel_Y_hi_; ve->defaults[0] = 1; // blend type (additive) ve->defaults[1] = 110; // scale before blend ve->defaults[2] = 16; // constant Y @@ -67,9 +67,7 @@ void constantblend_apply( VJFrame *frame, int width, int height, for (i = 0; i < len; i++) { - // keep black real black ? how ? int tmp_val =(int)( ((float) *(Y)) * s); - if(tmp_val > 235) tmp_val = 235; else if(tmp_val < 16) tmp_val = 16; *(Y)++ = blend_y( (uint8_t) ( (uint8_t) tmp_val ) , y ); } diff --git a/veejay-current/libvje/effects/contrast.c b/veejay-current/libvje/effects/contrast.c index 79acf55b..a761b39c 100644 --- a/veejay-current/libvje/effects/contrast.c +++ b/veejay-current/libvje/effects/contrast.c @@ -19,7 +19,7 @@ */ #include "contrast.h" - +#include "common.h" vj_effect *contrast_init(int w, int h) { vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); @@ -59,19 +59,15 @@ void contrast_cb_apply(VJFrame *frame, int width,int height, int *s) { cb *= s[2]; cb = (cb + 50)/100; cb += 128; - if(cb > 235) cb = 235; - if(cb < 16) cb = 16; cr = Cr[r]; cr -= 128; cr *= s[2]; cr = (cr + 50)/100; cr += 128; - if(cr > 235) cr = 235; - if(cr < 16) cr = 16; - Cb[r] = cb; - Cr[r] = cr; + Cb[r] = CLAMP_UV(cb); + Cr[r] = CLAMP_UV(cr); } } @@ -87,9 +83,7 @@ void contrast_y_apply(VJFrame *frame, int width, int height, int *s) { m *= s[1]; m = (m + 50)/100; m += 128; - if ( m > 240) m = 240; - if ( m < 16) m = 16; - Y[r] = m; + Y[r] = CLAMP_Y(m); } } diff --git a/veejay-current/libvje/effects/crosspixel.c b/veejay-current/libvje/effects/crosspixel.c index 81c805ac..711a0cce 100644 --- a/veejay-current/libvje/effects/crosspixel.c +++ b/veejay-current/libvje/effects/crosspixel.c @@ -19,6 +19,7 @@ */ #include "crosspixel.h" +#include "common.h" #include static uint8_t *cross_pixels[3]; @@ -83,7 +84,7 @@ void crosspixel_apply(VJFrame *frame, int w, int h, int t,int v) { memcpy( cross_pixels[2], Cr, uv_len); if(t==0) { - memset(Y, 16, len); + memset(Y, pixel_Y_lo_, len); memset(Cb, 128, uv_len); memset(Cr, 128, uv_len); } diff --git a/veejay-current/libvje/effects/diff.c b/veejay-current/libvje/effects/diff.c index 894aea31..8b19ad45 100644 --- a/veejay-current/libvje/effects/diff.c +++ b/veejay-current/libvje/effects/diff.c @@ -252,11 +252,11 @@ void diff_apply(void *ed, VJFrame *frame, { if(dst[i] != 0xff) { - Y[i] = 16; + Y[i] = pixel_Y_lo_; } else { - Y[i] = 235; + Y[i] = pixel_Y_hi_; } } Cr[i] = 128; diff --git a/veejay-current/libvje/effects/dither.c b/veejay-current/libvje/effects/dither.c index 0ab863f8..523f1f7b 100644 --- a/veejay-current/libvje/effects/dither.c +++ b/veejay-current/libvje/effects/dither.c @@ -65,8 +65,6 @@ void dither_apply(VJFrame *frame, int width, int height, int size, /* Luminance , dither image. Do this for U and V too, see what happens hehe */ v = ((long) Y[((h_ * width) + w_)] + d); - if (v > 255) - v = 216; Y[(h_ * width) + w_] = (uint8_t) ((v >> 7) << 7); } } diff --git a/veejay-current/libvje/effects/emboss.c b/veejay-current/libvje/effects/emboss.c index 0c852b0f..b6d00fab 100644 --- a/veejay-current/libvje/effects/emboss.c +++ b/veejay-current/libvje/effects/emboss.c @@ -21,6 +21,7 @@ #include "emboss.h" #include #include +#include "common.h" vj_effect *emboss_init(int w, int h) { vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); @@ -57,9 +58,9 @@ void simpleedge_framedata(VJFrame *frame, int width, int height) c3 = Y[(y + 1) * width + (x + 1)]; if (b2 > a1 && b2 > a2 && b2 > a3 && b2 > b1 && b2 > b3 && b3 > c1 && b2 > c2 && b2 > c2) - Y[y * width + x] = 235; + Y[y * width + x] = pixel_Y_hi_; else - Y[y * width + x] = 16; + Y[y * width + x] = pixel_Y_lo_; } } } @@ -100,8 +101,7 @@ void another_try_edge(VJFrame *frame, int w, int h) { (Y[r+c] * -8) + (Y[r+c+1] * -1) + (Y[r+c+w] * -1) + (Y[r+c+w-1] * -1) + (Y[r+c+w+1] * -1))/9; - if(p>240) p = 240; else if ( p < 16 ) p = 16; - Y[r+c] = p; + Y[r+c] = CLAMP_Y(p); } } } @@ -129,9 +129,7 @@ void lines_white_balance_framedata(VJFrame *frame, int width, int height) Y[r + 1 + c - 1] - Y[r + 1 + c] - Y[r + 1 + c + 1] ) / 9; - if (val < 16 || val > 235) - val = 235; - Y[c + r] = val; + Y[c + r] = CLAMP_Y(val); } } } @@ -157,9 +155,7 @@ void white_emboss_framedata(VJFrame *frame, int width, int height) Y[r + 1 + c - 1] - Y[r + 1 + c] - Y[r + 1 + c + 1] ) / 9; - if (val < 16 || val > 235) - val = 235; - Y[c + r] = val; + Y[c + r] = CLAMP_Y(val); } } @@ -200,9 +196,7 @@ void gray_emboss_framedata(VJFrame *frame, int width, int height) Y[r + 1 + c - 1] - Y[r + 1 + c] - Y[r + 1 + c + 1] ) / 9; - if (val < 16 || val > 235) - val = 16; - Y[r + c] = val; + Y[r + c] = CLAMP_Y(val); } } @@ -230,9 +224,7 @@ void aggressive_emboss_framedata(VJFrame *frame, int width, int height) Y[r + 1 + c - 1] + Y[r + 1 + c] + Y[r + 1 + c + 1] ) / 9; - if (val < 16 || val > 235) - val = 16; - Y[c + r] = val; + Y[c + r] = CLAMP_Y(val); } } diff --git a/veejay-current/libvje/effects/enhancemask.c b/veejay-current/libvje/effects/enhancemask.c index 462731bb..cbb62a93 100644 --- a/veejay-current/libvje/effects/enhancemask.c +++ b/veejay-current/libvje/effects/enhancemask.c @@ -20,7 +20,7 @@ #include "enhancemask.h" - +#include "common.h" vj_effect *enhancemask_init(int width, int height) { vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); @@ -83,8 +83,8 @@ void enhancemask_apply(VJFrame *frame, int width, int height, int *s ) { d /= 100; m = m + d; // a = Y[r]; - if( m > 240) m = 240; - if( m < 16) m = 16; + if( m > pixel_Y_hi_) m = pixel_Y_hi_; + if( m < pixel_Y_lo_) m = pixel_Y_lo_; // Y[r] = (m * op0 + a * op1) / 255; Y[r] = m; } @@ -94,8 +94,8 @@ void enhancemask_apply(VJFrame *frame, int width, int height, int *s ) { d *= s[0]; d /= 100; m = m + d; - if( m > 240) m = 240; - if( m < 16) m = 16; + if( m > pixel_Y_hi_) m = pixel_Y_hi_; + if( m < pixel_Y_lo_) m = pixel_Y_lo_; Y[r] = m; } diff --git a/veejay-current/libvje/effects/fisheye.c b/veejay-current/libvje/effects/fisheye.c index ac5dc753..9f25f57d 100644 --- a/veejay-current/libvje/effects/fisheye.c +++ b/veejay-current/libvje/effects/fisheye.c @@ -180,7 +180,7 @@ void fisheye_apply(VJFrame *frame, int w, int h, int v ) { if(cached_coords[i] == -1) { - Y[i] = 16; + Y[i] = pixel_Y_lo_; Cb[i] = 128; Cr[i] = 128; } diff --git a/veejay-current/libvje/effects/flare.c b/veejay-current/libvje/effects/flare.c index 59821c1a..7881d4a1 100644 --- a/veejay-current/libvje/effects/flare.c +++ b/veejay-current/libvje/effects/flare.c @@ -102,31 +102,24 @@ void flare_exclusive(VJFrame *frame, VJFrame *frame2, int width, int height, int a = Y[i]; b = Y2[i]; - // if(a < 16) a = 16; else if(a > 235) a = 235; - // if(b < 16) b = 16; else if(b > 235) b = 235; - a *= o1; b *= o2; a = a >> 8; b = b >> 8; - c = (a+b) - ((a * b) >> 8); - if( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]-128; b = Cb2[i]-128; c = (a + b) - (( a * b) >> 8); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]-128; b = Cr2[i]-128; c = (a + b) - ((a*b) >> 8); c += 128; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -151,24 +144,19 @@ void flare_additive(VJFrame *frame, VJFrame *frame2, int width, a = (Y[i]*o1) >> 7; b = (Y2[i]*o2) >> 7; c = a + (( 2 * b ) - 255); - if( c < 16) c = 16; else if ( c > 235 ) c = 235; - - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]; b = Cb2[i]; c = a + ( ( 2 * b ) - 255 ); - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Cb[i] = c ; + Cb[i] = CLAMP_UV(c); a = Cr[i] ; b = Cr2[i] ; c = a + ( ( 2 * b ) - 255 ); - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - - Cr[i] = c ; + Cr[i] = CLAMP_UV(c); } } @@ -188,27 +176,21 @@ void flare_unfreeze( VJFrame *frame, VJFrame *frame2, int w, int h, int op_a ) { { a = Y[i]; b = Y2[i]; - if ( a < 16 ) a = 16; -// if ( b < 16 ) b = 16; + if ( a < 1 ) a = 1; c = 255 - (( op_a - b) * (op_a - b)) / a; - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Y[i] = c; + Y[i] = CLAMP_Y(c); a = Cb[i]; b = Cb2[i]; - if ( a < 16) a = 16; -// if ( b < 16) b = 16; + if ( a < 1) a = 1; c = 255 - (( 255 - b) * ( 255 - b )) / a; - if ( c < 16 ) c = 16; else if ( c > 235 ) c = 235; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]; b = Cr2[i]; - if ( a < 16 ) a = 16; -// if ( b < 16 ) b = 16; + if ( a < 1 ) a = 1; c = 255 - ((255 -b ) * (255 - b)) /a ; - if ( c < 16 ) c = 16; else if ( c > 235) c = 235; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } diff --git a/veejay-current/libvje/effects/keyselect.c b/veejay-current/libvje/effects/keyselect.c index 8a695cac..1054843e 100644 --- a/veejay-current/libvje/effects/keyselect.c +++ b/veejay-current/libvje/effects/keyselect.c @@ -74,12 +74,10 @@ uint8_t blend_func1(uint8_t a, uint8_t b) { uint8_t blend_func2(uint8_t a, uint8_t b) { uint8_t val; - if(a < 16) a = 16; - if(b < 16) b = 16; + if(a < pixel_Y_lo_) a = pixel_Y_lo_; + if(b < pixel_Y_lo_) b = pixel_Y_lo_; val = 255 - ((255-b) * (255-b))/a; - if(val < 16)val=16; - if(val > 235) val=235; - return val; + return CLAMP_Y(val); } uint8_t blend_func3(uint8_t a , uint8_t b) { @@ -89,28 +87,23 @@ uint8_t blend_func3(uint8_t a , uint8_t b) { uint8_t blend_func4(uint8_t a, uint8_t b) { uint8_t val; - if(b > 235) b = 235; + if(b > pixel_Y_hi_) b = pixel_Y_hi_; val = (a * a) / ( 255 - b ); - if(val < 16) val = a; - if(val > 235) val = a; - return val; + return CLAMP_Y(val); } uint8_t blend_func5(uint8_t a, uint8_t b) { uint8_t val; int c = 255 - b; - if(c<16)c=16; + if( c < pixel_Y_lo_ ) + c = pixel_Y_lo_; val = b / c; - if(val > 235) val = 235; - if(val < 16) val = 16; - return val; + return CLAMP_Y(val); } uint8_t blend_func6(uint8_t a, uint8_t b) { - uint8_t val = a + (2 * (b)) - 235; - if(val < 16) val = 16; - if(val > 235) val = 235; - return val; + uint8_t val = a + (2 * (b)) - 255; + return CLAMP_Y(val); } uint8_t blend_func7(uint8_t a, uint8_t b) { @@ -121,8 +114,7 @@ uint8_t blend_func8(uint8_t a, uint8_t b) { int c; if(b < 128) c = (a * b) >> 7; else c = 255 - ((255-b)*(255-a)>>7); - if(c<16)c=16; - return (uint8_t) c; + return CLAMP_Y(c); } @@ -166,7 +158,7 @@ void keyselect_apply( VJFrame *frame, VJFrame *frame2, int width, uint8_t *Y2 = frame2->data[0]; uint8_t *Cb2= frame2->data[1]; uint8_t *Cr2= frame2->data[2]; - int iy=16,iu=128,iv=128; + int iy=pixel_Y_lo_,iu=128,iv=128; _rgb2yuv( r,g,b, iy,iu,iv ); _y = (float) iy; aa = (float) iu; diff --git a/veejay-current/libvje/effects/lumablend.c b/veejay-current/libvje/effects/lumablend.c index ed7b523a..493f005d 100644 --- a/veejay-current/libvje/effects/lumablend.c +++ b/veejay-current/libvje/effects/lumablend.c @@ -94,14 +94,6 @@ void opacity_by_threshold_(uint8_t * yuv1[3], uint8_t * yuv2[3], int width, for (x = 0; x < width; x++) { a1 = yuv1[0][x + y]; a2 = yuv2[0][x + y]; - if (a1 < 16) - a1 = 16; - else if (a1 > 235) - a1 = 235; - if (a2 < 16) - a2 = 16; - else if (a2 > 235) - a2 = 235; if (a2 > threshold && a2 < threshold2) { yuv1[0][x + y] = (op0 * a1 + op1 * a2) >> 8; yuv1[1][x + y] = diff --git a/veejay-current/libvje/effects/lumakey.c b/veejay-current/libvje/effects/lumakey.c index dd4c5891..fd5ed6af 100644 --- a/veejay-current/libvje/effects/lumakey.c +++ b/veejay-current/libvje/effects/lumakey.c @@ -75,9 +75,6 @@ void lumakey_simple(uint8_t * yuv1[3], uint8_t * yuv2[3], int width, Y = (op0 * a1 + op1 * a2 )/255; Cb = (op0 * yuv1[1][x+y] + op1 * yuv2[1][x+y])/255; Cr =(op0 * yuv1[2][x+y] + op1 * yuv2[2][x+y])/255; - yuv1[0][x+y] = Y < 16 ? 16: Y > 240 ? 240 : Y; - yuv1[1][x+y] = Cb < 16 ? 16 : Cb > 235 ? 235 : Cb; - yuv1[2][x+y] = Cr < 16 ? 16 : Cr > 235 ? 235 : Cr; } */ diff --git a/veejay-current/libvje/effects/lumamagick.c b/veejay-current/libvje/effects/lumamagick.c index 898ff847..8038d0e4 100644 --- a/veejay-current/libvje/effects/lumamagick.c +++ b/veejay-current/libvje/effects/lumamagick.c @@ -22,7 +22,7 @@ #include #include "magicoverlays.h" - +#include "common.h" /* 04/01/03: added transparency parameters for frame a and frame b in each function */ vj_effect *lumamagick_init(int width, int height) @@ -72,30 +72,18 @@ void _lumamagick_adddistorted(VJFrame *frame, VJFrame *frame2, a = Y[i] * opacity_a; b = Y2[i] * opacity_b; c = a + b; - if (c > 235) - c = 235; - if (c < 16) - c = 16; - Y[i] = c; + Y[i] = CLAMP_Y(c); } for (i = 0; i < uv_len; i++) { a = Cb[i]; b = Cb2[i]; c = a + b; - if (c > 240) - c = 240; - if (c < 16) - c = 16; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]; b = Cr2[i]; c = a + b; - if (c > 240) - c = 240; - if (c < 16) - c = 16; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -251,8 +239,8 @@ void _lumamagick_divide(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { b = (Y[i] * opacity_a) * (Y[i] * opacity_a); c = 255 - (Y2[i] * opacity_b); - if (c < 16) - c = 16; + if (c < pixel_Y_lo_) + c = pixel_Y_lo_; a = b / c; Y[i] = a; } @@ -271,10 +259,6 @@ void _lumamagick_additive(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { a = (Y[i] * opacity_a) + (2 * (Y2[i] * opacity_b)) - 255; -// if (a < 16) -// a = 16; -// if (a > 235) -// a = 235; Y[i] = a; } } @@ -312,16 +296,16 @@ void _lumamagick_softburn(VJFrame *frame, VJFrame *frame2, int width, b = Y2[i] * opacity_b; if (a + b < 255) { - if (a > 235) + if (a > pixel_Y_hi_) c = a; else - c = (b >> 7) / (255 - a); + c = (b >> 7) / (256 - a); } else { - if (b < 16) - b = 16; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = 255 - (((255 - a) >> 7) / b); - if (c < 16) - c = 16; + if (c < pixel_Y_lo_) + c = pixel_Y_lo_; } Y[i] = c; } @@ -341,8 +325,8 @@ void _lumamagick_inverseburn(VJFrame *frame, VJFrame *frame2, for (i = 0; i < len; i++) { a = Y[i] * opacity_a; b = Y2[i] * opacity_b; - if (a < 16) - c = 16; + if (a < pixel_Y_lo_) + c = pixel_Y_lo_; else c = 255 - (((255 - b) >> 8) / a); Y[i] = c; @@ -364,10 +348,10 @@ void _lumamagick_colordodge(VJFrame *frame, VJFrame *frame2, for (i = 0; i < len; i++) { a = Y[i] * opacity_a; b = Y2[i] * opacity_b; - if (a >= 235) - c = 235; + if (a >= pixel_Y_hi_) + c = pixel_Y_hi_; else - c = (b >> 8) / (235 - a); + c = (b >> 8) / (pixel_Y_hi_ - a); Y[i] = c; } @@ -386,9 +370,9 @@ void _lumamagick_mulsub(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { a = Y[i] * opacity_a; - b = (235 - Y2[i]) * opacity_b; - if (b < 16) - b = 16; + b = (pixel_Y_hi_ - Y2[i]) * opacity_b; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = a / b; Y[i] = c; } @@ -487,10 +471,10 @@ void _lumamagick_basecolor(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { a = Y[i] * opacity_a; b = Y2[i] * opacity_b; - if (a < 16) - a = 16; - if (b < 16) - b = 16; + if (a < pixel_Y_lo_) + a = pixel_Y_lo_; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = a * b >> 7; d = c + a * ((255 - (((255 - a) * (255 - b)) >> 7) - c) >> 7); //8 Y[i] = d; @@ -512,8 +496,8 @@ void _lumamagick_freeze(VJFrame *frame, VJFrame *frame2, int width, a = Y[i] * opacity_a; b = Y2[i] * opacity_b; - if (b < 16) - c = 16; + if (b < pixel_Y_lo_) + c = pixel_Y_lo_; else c = 255 - ((255 - a) * (255 - a)) / b; @@ -536,12 +520,12 @@ void _lumamagick_unfreeze(VJFrame *frame, VJFrame *frame2, int width, a = Y[i] * opacity_a; b = Y2[i] * opacity_b; - if (a < 16) - c = 16; + if (a < pixel_Y_lo_) + c = pixel_Y_lo_; else - c = 255 - ((255 - b) * (255 - b)) / a; - if (c < 16) - c = 16; + c = 255 - ((256 - b) * (256 - b)) / a; + if (c < pixel_Y_lo_) + c = pixel_Y_lo_; Y[i] = c; } @@ -565,9 +549,9 @@ void _lumamagick_hardlight(VJFrame *frame, VJFrame *frame2, int width, if (b < 128) c = (a * b) >> 7; else - c = 255 - ((255 - b) * (255 - a) >> 7); - if (c < 16) - c = 16; + c = 255 - ((256 - b) * (256 - a) >> 7); + if (c < pixel_Y_lo_) + c = pixel_Y_lo_; Y[i] = c; } @@ -852,12 +836,12 @@ void _lumamagick_addtest4(VJFrame *frame, VJFrame *frame2, int width, a = Y[i] * opacity_a; b = Y2[i] * opacity_b; b = b - 255; - if (a < 16) - a = 16; - if (b < 16) + if (a < pixel_Y_lo_) + a = pixel_Y_lo_; + if (b < pixel_Y_lo_) b = Y2[i] * opacity_b; - if (b < 16) - b = 16; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = (a * a) / b; Y[i] = c; @@ -919,19 +903,19 @@ void _lumamagick_addtest3(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { a = Y[i] * opacity_a; b = (255 - Y2[i]) * opacity_b; - if (b < 16) - b = 16; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = (a * a) / b; Y[i] = c; } for (i = 0; i < uv_len; i++) { //a = Cb[i] * opacity_a; - //b = (235 - Cb2[i]) * opacity_b; - //if (b < 16) b = Cb2[i] * opacity_b; + //b = (pixel_Y_hi_ - Cb2[i]) * opacity_b; + //if (b < pixel_Y_lo_) b = Cb2[i] * opacity_b; a = Cb[i]; b = 255 - Cb2[i]; - if (b < 16) + if (b < pixel_U_lo_) b = Cb2[i]; c = (a >> 1) + (b >> 1); @@ -939,17 +923,16 @@ void _lumamagick_addtest3(VJFrame *frame, VJFrame *frame2, int width, Cb[i] = c; //a = Cr[i] * opacity_a; - //b = (235 - Cr2[i]) * opacity_b; - //if (b < 16) b = Cr2[i] * opacity_b; + //b = (pixel_Y_hi_ - Cr2[i]) * opacity_b; + //if (b < pixel_Y_lo_) b = Cr2[i] * opacity_b; a = Cr[i]; b = 255 - Cr2[i]; - if (b < 16) + if (b < pixel_U_lo_) b = Cr2[i]; c = (a >> 1) + (b >> 1); - //c = (a * a) / ( b - 255 ) ; Cr[i] = c; @@ -972,12 +955,12 @@ void _lumamagick_addlum(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { a = Y[i] * opacity_a; b = Y2[i] * opacity_b; - if (b > 235) - b = 235; + if (b > pixel_Y_hi_) + b = pixel_Y_hi_; if ((255 - b) > 0) { c = (a * a) / 255; } else { - c = (a * a) / (255 - b); + c = (a * a) / (256 - b); } Y[i] = c; diff --git a/veejay-current/libvje/effects/magicoverlays.c b/veejay-current/libvje/effects/magicoverlays.c index 838fefb2..cca8ae62 100644 --- a/veejay-current/libvje/effects/magicoverlays.c +++ b/veejay-current/libvje/effects/magicoverlays.c @@ -22,7 +22,7 @@ #include #include - +#include "common.h" vj_effect *overlaymagic_init(int w, int h) { vj_effect *ve = (vj_effect *) vj_malloc(sizeof(vj_effect)); @@ -61,31 +61,19 @@ void _overlaymagic_adddistorted(VJFrame *frame, VJFrame *frame2, a = Y[i]; b = Y2[i]; c = a + b; - if (c > 240) - c = 240; - if (c < 16) - c = 16; - Y[i] = c; + Y[i] = CLAMP_Y(c); } for (i = 0; i < uv_len; i++) { a = Cb[i]; b = Cb2[i]; c = a + b; - if (c > 235) - c = 235; - if (c < 16) - c = 16; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i]; b = Cr2[i]; c = a + b; - if (c > 235) - c = 235; - if (c < 16) - c = 16; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -217,7 +205,7 @@ void _overlaymagic_divide(VJFrame *frame, VJFrame *frame2, int width, b = Y[i] * Y[i]; c = 255 - Y2[i]; if (c == 0) - c = 16; + c = pixel_Y_lo_; a = b / c; Y[i] = a; } @@ -234,9 +222,7 @@ void _overlaymagic_additive(VJFrame *frame, VJFrame *frame2, int a; while(len--) { a = Y[len] + (2 * Y2[len]) - 255; -// a = Y[len] + (2 * (Y2[len]-128)&255); - if(a < 16) a = 16; else if (a > 235) a = 235; - Y[len] = a; + Y[len] = CLAMP_Y(a); } } @@ -270,14 +256,14 @@ void _overlaymagic_softburn(VJFrame *frame, VJFrame *frame2, a = Y[i]; b = Y2[i]; - if (a + b < 240) { - if (a == 235) + if (a + b < pixel_Y_hi_) { + if (a == pixel_Y_hi_) c = a; else - c = (b >> 7) / (255 - a); + c = (b >> 7) / (256 - a); } else { - if (b < 16) - b = 16; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = 255 - (((255 - a) >> 7) / b); } Y[i] = c; @@ -296,15 +282,11 @@ void _overlaymagic_inverseburn(VJFrame *frame, VJFrame *frame2, for (i = 0; i < len; i++) { a = Y[i]; b = Y2[i]; - if (a < 16) - c = 16; + if (a < pixel_Y_lo_) + c = pixel_Y_lo_; else c = 255 - (((255 - b) >> 8) / a); - if (c < 16) - c = 16; - if (c > 235) - c = 235; - Y[i] = c; + Y[i] = CLAMP_Y(c); } } @@ -321,13 +303,13 @@ void _overlaymagic_colordodge(VJFrame *frame, VJFrame *frame2, for (i = 0; i < len; i++) { a = Y[i]; b = Y2[i]; - if (a >= 235) - c = 235; + if (a >= pixel_Y_hi_) + c = pixel_Y_hi_; else c = (b >> 8) / (256 - a); - if (c > 235) - c = 235; + if (c > pixel_Y_hi_) + c = pixel_Y_hi_; Y[i] = c; } } @@ -344,8 +326,8 @@ void _overlaymagic_mulsub(VJFrame *frame, VJFrame *frame2, int width, for (i = 0; i < len; i++) { a = Y[i]; b = 255 - Y2[i]; - if (b < 16) - b = 16; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = a / b; Y[i] = c; } @@ -429,16 +411,14 @@ void _overlaymagic_exclusive(VJFrame *frame, VJFrame *frame2, b = Cb2[i]-128; c = a +b - (( a * b ) >> 8); c += 128; - if ( c < 16 ) c = 16; else if ( c > 240 ) c = 240; - Cb[i] = c; + Cb[i] = CLAMP_UV(c); a = Cr[i] - 128; b = Cr2[i] - 128; c = a + b - (( a * b) >> 8); c += 128; - if ( c < 16) c = 16; else if ( c > 240 ) c = 240; - Cr[i] = c; + Cr[i] = CLAMP_UV(c); } } @@ -454,10 +434,10 @@ void _overlaymagic_basecolor(VJFrame *frame, VJFrame *frame2, for (i = 0; i < len; i++) { a = Y[i]; b = Y2[i]; - if (a < 16) - a = 16; - if (b < 16) - b = 16; + if (a < pixel_Y_lo_) + a = pixel_Y_lo_; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = a * b >> 7; d = c + a * ((255 - (((255 - a) * (255 - b)) >> 7) - c) >> 7); //8 Y[i] = d; @@ -477,10 +457,10 @@ void _overlaymagic_freeze(VJFrame *frame, VJFrame *frame2, int width, a = Y[i]; b = Y2[i]; - if (b < 16) - c = a; //16 + if (b < pixel_Y_lo_) + c = a; else - c = 255 - ((255 - a) * (255 - a)) / b; + c = 255 - ((256 - a) * (256 - a)) / b; Y[i] = c; } } @@ -498,8 +478,8 @@ void _overlaymagic_unfreeze(VJFrame *frame, VJFrame *frame2, a = Y[i]; b = Y2[i]; - if (a < 16) - c = 16; + if (a < pixel_Y_lo_) + c = pixel_Y_lo_; else c = 255 - ((255 - b) * (255 - b)) / a; Y[i] = c; @@ -786,12 +766,12 @@ void _overlaymagic_addtest4(VJFrame *frame, VJFrame *frame2, a = Y[i]; b = Y2[i]; b = b - 255; - if (a < 16) - a = 16; - if (b < 16) + if (a < pixel_Y_lo_) + a = pixel_Y_lo_; + if (b < pixel_Y_lo_) b = Y2[i]; - if (b < 16) - b = 16; + if (b < pixel_Y_lo_) + b = pixel_Y_lo_; c = (a * a) / b; Y[i] = c; @@ -812,30 +792,30 @@ void _overlaymagic_try a = Y[i]; b = Y[i]; - if (b < 16) - p = 16; + if (b < pixel_Y_lo_) + p = pixel_Y_lo_; else - p = 255 - ((255 - a) * (255 - a)) / b; - if (p < 16) - p = 16; + p = 255 - ((256 - a) * (256 - a)) / b; + if (p < pixel_Y_lo_) + p = pixel_Y_lo_; /* calc q */ a = Y2[i]; b = Y2[i]; - if (b < 16) - q = 16; + if (b < pixel_Y_lo_) + q = pixel_Y_lo_; else - q = 255 - ((255 - a) * (255 - a)) / b; - if (b < 16) - q = 16; + q = 255 - ((256 - a) * (256 - a)) / b; + if (b < pixel_Y_lo_) + q = pixel_Y_lo_; /* calc pixel */ - if (q < 16) - q = 16; + if (q < pixel_Y_lo_) + q = pixel_Y_lo_; else - q = 255 - ((255 - p) * (255 - a)) / q; - if (q < 16) - q = 16; + q = 255 - ((256 - p) * (256 - a)) / q; + if (q < pixel_Y_lo_) + q = pixel_Y_lo_; Y[i] = q; diff --git a/veejay-current/libvje/effects/pencilsketch.c b/veejay-current/libvje/effects/pencilsketch.c index 012a73d9..05678c08 100644 --- a/veejay-current/libvje/effects/pencilsketch.c +++ b/veejay-current/libvje/effects/pencilsketch.c @@ -28,8 +28,8 @@ vj_effect *pencilsketch_init(int w, int h) ve->limits[1] = (int *) vj_malloc(sizeof(int) * ve->num_params); ve->defaults = (int *) vj_malloc(sizeof(int) * ve->num_params); ve->defaults[0] = 0;/* type */ - ve->defaults[1] = 16; /* min */ - ve->defaults[2] = 235; /* max */ + ve->defaults[1] = pixel_Y_lo_; /* min */ + ve->defaults[2] = pixel_Y_hi_; /* max */ ve->limits[0][0] = 0; ve->limits[1][0] = 8; ve->limits[0][1] = 0; @@ -57,7 +57,6 @@ typedef uint8_t (*_pcbcr) (uint8_t a, uint8_t b); uint8_t p = 255 - ( abs ( (255 - abs((255-a)-a)) - (255-abs((255-b)-b))) ); p = (abs(abs(p-b) - b)); - // if( p >= 16 || p <= t_max) p = 16 ; else p = 240; return p; } @@ -69,7 +68,6 @@ typedef uint8_t (*_pcbcr) (uint8_t a, uint8_t b); static uint8_t _pcf_dneg2(uint8_t a,uint8_t b, int t_max) { uint8_t p = ( 255 - abs ( (255-a)- b ) ); - if( p >= 16 || p <= t_max) p = 16 ; else p = 240; return p; } @@ -77,29 +75,24 @@ typedef uint8_t (*_pcbcr) (uint8_t a, uint8_t b); { uint8_t p = ( (b < a) ? b : a); p = ( 255 - abs( (255-p) - b ) ); - // if( p >= 16 || p <= t_max) p = 16 ; else p = 240; return p; } static uint8_t _pcf_max(uint8_t a,uint8_t b, int t_max) { - int p = ( (b > a) ? b : a); - if( p <= 0 ) - return 0; - p = ( 255 - ((255 - b) * (255 - b)) / p); - // if( p >= 16 || p <= t_max) p = 16 ; else p = 240; + int p = ( (b > a) ? b : a); + p = CLAMP_Y(p); + p = ( 255 - ((256 - b) * (256 - b)) / p); return (uint8_t)p; } static uint8_t _pcf_pq(uint8_t a,uint8_t b, int t_max) { - if(a <= 0 ) a=16; - if(b <= 0 ) b=16; - int p = 255 - ((255-a) * (255-a)) / a; - int q = 255 - ((255-b) * (255-b)) / b; - if(q <= 0 ) q=16; - p = ( 255 - ((255-p) * (255 - a)) / q); - // if( p >= 16 || p <= t_max) p = 16 ; else p = 240; + a = CLAMP_Y(a); + b = CLAMP_Y(b); + int p = 255 - ((256-a) * (256-a)) / a; + int q = 255 - ((256-b) * (256-b)) / b; + p = ( 255 - ((256-p) * (256 - a)) / q); return (uint8_t)p; } @@ -109,8 +102,6 @@ typedef uint8_t (*_pcbcr) (uint8_t a, uint8_t b); 255 - ( abs ( (255 - abs((255-a)-a)) - (255-abs((255-b)-b))) ); p = (abs(abs(p-b) - b)); p = p + b - (( p * b ) >> 8); - // if( p >= 16 || p <= t_max) p = 16 ; else p = 240; - return p; } static uint8_t _pcbcr_color(uint8_t a,uint8_t b) @@ -122,7 +113,7 @@ typedef uint8_t (*_pcbcr) (uint8_t a, uint8_t b); static uint8_t _pcf_none(uint8_t a, uint8_t b, int t_max) { - if( a >= 16 || a <= t_max) a = 16 ; else a = 240; + if( a > pixel_Y_lo_ || a <= t_max) a = pixel_Y_lo_ ; else a = pixel_Y_hi_; return a; } @@ -174,7 +165,6 @@ void pencilsketch_apply( for(i=0; i < len; i++) { y = Y[i]; - // if( y < 16 ) y = 16; else if (y > 235) y = 235; yb = y; /* substract user defined mask from image */ @@ -194,7 +184,7 @@ void pencilsketch_apply( } else { - Y[i] = 240; + Y[i] = pixel_Y_hi_; } } diff --git a/veejay-current/libvje/effects/photoplay.c b/veejay-current/libvje/effects/photoplay.c index 99d07def..73e47b9c 100644 --- a/veejay-current/libvje/effects/photoplay.c +++ b/veejay-current/libvje/effects/photoplay.c @@ -77,7 +77,7 @@ static int prepare_filmstrip(int film_length, int w, int h) photo_list[i]->data[j] = vj_malloc(sizeof(uint8_t) * picture_width * picture_height ); if(!photo_list[i]->data[j]) return 0; - memset(photo_list[i]->data[j], (j==0 ? 16 : 128), picture_width *picture_height ); + memset(photo_list[i]->data[j], (j==0 ? pixel_Y_lo_ : 128), picture_width *picture_height ); } // val+= inc; } @@ -154,7 +154,7 @@ static void take_photo( uint8_t *plane, uint8_t *dst_plane, int w, int h, int in if(sum > 0) dst_plane[(dst_y*box_width)+dst_x] = sum / (step_y*step_x); else - dst_plane[(dst_y*box_width)+dst_x] = 16; + dst_plane[(dst_y*box_width)+dst_x] = pixel_Y_lo_; dst_x++; } diff --git a/veejay-current/libvje/effects/rgbkey.c b/veejay-current/libvje/effects/rgbkey.c index cc1e8ca3..a3416d5e 100644 --- a/veejay-current/libvje/effects/rgbkey.c +++ b/veejay-current/libvje/effects/rgbkey.c @@ -214,25 +214,13 @@ void rgbkey_apply1(VJFrame *frame, VJFrame *frame2, int width, } val = (Y[pos] + (kbg * bg_y[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 235) - val = 235; - Y[pos] = val; + Y[pos] = CLAMP_Y(val); val = (Cb[pos] + (kbg * bg_cb[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cb[pos] = val; + Cb[pos] = CLAMP_UV(val); val = (Cr[pos] + (kbg * bg_cr[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cr[pos] = val; + Cr[pos] = CLAMP_UV(val); } } @@ -360,25 +348,13 @@ void rgbkey_apply2(VJFrame *frame, VJFrame *frame2, int width, } val = (Y[pos] + (kbg * bg_y[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 235) - val = 235; - Y[pos] = val; + Y[pos] = CLAMP_Y(val); val = (Cb[pos] + (kbg * bg_cb[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cb[pos] = val; + Cb[pos] = CLAMP_UV(val); val = (Cr[pos] + (kbg * bg_cr[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; - Cr[pos] = val; + Cr[pos] = CLAMP_UV(val); } } } diff --git a/veejay-current/libvje/effects/rgbkeysmooth.c b/veejay-current/libvje/effects/rgbkeysmooth.c index c65f9f0f..dcaed8e5 100644 --- a/veejay-current/libvje/effects/rgbkeysmooth.c +++ b/veejay-current/libvje/effects/rgbkeysmooth.c @@ -191,24 +191,14 @@ void rgbkeysmooth_apply(VJFrame *frame, VJFrame *frame2, int width, } val = (Y[pos] + (kbg * bg_y[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 235) - val = 235; + val = CLAMP_Y(val); Y[pos] = ((val*op0)+(fg_y[pos]*op1) )>>8 ; - + val = (Cb[pos] + (kbg * bg_cb[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; + val = CLAMP_UV(val); Cb[pos] = ((val*op0) + (fg_cb[pos]*op1) )>>8; - val = (Cr[pos] + (kbg * bg_cr[pos])) >> 8; - if (val < 16) - val = 16; - else if (val > 240) - val = 240; + val = CLAMP_UV(val); Cr[pos] = ((val*op0) + (fg_cr[pos]*op1) )>>8; } diff --git a/veejay-current/libvje/effects/scratcher.c b/veejay-current/libvje/effects/scratcher.c index a1b23244..a14212cf 100644 --- a/veejay-current/libvje/effects/scratcher.c +++ b/veejay-current/libvje/effects/scratcher.c @@ -67,7 +67,7 @@ int scratcher_malloc(int w, int h) frame[0] = (uint8_t *) vj_malloc(w * h * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); if(!frame[0]) return 0; - memset( frame[0], 16, w * h * MAX_SCRATCH_FRAMES ); + memset( frame[0], pixel_Y_lo_, w * h * MAX_SCRATCH_FRAMES ); frame[1] = (uint8_t *) vj_malloc( ((w * h)/4) * sizeof(uint8_t) * MAX_SCRATCH_FRAMES); if(!frame[1]) return 0; diff --git a/veejay-current/libvje/effects/swirl.c b/veejay-current/libvje/effects/swirl.c index a0cf5965..48e5a53d 100644 --- a/veejay-current/libvje/effects/swirl.c +++ b/veejay-current/libvje/effects/swirl.c @@ -167,7 +167,7 @@ void swirl_apply(VJFrame *frame, int w, int h, int v) { if(cached_coords[i] == -1) { - Y[i] = 16; + Y[i] = pixel_Y_lo_; Cb[i] = 128; Cr[i] = 128; } diff --git a/veejay-current/libvje/effects/uvcorrect.c b/veejay-current/libvje/effects/uvcorrect.c index 38363c7b..0e7f793b 100644 --- a/veejay-current/libvje/effects/uvcorrect.c +++ b/veejay-current/libvje/effects/uvcorrect.c @@ -74,8 +74,8 @@ vj_effect *uvcorrect_init(int w, int h) ve->defaults[2] = 128; ve->defaults[3] = 10; ve->defaults[4] = 10; - ve->defaults[5] = 16; - ve->defaults[6] = 240; + ve->defaults[5] = pixel_U_lo_; + ve->defaults[6] = pixel_U_hi_; ve->description = "U/V Correction"; ve->sub_format = 0; diff --git a/veejay-current/libvje/effects/videomask.c b/veejay-current/libvje/effects/videomask.c index cde86f94..2d1b2a0a 100644 --- a/veejay-current/libvje/effects/videomask.c +++ b/veejay-current/libvje/effects/videomask.c @@ -22,7 +22,7 @@ #include "../../config.h" #include #include "../subsample.h" - +#include "common.h" vj_effect *videomask_init(int w,int h) { @@ -49,8 +49,8 @@ void videomask_apply(VJFrame *frame, VJFrame *frame2, int width, unsigned int i, op0, op1; const int len = frame->len; const int uv_len = frame->uv_len; - const uint8_t pure_white_y = 235; - const uint8_t pure_white_c = 240; + const uint8_t pure_white_y = pixel_Y_hi_; + const uint8_t pure_white_c = pixel_U_hi_; uint8_t *Y = frame->data[0]; uint8_t *Cb= frame->data[1]; uint8_t *Cr= frame->data[2]; diff --git a/veejay-current/libvje/effects/videoplay.c b/veejay-current/libvje/effects/videoplay.c index 356bc5d7..7610166f 100644 --- a/veejay-current/libvje/effects/videoplay.c +++ b/veejay-current/libvje/effects/videoplay.c @@ -78,7 +78,7 @@ static int prepare_filmstrip(int film_length, int w, int h) video_list[i]->data[j] = vj_malloc(sizeof(uint8_t) * picture_width * picture_height ); if(!video_list[i]->data[j]) return 0; - memset(video_list[i]->data[j], (j==0 ? 16 : 128), picture_width *picture_height ); + memset(video_list[i]->data[j], (j==0 ? pixel_Y_lo_ : 128), picture_width *picture_height ); } // val+= inc; } @@ -155,7 +155,7 @@ static void take_video( uint8_t *plane, uint8_t *dst_plane, int w, int h, int in if(sum > 0) dst_plane[(dst_y*box_width)+dst_x] = sum / (step_y*step_x); else - dst_plane[(dst_y*box_width)+dst_x] = 16; + dst_plane[(dst_y*box_width)+dst_x] = pixel_Y_lo_; dst_x++; } diff --git a/veejay-current/libvje/effects/videowall.c b/veejay-current/libvje/effects/videowall.c index e1c6d3ef..18ca503c 100644 --- a/veejay-current/libvje/effects/videowall.c +++ b/veejay-current/libvje/effects/videowall.c @@ -184,7 +184,7 @@ static void take_photo( uint8_t *plane, uint8_t *dst_plane, int w, int h, int in if(sum > 0) dst_plane[(dst_y*box_width)+dst_x] = sum / (step_y*step_x); else - dst_plane[(dst_y*box_width)+dst_x] = 16; + dst_plane[(dst_y*box_width)+dst_x] = pixel_Y_lo_; dst_x++; } diff --git a/veejay-current/libvje/effects/water.c b/veejay-current/libvje/effects/water.c index 2432764a..963dcecf 100644 --- a/veejay-current/libvje/effects/water.c +++ b/veejay-current/libvje/effects/water.c @@ -30,7 +30,7 @@ #include #include #include - +#include "common.h" static uint8_t *ripple_data[3]; static int stat; @@ -102,7 +102,7 @@ int water_malloc(int width, int height) { ripple_data[0] = (uint8_t*)vj_malloc(sizeof(uint8_t) * width * height); if(!ripple_data[0]) return 0; - memset( ripple_data[0], 16, width*height); + memset( ripple_data[0], pixel_Y_lo_, width*height); map_h = height / 2 + 1; diff --git a/veejay-current/libvje/plugload.c b/veejay-current/libvje/plugload.c index b0b1ab28..aa478414 100644 --- a/veejay-current/libvje/plugload.c +++ b/veejay-current/libvje/plugload.c @@ -993,10 +993,11 @@ void plug_process_mix( VJFrame *frame, VJFrame *frame_b,int fx_id, int src_fmt ) int srcf = 0; if( src_fmt == 1 ) srcf = PIX_FMT_YUV422P; - else if( src_fmt == 2 ) - srcf = PIX_FMT_YUV444P; - else - srcf = PIX_FMT_YUV420P; + else if( src_fmt == 0 ) + srcf = PIX_FMT_YUV420P; + else if ( src_fmt == 2 ) + srcf = PIX_FMT_YUVJ420P; + else srcf = PIX_FMT_YUVJ422P; img_convert( &p1, PIX_FMT_RGBA32, &p2, srcf, @@ -1066,10 +1067,11 @@ void plug_process( VJFrame *frame,VJFrame *b, int fx_id, int src_fmt ) int srcf = 0; if( src_fmt == 1 ) srcf = PIX_FMT_YUV422P; - else if( src_fmt == 2 ) - srcf = PIX_FMT_YUV444P; - else - srcf = PIX_FMT_YUV420P; + else if( src_fmt == 0 ) + srcf = PIX_FMT_YUV420P; + else if( src_fmt == 2 ) + srcf = PIX_FMT_YUVJ420P; + else srcf = PIX_FMT_YUVJ422P; img_convert( &p1, PIX_FMT_RGBA32, &p2, srcf, diff --git a/veejay-current/libvje/vj-effect.c b/veejay-current/libvje/vj-effect.c index a499fc25..ff78a1df 100644 --- a/veejay-current/libvje/vj-effect.c +++ b/veejay-current/libvje/vj-effect.c @@ -148,6 +148,20 @@ #ifdef USE_SWSCALER #include "effects/picinpic.h" #endif + +int pixel_Y_hi_ = 235; +int pixel_U_hi_ = 240; +int pixel_Y_lo_ = 16; +int pixel_U_lo_ = 16; + +void set_pixel_range(uint8_t Yhi,uint8_t Uhi, uint8_t lo) +{ + pixel_Y_hi_ = Yhi; + pixel_U_hi_ = Uhi; + pixel_U_lo_ = lo; + pixel_Y_lo_ = lo; +} + static struct { int (*mem_init)(int width, int height); @@ -397,11 +411,16 @@ void vj_effect_deactivate_all() } } -void vj_effect_initialize(int width, int height) +void vj_effect_initialize(int width, int height, int full_range) { int i = VJ_VIDEO_COUNT; int k; + if( full_range ) + { + set_pixel_range( 255, 255,0 ); + } + n_ext_plugs_ = plug_detect_plugins(); if( n_ext_plugs_ > 0 ) diff --git a/veejay-current/libvje/vje.h b/veejay-current/libvje/vje.h index a50cb64b..21c782af 100644 --- a/veejay-current/libvje/vje.h +++ b/veejay-current/libvje/vje.h @@ -98,7 +98,7 @@ typedef struct vj_effect_t { } vj_effect; // initialize library -extern void vj_effect_initialize(int width, int height); +extern void vj_effect_initialize(int width, int height, int range); extern void vj_effect_shutdown(); // convert effect number to internal num diff --git a/veejay-current/veejay/liblavplayvj.c b/veejay-current/veejay/liblavplayvj.c index 24d1bdd0..05a2db0c 100644 --- a/veejay-current/veejay/liblavplayvj.c +++ b/veejay-current/veejay/liblavplayvj.c @@ -268,14 +268,14 @@ void veejay_set_sampling(veejay_t *info, subsample_mode_t m) video_playback_setup *settings = (video_playback_setup*) info->settings; if(m == SSM_420_JPEG_TR ) { - if(info->pixel_format == FMT_420) + if(info->pixel_format == FMT_420 || info->pixel_format == FMT_420F) settings->sample_mode = SSM_420_JPEG_TR; else settings->sample_mode = SSM_422_444; } else { - if(info->pixel_format == FMT_420) + if(info->pixel_format == FMT_420 || info->pixel_format == FMT_420F) settings->sample_mode = SSM_420_JPEG_BOX; else settings->sample_mode = SSM_422_444; @@ -1564,7 +1564,7 @@ static int veejay_mjpeg_sync_buf(veejay_t * info, struct mjpeg_sync *bs) ******************************************************/ -int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) +int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags, int full_range) { editlist *el = info->current_edit_list; video_playback_setup *settings = info->settings; @@ -1760,7 +1760,8 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) veejay_msg(VEEJAY_MSG_INFO, "Initialized %d Image- and Video Effects", vj_effect_max_effects()); - vj_effect_initialize(info->current_edit_list->video_width, info->current_edit_list->video_height); + vj_effect_initialize(info->current_edit_list->video_width, info->current_edit_list->video_height, + full_range); info->plugin_frame = vj_perform_init_plugin_frame(info); info->plugin_frame_info = vj_perform_init_plugin_frame_info(info); @@ -3127,10 +3128,10 @@ static int veejay_open_video_files(veejay_t *info, char **files, int num_files, if(force_pix_fmt >= 0) { - info->pixel_format = (force_pix_fmt == 1 ? FMT_422 : FMT_420); - veejay_msg(VEEJAY_MSG_WARNING, "Pixel format forced to YCbCr %s", - (info->pixel_format == FMT_422 ? "4:2:2" : "4:2:0")); - + info->pixel_format = force_pix_fmt; + veejay_msg(VEEJAY_MSG_INFO, "Processing video in pixel format %s %s", + (force_pix_fmt >1 ? "JPEG YUV" : "YCbCr" ), + ((info->pixel_format == FMT_422 || info->pixel_format == FMT_422F) ? "4:2:2" : "4:2:0")); } //TODO: pass yuv sampling to dummy if( info->dummy->active ) @@ -3152,7 +3153,7 @@ static int veejay_open_video_files(veejay_t *info, char **files, int num_files, info->current_edit_list = vj_el_dummy( 0, info->auto_deinterlace, info->dummy->chroma, info->dummy->norm, info->dummy->width, info->dummy->height, info->dummy->fps, - info->pixel_format ); + force_pix_fmt ); if( info->dummy->arate ) { @@ -3168,7 +3169,7 @@ static int veejay_open_video_files(veejay_t *info, char **files, int num_files, } else { - info->current_edit_list = vj_el_init_with_args(files, num_files, info->preserve_pathnames, info->auto_deinterlace, force, override_norm, info->pixel_format); + info->current_edit_list = vj_el_init_with_args(files, num_files, info->preserve_pathnames, info->auto_deinterlace, force, override_norm, force_pix_fmt); } info->edit_list = info->current_edit_list; @@ -3177,13 +3178,13 @@ static int veejay_open_video_files(veejay_t *info, char **files, int num_files, return 0; } - if(!vj_avcodec_init(info->current_edit_list , info->pixel_format)) + if(!vj_avcodec_init(info->current_edit_list , force_pix_fmt)) { veejay_msg(VEEJAY_MSG_ERROR, "Cannot initialize encoders!"); return 0; } - if(info->pixel_format == FMT_422 ) + if(info->pixel_format == FMT_422 || info->pixel_format == FMT_422F) { if(!vj_el_init_422_frame( info->current_edit_list, info->effect_frame1)) return 0; if(!vj_el_init_422_frame( info->current_edit_list, info->effect_frame2)) return 0; diff --git a/veejay-current/veejay/libveejay.h b/veejay-current/veejay/libveejay.h index 287707c3..01d52797 100644 --- a/veejay-current/veejay/libveejay.h +++ b/veejay-current/veejay/libveejay.h @@ -29,7 +29,7 @@ void veejay_signal_loop(void *); int veejay_init_editlist(veejay_t * info); -int veejay_init(veejay_t *info,int w, int h, char *arg, int td); +int veejay_init(veejay_t *info,int w, int h, char *arg, int td, int fr); int veejay_open(veejay_t *info); diff --git a/veejay-current/veejay/veejay.c b/veejay-current/veejay/veejay.c index ef755d98..819b6ca4 100644 --- a/veejay-current/veejay/veejay.c +++ b/veejay-current/veejay/veejay.c @@ -45,6 +45,7 @@ static int default_geometry_x = -1; static int default_geometry_y = -1; static int force_video_file = 0; // unused static int override_pix_fmt = 1; +static int full_range = 0; static char override_norm = 'p'; static int auto_loop = 0; static int n_slots_ = 8; @@ -185,7 +186,16 @@ static void Usage(char *progname) fprintf(stderr, " -j/--max_cache \t\tDivide cache memory over N samples (fairly distributed)\n"); fprintf(stderr, - " -Y/--ycbcr [01]\t\t0 = YUV 4:2:0 Planar, 1 = YUV 4:2:2 Planar\n"); + " -Y/--ycbcr [01]\t\tInternal processing format"); + fprintf(stderr, + "\t\t 0 = YUV 4:2:0 Planar\n"); + fprintf(stderr, + "\t\t 1 = YUV 4:2:2 Planar (default)\n"); + fprintf(stderr, + "\t\t 2 = YUV 4:2:0 Planar full range\n"); + fprintf(stderr, + "\t\t 3 = YUV 4:2:2 Planar full range\n"); + fprintf(stderr, " -d/--dummy \t\tDummy playback\n"); fprintf(stderr, @@ -390,6 +400,12 @@ static int set_option(const char *name, char *value) else if(strcmp(name,"ycbcr")==0 || strcmp(name,"Y")==0) { override_pix_fmt = atoi(optarg); + if(override_pix_fmt > 1 ) + { + full_range = 1; + } + if( override_pix_fmt < 0 || override_pix_fmt > 3 ) + override_pix_fmt = 1; } else if( strcmp(name,"auto-loop")==0 || strcmp(name,"L") == 0) { @@ -660,7 +676,7 @@ int main(int argc, char **argv) { veejay_set_colors(0); vj_event_init(); - vj_effect_initialize(720,576); + vj_effect_initialize(720,576,0); vj_osc_allocate(VJ_PORT+2); vj_event_dump(); vj_effect_dump(); @@ -717,7 +733,8 @@ int main(int argc, char **argv) default_geometry_x, default_geometry_y, NULL, - 0)<0) + 0, + full_range)<0) { veejay_msg(VEEJAY_MSG_ERROR, "Initializing veejay"); return 0; diff --git a/veejay-current/veejay/vj-event.c b/veejay-current/veejay/vj-event.c index 37b67f0d..8881de13 100644 --- a/veejay-current/veejay/vj-event.c +++ b/veejay-current/veejay/vj-event.c @@ -5957,7 +5957,7 @@ void vj_event_tag_set_format(void *ptr, const char format[], va_list ap) { _recorder_format = ENCODER_YUV420; veejay_msg(VEEJAY_MSG_INFO, "Recorder writes in uncompressed YV12/I420 (see swapping)"); - if(v->pixel_format == FMT_422) + if(v->pixel_format == FMT_422 || v->pixel_format == FMT_422F ) { veejay_msg(VEEJAY_MSG_WARNING, "Using 2x2 -> 1x1 and 1x1 -> 2x2 conversion"); } diff --git a/veejay-current/veejay/vj-global.h b/veejay-current/veejay/vj-global.h index 9a949203..796348f2 100644 --- a/veejay-current/veejay/vj-global.h +++ b/veejay-current/veejay/vj-global.h @@ -74,6 +74,7 @@ enum { #define FMT_420 0 #define FMT_422 1 - +#define FMT_420F 2 +#define FMT_422F 3 #endif #define MAX_EDIT_LIST_FILES 4096 diff --git a/veejay-current/veejay/vj-perform.c b/veejay-current/veejay/vj-perform.c index 2561205e..ecea313a 100644 --- a/veejay-current/veejay/vj-perform.c +++ b/veejay-current/veejay/vj-perform.c @@ -811,7 +811,7 @@ VJFrame *vj_perform_init_plugin_frame(veejay_t *info) editlist *el = info->edit_list; VJFrame *frame = (VJFrame*) vj_malloc(sizeof(VJFrame)); if(!frame) return 0; - if(info->pixel_format == FMT_422) + if(info->pixel_format == FMT_422 || info->pixel_format == FMT_422F) vj_el_init_422_frame( el, frame ); else vj_el_init_420_frame( el, frame ); @@ -1028,7 +1028,7 @@ void vj_perform_send_frame_now( veejay_t *info,int k ) void vj_perform_get_output_frame_420p( veejay_t *info, uint8_t **frame, int w, int h ) { - if(info->pixel_format == FMT_422) + if(info->pixel_format == FMT_422 || info->pixel_format == FMT_422F) { frame[0] = video_output_buffer[1]->Y; frame[1] = video_output_buffer[1]->Cb; @@ -1040,7 +1040,7 @@ void vj_perform_get_output_frame_420p( veejay_t *info, uint8_t **frame, int w, i src_frame[2] = video_output_buffer[0]->Cr; yuv422p_to_yuv420p2( - src_frame, frame,w, h ); + src_frame, frame,w, h, info->pixel_format ); } else { @@ -1073,7 +1073,7 @@ void vj_perform_unlock_primary_frame( void ) void vj_perform_get_primary_frame_420p(veejay_t *info, uint8_t **frame ) { editlist *el = info->edit_list; - if(info->pixel_format==FMT_422) + if(info->pixel_format==FMT_422 || info->pixel_format == FMT_422F) { if( video_output_buffer_convert == 0 ) { @@ -1081,7 +1081,7 @@ void vj_perform_get_primary_frame_420p(veejay_t *info, uint8_t **frame ) pframe[0] = primary_buffer[0]->Y; pframe[1] = primary_buffer[0]->Cb; pframe[2] = primary_buffer[0]->Cr; - yuv422p_to_yuv420p2( pframe,temp_buffer, el->video_width, el->video_height); + yuv422p_to_yuv420p2( pframe,temp_buffer, el->video_width, el->video_height, info->pixel_format); // ss_422_to_420( primary_buffer[0]->Cb, // el->video_width/2, // el->video_height ); @@ -2510,7 +2510,7 @@ int vj_perform_tag_fill_buffer(veejay_t * info, int entry) if (error == 1) { VJFrame dumb; - if( info->pixel_format == FMT_420 ) + if( info->pixel_format == FMT_422 || info->pixel_format == FMT_422F ) vj_el_init_422_frame( info->edit_list, &dumb ); else vj_el_init_420_frame( info->edit_list, &dumb ); diff --git a/veejay-current/veejay/vj-sdl.c b/veejay-current/veejay/vj-sdl.c index e83ea3b1..045bc155 100644 --- a/veejay-current/veejay/vj-sdl.c +++ b/veejay-current/veejay/vj-sdl.c @@ -266,7 +266,7 @@ int vj_sdl_update_yuv_overlay(vj_sdl * vjsdl, uint8_t ** yuv420) if (!yuv420[0] || !yuv420[1] || !yuv420[2]) return 0; - if(vjsdl->pix_fmt == FMT_420) + if(vjsdl->pix_fmt == FMT_420 || vjsdl->pix_fmt == FMT_420F) yuv420p_to_yuv422( yuv420, vjsdl->yuv_overlay->pixels[0],vjsdl->width,vjsdl->height); else yuv422_to_yuyv( yuv420, vjsdl->yuv_overlay->pixels[0], vjsdl->width,vjsdl->height);