fix color space conversion error between yuv ,yuvj and rgb in fx

git-svn-id: svn://code.dyne.org/veejay/trunk@863 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
Niels Elburg
2007-03-16 15:26:46 +00:00
parent 6df3684f99
commit e8e2110f6e
4 changed files with 79 additions and 9 deletions

View File

@@ -56,6 +56,8 @@ vj_effect *colorhis_init(int w, int h)
static void *histogram_ = NULL;
static VJFrame *rgb_frame_ = NULL;
static uint8_t *rgb_ = NULL;
static void *convert_yuv = NULL;
static void *convert_rgb = NULL;
int colorhis_malloc(int w, int h)
{
@@ -66,6 +68,8 @@ int colorhis_malloc(int w, int h)
histogram_ = veejay_histogram_new();
rgb_ = vj_malloc(sizeof(uint8_t) * w * h * 3 );
rgb_frame_ = yuv_rgb_template( rgb_, w, h, PIX_FMT_RGB24 );
return 1;
}
@@ -80,13 +84,28 @@ void colorhis_free()
rgb_ = NULL;
rgb_frame_ = NULL;
histogram_ = NULL;
if( convert_yuv )
yuv_fx_context_destroy( convert_yuv );
if( convert_rgb )
yuv_fx_context_destroy( convert_rgb );
convert_rgb = NULL;
convert_yuv = NULL;
}
void colorhis_apply( VJFrame *frame, int width, int height,int mode, int val, int intensity, int strength)
{
int src_fmt = (frame->uv_height == height ? PIX_FMT_YUV422P : PIX_FMT_YUV420P);
yuv_convert_any_ac( frame, rgb_frame_, src_fmt, PIX_FMT_RGB24 );
if(!convert_yuv)
convert_yuv = yuv_fx_context_create( frame, rgb_frame_, src_fmt, PIX_FMT_RGB24 );
yuv_fx_context_process( convert_yuv, frame, rgb_frame_ );
//yuv_convert_any_ac( frame, rgb_frame_, src_fmt, PIX_FMT_RGB24 );
if( val == 0 )
{
@@ -96,9 +115,12 @@ void colorhis_apply( VJFrame *frame, int width, int height,int mode, int val, in
{
veejay_histogram_analyze_rgb( histogram_,rgb_, frame );
veejay_histogram_equalize_rgb( histogram_, frame, rgb_, intensity, strength, mode );
if(!convert_rgb )
convert_rgb = yuv_fx_context_create( rgb_frame_, frame, PIX_FMT_RGB24, src_fmt );
yuv_fx_context_process( convert_rgb, rgb_frame_, frame );
yuv_convert_any_ac( rgb_frame_, frame, PIX_FMT_RGB24, src_fmt );
// yuv_convert_any_ac( rgb_frame_, frame, PIX_FMT_RGB24, src_fmt );
}
}

View File

@@ -28,6 +28,7 @@ static VJFrame *rgb_frame_ = NULL;
static PluginInfo *goom_ = NULL;
static uint8_t *goom_buffer_ = NULL;
static int last_= 0;
static void *convert_rgb = NULL;
vj_effect *goomfx_init(int w, int h)
{
@@ -70,10 +71,15 @@ void goomfx_free()
goom_buffer_ = NULL;
goom_ = NULL;
rgb_frame_ = NULL;
if( convert_rgb )
yuv_fx_context_destroy( convert_rgb );
convert_rgb = NULL;
}
void goomfx_apply( VJFrame *frame, int width, int height, int val, int val2)
{
unsigned int i;
@@ -104,7 +110,14 @@ void goomfx_apply( VJFrame *frame, int width, int height, int val, int val2)
NULL,
NULL );
yuv_convert_any_ac( rgb_frame_, frame, PIX_FMT_RGBA, (frame->shift_v == 0 ? PIX_FMT_YUV422P :
if( !convert_rgb )
convert_rgb = yuv_fx_context_create( rgb_frame_, frame, PIX_FMT_RGBA,
(frame->shift_v == 0 ? PIX_FMT_YUV422P :
PIX_FMT_YUV420P) );
//yuv_convert_any_ac( rgb_frame_, frame, PIX_FMT_RGBA, (frame->shift_v == 0 ? PIX_FMT_YUV422P :
// PIX_FMT_YUV420P) );
yuv_fx_context_process( convert_rgb, rgb_frame_, frame );
}

View File

@@ -53,6 +53,8 @@ vj_effect *rgbchannel_init(int w, int h)
static uint8_t *rgb_ = NULL;
static VJFrame *rgb_frame_ = NULL;
static void *convert_yuv = NULL;
static void *convert_rgb = NULL;
int rgbchannel_malloc( int w, int h )
{
if(!rgb_)
@@ -72,6 +74,13 @@ void rgbchannel_free( )
free(rgb_frame_);
rgb_frame_ = NULL;
rgb_ = NULL;
if(convert_rgb)
yuv_fx_context_destroy( convert_rgb );
if(convert_yuv)
yuv_fx_context_destroy( convert_yuv );
convert_rgb = NULL;
convert_yuv = NULL;
}
void rgbchannel_apply( VJFrame *frame, int width, int height, int chr, int chg , int chb)
@@ -83,7 +92,14 @@ void rgbchannel_apply( VJFrame *frame, int width, int height, int chr, int chg ,
frame->data[2],
width, height, PIX_FMT_YUV444P );
yuv_convert_any_ac( tmp, rgb_frame_, PIX_FMT_YUV444P, PIX_FMT_RGB24 );
// yuv_convert_any_ac( tmp, rgb_frame_, PIX_FMT_YUV444P, PIX_FMT_RGB24 );
if(!convert_yuv )
convert_yuv = yuv_fx_context_create( tmp, rgb_frame_, PIX_FMT_YUV444P, PIX_FMT_RGB24 );
if(!convert_rgb )
convert_rgb = yuv_fx_context_create( rgb_frame_,tmp, PIX_FMT_RGB24, PIX_FMT_YUV444P );
yuv_fx_context_process( convert_yuv, tmp, rgb_frame_ );
int row_stride = width * 3;
@@ -118,7 +134,9 @@ void rgbchannel_apply( VJFrame *frame, int width, int height, int chr, int chg ,
}
}
yuv_convert_any_ac( rgb_frame_, tmp, PIX_FMT_RGB24, PIX_FMT_YUV444P );
// yuv_convert_any_ac( rgb_frame_, tmp, PIX_FMT_RGB24, PIX_FMT_YUV444P );
yuv_fx_context_process( convert_rgb, rgb_frame_, tmp );
free(tmp);

View File

@@ -92,6 +92,8 @@ typedef void (*f0r_set_param_value_f)(f0r_instance_t *instance, f0r_param_t *par
#define FF_CAP_V_BITS_VIDEO FF_CAP_16BITVIDEO
#endif
static void *convert_yuv = NULL;
static void *convert_rgb = NULL;
static vevo_port_t **index_map_ = NULL;
static vevo_port_t *illegal_plugins_ =NULL;
static int index_ = 0;
@@ -761,6 +763,12 @@ static void process_plug_plugin( void *plugin, void *buffer , void *out_buffer)
void plug_free(void)
{
free_plugins();
if( convert_rgb )
yuv_fx_context_destroy( convert_rgb );
if( convert_yuv )
yuv_fx_context_destroy( convert_yuv );
if( buffer_ )
free( buffer_ );
if( buffer2_ )
@@ -976,11 +984,20 @@ void plug_process( VJFrame *frame,VJFrame *b, int fx_id, int src_fmt )
VJFrame *dst1 = yuv_rgb_template( buffer_, frame->width,frame->height,
PIX_FMT_RGB24 );
yuv_convert_any_ac( frame, dst1, src_fmt, dst1->format );
if(!convert_yuv)
convert_yuv = yuv_fx_context_create( frame,dst1,src_fmt,dst1->format );
if(!convert_rgb )
convert_rgb = yuv_fx_context_create( dst1, frame, dst1->format, src_fmt );
// yuv_convert_any_ac( frame, dst1, src_fmt, dst1->format );
yuv_fx_context_process( convert_yuv, frame,dst1 );
process_plug_plugin( plugin, buffer_, buffer2_ );
yuv_convert_any_ac( dst1, frame, dst1->format, src_fmt );
yuv_fx_context_process( convert_rgb, dst1, frame );
// yuv_convert_any_ac( dst1, frame, dst1->format, src_fmt );
free(dst1);