greyscale fixed

git-svn-id: svn://code.dyne.org/veejay/trunk@832 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
Niels Elburg
2007-03-10 20:59:59 +00:00
parent 68744b133a
commit f14b77ea95
3 changed files with 35 additions and 13 deletions

View File

@@ -35,7 +35,6 @@ typedef struct
vj_client *fd;
uint8_t *data_buffer;
uint8_t *tmp_buffer;
uint8_t *compr_buffer; //shared
uint8_t *status_buffer;
int track_list[16];
int track_items; //shared
@@ -49,6 +48,7 @@ typedef struct
int need_track_list;
unsigned char *queue[16];
int n_queued;
int bw;
} veejay_track_t;
typedef struct
@@ -109,7 +109,6 @@ static void gvr_close_connection( veejay_track_t *v )
vj_client_close(v->fd);
if(v->hostname) free(v->hostname);
if(v->status_buffer) free(v->status_buffer);
if(v->compr_buffer) free(v->compr_buffer);
if(v->data_buffer) free(v->data_buffer);
if(v->tmp_buffer) free(v->tmp_buffer);
@@ -339,13 +338,27 @@ static int veejay_get_image_data(veejay_preview_t *vp, veejay_track_t *v )
return bw;
}
//
// bw = lzo_decompress2( vp->lzo, v->compr_buffer, bw, v->data_buffer);
v->bw = 0;
if( bw == (v->width * v->height ))
{
//@ repeat plane in data_buffer
veejay_memcpy( v->data_buffer + bw, v->data_buffer, bw );
veejay_memcpy( v->data_buffer + bw + bw, v->data_buffer,bw );
uint8_t *in = v->data_buffer;
uint8_t *out = v->tmp_buffer;
unsigned int i,j;
unsigned int len = v->width * v->height;
unsigned int stride = v->width * 3;
unsigned int width = v->width;
unsigned int height = v->height;
for( j = 0; j < height ; j ++ )
{
for( i = 0; i < width; i ++ )
{
uint8_t *dst = out + j * stride + (i*3);
dst[0] = in[ j * width + i ];
dst[1] = in[ j * width + i ];
dst[2] = in[ j * width + i ];
}
}
v->bw = 1;
}
@@ -481,7 +494,6 @@ int gvr_track_connect( void *preview, const char *hostname, int port_num, int *
vt->status_buffer = (uint8_t*) vj_calloc(sizeof(uint8_t) * 256);
vt->compr_buffer = (uint8_t*) vj_calloc(sizeof(uint8_t) * 512 * 512 * 3 );
vt->data_buffer = (uint8_t*) vj_calloc(sizeof(uint8_t) * 512 * 512 * 3 );
vt->tmp_buffer = (uint8_t*) vj_calloc(sizeof(uint8_t) * 512 * 512 * 3 );
veejay_msg(2, "Track %d connected to Veejay %s : %d", track_num,hostname,port_num);
@@ -701,6 +713,10 @@ static GdkPixbuf **gvr_grab_images(void *preview)
{
veejay_track_t *v = vp->tracks[i];
if( v->bw )
list[i] =gdk_pixbuf_new_from_data(v->tmp_buffer,GDK_COLORSPACE_RGB,FALSE,
8,v->width,v->height,v->width*3,NULL,NULL );
else
list[i] = gdk_pixbuf_new_from_data( v->data_buffer, GDK_COLORSPACE_RGB, FALSE,
8, v->width, v->height, v->width * 3, NULL,NULL );
/*
@@ -938,7 +954,6 @@ static int gvr_veejay( veejay_preview_t *vp , veejay_track_t *v, int track_num
track_num );
if(v->hostname) free(v->hostname);
if(v->status_buffer) free(v->status_buffer);
if(v->compr_buffer) free(v->compr_buffer);
if(v->data_buffer) free(v->data_buffer);
if(v->tmp_buffer) free(v->tmp_buffer);
free(v);

View File

@@ -410,7 +410,7 @@ void vj_fastbw_picture_save_to_mem( VJFrame *frame, int out_w, int out_h, int f
planes[2] = planes[1] + (out_w * out_h );
VJFrame *dst1 = yuv_yuv_template( planes[0], planes[1], planes[2],
out_w , out_h, pixfmt );
out_w , out_h, PIX_FMT_GRAY8 );
if( frame->width == out_w && frame->height == out_h )
yuv_convert_any_ac( src1,dst1,src1->format, dst1->format );

View File

@@ -118,6 +118,12 @@ VJFrame *yuv_yuv_template( uint8_t *Y, uint8_t *U, uint8_t *V, int w, int h, int
f->stride[0] = w;
f->stride[1] = f->stride[2] = f->stride[0];
break;
case PIX_FMT_GRAY8:
f->uv_width = 0;
f->uv_height = 0;
f->stride[0] = w;
f->stride[1] = f->stride[2] = 0;
break;
default:
#ifdef STRICT_CHECKING
assert(0);
@@ -179,6 +185,7 @@ static struct
{ PIX_FMT_RGB32, IMG_ARGB32 },
{ PIX_FMT_RGBA, IMG_RGBA32 },
{ PIX_FMT_RGB32_1, IMG_RGBA32 },
{ PIX_FMT_GRAY8, IMG_GRAY8 },
{ -1, -1},
};
@@ -191,7 +198,7 @@ void yuv_convert_any_ac( VJFrame *src, VJFrame *dst, int src_fmt, int dst_fmt )
src_fmt == PIX_FMT_YUV444P || src_fmt == PIX_FMT_YUVJ444P ||
src_fmt == PIX_FMT_RGB24 || src_fmt == PIX_FMT_RGBA ||
src_fmt == PIX_FMT_BGR24 || src_fmt == PIX_FMT_RGB32 ||
src_fmt == PIX_FMT_RGB32_1 );
src_fmt == PIX_FMT_RGB32_1 || src_fmt == PIX_FMT_GRAY8 );
assert( src->width > 0 );
assert( dst->width > 0 );
#endif
@@ -211,7 +218,7 @@ void yuv_convert_any( VJFrame *src, VJFrame *dst, int src_fmt, int dst_fmt )
src_fmt == PIX_FMT_YUV444P || src_fmt == PIX_FMT_YUVJ444P ||
src_fmt == PIX_FMT_RGB24 || src_fmt == PIX_FMT_RGBA ||
src_fmt == PIX_FMT_BGR24 || src_fmt == PIX_FMT_RGB32 ||
src_fmt == PIX_FMT_RGB32_1 );
src_fmt == PIX_FMT_RGB32_1 || src_fmt == PIX_FMT_GRAY8 );
assert( src->width > 0 );
assert( dst->width > 0 );
#endif