From 4b00ff6ec805784d3b136591f0a4cf460ac36af9 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 19 Jul 2008 15:41:59 +0200 Subject: [PATCH] Use filter helpers. --- modules/codec/avcodec/deinterlace.c | 8 ++++++-- modules/video_filter/adjust.c | 3 +-- modules/video_filter/colorthres.c | 3 +-- modules/video_filter/croppadd.c | 3 +-- modules/video_filter/deinterlace.c | 7 ++----- modules/video_filter/erase.c | 3 +-- modules/video_filter/extract.c | 3 +-- modules/video_filter/gaussianblur.c | 3 +-- modules/video_filter/gradient.c | 3 +-- modules/video_filter/grain.c | 3 +-- modules/video_filter/invert.c | 2 +- modules/video_filter/logo.c | 2 +- modules/video_filter/marq.c | 2 +- modules/video_filter/mosaic.c | 4 +--- modules/video_filter/motionblur.c | 3 +-- modules/video_filter/motiondetect.c | 29 +++++++++++------------------ modules/video_filter/noise.c | 2 +- modules/video_filter/osdmenu.c | 5 +++-- modules/video_filter/postproc.c | 3 +-- modules/video_filter/psychedelic.c | 3 +-- modules/video_filter/remoteosd.c | 2 +- modules/video_filter/ripple.c | 3 +-- modules/video_filter/rotate.c | 6 ++---- modules/video_filter/rss.c | 2 +- modules/video_filter/rv32.c | 3 +-- modules/video_filter/scale.c | 3 +-- modules/video_filter/sharpen.c | 3 +-- modules/video_filter/swscale.c | 10 +++++++--- modules/video_filter/wave.c | 3 +-- 29 files changed, 54 insertions(+), 75 deletions(-) diff --git a/modules/codec/avcodec/deinterlace.c b/modules/codec/avcodec/deinterlace.c index f44289ab28..b297bbdd0e 100644 --- a/modules/codec/avcodec/deinterlace.c +++ b/modules/codec/avcodec/deinterlace.c @@ -122,9 +122,12 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) int i, i_res = -1; /* Request output picture */ - p_pic_dst = p_filter->pf_vout_buffer_new( p_filter ); + p_pic_dst = filter_NewPicture( p_filter ); if( !p_pic_dst ) + { + picture_Release( p_pic ); return NULL; + } /* Prepare the AVPictures for the conversion */ for( i = 0; i < p_pic->i_planes; i++ ) @@ -144,7 +147,8 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) if( i_res == -1 ) { msg_Err( p_filter, "deinterlacing picture failed" ); - p_filter->pf_vout_buffer_del( p_filter, p_pic_dst ); + filter_DeletePicture( p_filter, p_pic_dst ); + picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/adjust.c b/modules/video_filter/adjust.c index b3781926de..a4bf4ef945 100644 --- a/modules/video_filter/adjust.c +++ b/modules/video_filter/adjust.c @@ -215,10 +215,9 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/colorthres.c b/modules/video_filter/colorthres.c index 2a393181a9..a4e40a2c24 100644 --- a/modules/video_filter/colorthres.c +++ b/modules/video_filter/colorthres.c @@ -162,10 +162,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/croppadd.c b/modules/video_filter/croppadd.c index 3f17320787..3f9f64883d 100644 --- a/modules/video_filter/croppadd.c +++ b/modules/video_filter/croppadd.c @@ -215,10 +215,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; /* Request output picture */ - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/deinterlace.c b/modules/video_filter/deinterlace.c index 9328491d16..4ec8333340 100644 --- a/modules/video_filter/deinterlace.c +++ b/modules/video_filter/deinterlace.c @@ -2106,12 +2106,9 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) picture_t *p_pic_dst; /* Request output picture */ - p_pic_dst = p_filter->pf_vout_buffer_new( p_filter ); + p_pic_dst = filter_NewPicture( p_filter ); if( p_pic_dst == NULL ) - { - msg_Warn( p_filter, "can't get output picture" ); - return NULL; - } + return p_pic; switch( p_vout->p_sys->i_mode ) { diff --git a/modules/video_filter/erase.c b/modules/video_filter/erase.c index cde3a8a362..33f507bf2e 100644 --- a/modules/video_filter/erase.c +++ b/modules/video_filter/erase.c @@ -202,10 +202,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/extract.c b/modules/video_filter/extract.c index 7c78400c87..23716f0183 100644 --- a/modules/video_filter/extract.c +++ b/modules/video_filter/extract.c @@ -172,10 +172,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/gaussianblur.c b/modules/video_filter/gaussianblur.c index 373857afb7..f0df010907 100644 --- a/modules/video_filter/gaussianblur.c +++ b/modules/video_filter/gaussianblur.c @@ -193,10 +193,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/gradient.c b/modules/video_filter/gradient.c index ac10a35132..f1c57cdeef 100644 --- a/modules/video_filter/gradient.c +++ b/modules/video_filter/gradient.c @@ -233,10 +233,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/grain.c b/modules/video_filter/grain.c index 8826628e24..e28b210c88 100644 --- a/modules/video_filter/grain.c +++ b/modules/video_filter/grain.c @@ -106,10 +106,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/invert.c b/modules/video_filter/invert.c index df1a168b12..1700c1d7eb 100644 --- a/modules/video_filter/invert.c +++ b/modules/video_filter/invert.c @@ -113,7 +113,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { msg_Warn( p_filter, "can't get output picture" ); diff --git a/modules/video_filter/logo.c b/modules/video_filter/logo.c index 541fc196a1..f274dc2f67 100644 --- a/modules/video_filter/logo.c +++ b/modules/video_filter/logo.c @@ -819,7 +819,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) p_pic = p_logo->p_pic; /* Allocate the subpicture internal data. */ - p_spu = p_filter->pf_sub_buffer_new( p_filter ); + p_spu = filter_NewSubpicture( p_filter ); if( !p_spu ) { vlc_mutex_unlock( &p_logo_list->lock ); diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c index 091cc8761e..a170b67fd5 100644 --- a/modules/video_filter/marq.c +++ b/modules/video_filter/marq.c @@ -276,7 +276,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) if( p_sys->b_need_update == false ) goto out; - p_spu = p_filter->pf_sub_buffer_new( p_filter ); + p_spu = filter_NewSubpicture( p_filter ); if( !p_spu ) goto out; diff --git a/modules/video_filter/mosaic.c b/modules/video_filter/mosaic.c index b62da83cdc..379b25ed12 100644 --- a/modules/video_filter/mosaic.c +++ b/modules/video_filter/mosaic.c @@ -448,11 +448,9 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) subpicture_region_t *p_region_prev = NULL; /* Allocate the subpicture internal data. */ - p_spu = p_filter->pf_sub_buffer_new( p_filter ); + p_spu = filter_NewSubpicture( p_filter ); if( !p_spu ) - { return NULL; - } /* Initialize subpicture */ p_spu->i_channel = 0; diff --git a/modules/video_filter/motionblur.c b/modules/video_filter/motionblur.c index 42043ab8ee..4b9bafeb71 100644 --- a/modules/video_filter/motionblur.c +++ b/modules/video_filter/motionblur.c @@ -137,10 +137,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/motiondetect.c b/modules/video_filter/motiondetect.c index 4b80c7a609..d4783e20e4 100644 --- a/modules/video_filter/motiondetect.c +++ b/modules/video_filter/motiondetect.c @@ -151,7 +151,6 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_inpic ) uint8_t *p_oldpix; uint8_t *p_oldpix_u; uint8_t *p_oldpix_v; - uint8_t *p_outpix; uint32_t *p_buf; uint32_t *p_buf2; @@ -180,22 +179,14 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_inpic ) p_buf = p_sys->p_buf; p_buf2 = p_sys->p_buf2; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_inpic ); return NULL; } - p_outpix = p_outpic->p[Y_PLANE].p_pixels; - vlc_memcpy( p_outpic->p[Y_PLANE].p_pixels, p_inpic->p[Y_PLANE].p_pixels, - p_inpic->p[Y_PLANE].i_pitch * p_inpic->p[Y_PLANE].i_visible_lines ); - vlc_memcpy( p_outpic->p[U_PLANE].p_pixels, p_inpic->p[U_PLANE].p_pixels, - p_inpic->p[U_PLANE].i_pitch * p_inpic->p[U_PLANE].i_visible_lines ); - vlc_memcpy( p_outpic->p[V_PLANE].p_pixels, p_inpic->p[V_PLANE].p_pixels, - p_inpic->p[V_PLANE].i_pitch * p_inpic->p[V_PLANE].i_visible_lines ); - + vout_CopyPicture( p_filter, p_outpic, p_inpic ); vlc_mutex_lock( &p_filter->p_sys->lock ); /** @@ -293,33 +284,36 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_inpic ) * Count final number of shapes * Draw rectangles (there can be more than 1 moving shape in 1 rectangle) */ + uint8_t *p_outpix = p_outpic->p[Y_PLANE].p_pixels; + const int i_dst_pitch = p_outpic->p[Y_PLANE].i_pitch; j = 0; for( i = 1; i < last; i++ ) { if( colors[i] == i && color_x_min[i] != -1 ) { - if( ( color_y_max[i] - color_y_min[i] ) * ( color_x_max[i] - color_x_min[i] ) < 16 ) continue; + if( ( color_y_max[i] - color_y_min[i] ) * ( color_x_max[i] - color_x_min[i] ) < 16 ) + continue; j++; int x, y; y = color_y_min[i]; for( x = color_x_min[i]; x <= color_x_max[i]; x++ ) { - p_outpix[y*i_src_pitch+x] = 0xff; + p_outpix[y*i_dst_pitch+x] = 0xff; } y = color_y_max[i]; for( x = color_x_min[i]; x <= color_x_max[i]; x++ ) { - p_outpix[y*i_src_pitch+x] = 0xff; + p_outpix[y*i_dst_pitch+x] = 0xff; } x = color_x_min[i]; for( y = color_y_min[i]; y <= color_y_max[i]; y++ ) { - p_outpix[y*i_src_pitch+x] = 0xff; + p_outpix[y*i_dst_pitch+x] = 0xff; } x = color_x_max[i]; for( y = color_y_min[i]; y <= color_y_max[i]; y++ ) { - p_outpix[y*i_src_pitch+x] = 0xff; + p_outpix[y*i_dst_pitch+x] = 0xff; } } } @@ -395,10 +389,9 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_inpic ) return p_inpic; } - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_inpic ); return NULL; } diff --git a/modules/video_filter/noise.c b/modules/video_filter/noise.c index 1c461bc049..e61391e3e4 100644 --- a/modules/video_filter/noise.c +++ b/modules/video_filter/noise.c @@ -119,7 +119,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { msg_Warn( p_filter, "can't get output picture" ); diff --git a/modules/video_filter/osdmenu.c b/modules/video_filter/osdmenu.c index 28818f3ff2..58b593963e 100644 --- a/modules/video_filter/osdmenu.c +++ b/modules/video_filter/osdmenu.c @@ -462,8 +462,9 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t i_date ) return NULL; /* we are too early, so wait */ /* Allocate the subpicture internal data. */ - p_spu = p_filter->pf_sub_buffer_new( p_filter ); - if( !p_spu ) return NULL; + p_spu = filter_NewSubpicture( p_filter ); + if( !p_spu ) + return NULL; p_spu->b_ephemer = true; p_spu->b_fade = true; diff --git a/modules/video_filter/postproc.c b/modules/video_filter/postproc.c index 83b309988f..e05d773bea 100644 --- a/modules/video_filter/postproc.c +++ b/modules/video_filter/postproc.c @@ -274,10 +274,9 @@ static picture_t *PostprocPict( filter_t *p_filter, picture_t *p_pic ) return p_pic; } - picture_t *p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + picture_t *p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); vlc_mutex_unlock( &p_sys->lock ); return NULL; diff --git a/modules/video_filter/psychedelic.c b/modules/video_filter/psychedelic.c index 7a9540acb1..88a2e3515f 100644 --- a/modules/video_filter/psychedelic.c +++ b/modules/video_filter/psychedelic.c @@ -142,10 +142,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c index b7fbc78ccd..34c86dc122 100644 --- a/modules/video_filter/remoteosd.c +++ b/modules/video_filter/remoteosd.c @@ -1134,7 +1134,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) } /* Allocate the subpicture internal data. */ - p_spu = p_filter->pf_sub_buffer_new( p_filter ); + p_spu = filter_NewSubpicture( p_filter ); if( !p_spu ) { vlc_mutex_unlock( &p_sys->lock ); diff --git a/modules/video_filter/ripple.c b/modules/video_filter/ripple.c index eb9d2f5491..6d9776fe18 100644 --- a/modules/video_filter/ripple.c +++ b/modules/video_filter/ripple.c @@ -121,10 +121,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/rotate.c b/modules/video_filter/rotate.c index 2fdf4408ec..55b7c9fbb8 100644 --- a/modules/video_filter/rotate.c +++ b/modules/video_filter/rotate.c @@ -172,10 +172,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } @@ -304,10 +303,9 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic ) return NULL; } - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index 6f4615adbd..0465a2cb30 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -429,7 +429,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) } } - p_spu = p_filter->pf_sub_buffer_new( p_filter ); + p_spu = filter_NewSubpicture( p_filter ); if( !p_spu ) { vlc_mutex_unlock( &p_sys->lock ); diff --git a/modules/video_filter/rv32.c b/modules/video_filter/rv32.c index 89c1aa2ef4..10c5699508 100644 --- a/modules/video_filter/rv32.c +++ b/modules/video_filter/rv32.c @@ -105,10 +105,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) unsigned int j; /* Request output picture */ - p_pic_dst = p_filter->pf_vout_buffer_new( p_filter ); + p_pic_dst = filter_NewPicture( p_filter ); if( !p_pic_dst ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/scale.c b/modules/video_filter/scale.c index 01033b8d00..7aa4e98e2e 100644 --- a/modules/video_filter/scale.c +++ b/modules/video_filter/scale.c @@ -124,10 +124,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) return NULL; /* Request output picture */ - p_pic_dst = p_filter->pf_vout_buffer_new( p_filter ); + p_pic_dst = filter_NewPicture( p_filter ); if( !p_pic_dst ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/sharpen.c b/modules/video_filter/sharpen.c index e975466927..c95e69b835 100644 --- a/modules/video_filter/sharpen.c +++ b/modules/video_filter/sharpen.c @@ -172,10 +172,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_filter ) return NULL; if( !p_filter->p_sys ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/swscale.c b/modules/video_filter/swscale.c index 5e0e8d0928..ba7a98192b 100644 --- a/modules/video_filter/swscale.c +++ b/modules/video_filter/swscale.c @@ -283,13 +283,17 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) int i_nb_planes = p_pic->i_planes; /* Check if format properties changed */ - if( CheckInit( p_filter ) != VLC_SUCCESS ) return NULL; + if( CheckInit( p_filter ) != VLC_SUCCESS ) + { + picture_Release( p_pic ); + return NULL; + } /* Request output picture */ - p_pic_dst = p_filter->pf_vout_buffer_new( p_filter ); + p_pic_dst = filter_NewPicture( p_filter ); if( !p_pic_dst ) { - msg_Warn( p_filter, "can't get output picture" ); + picture_Release( p_pic ); return NULL; } diff --git a/modules/video_filter/wave.c b/modules/video_filter/wave.c index 0a154a0240..03fb7c2587 100644 --- a/modules/video_filter/wave.c +++ b/modules/video_filter/wave.c @@ -122,10 +122,9 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) if( !p_pic ) return NULL; - p_outpic = p_filter->pf_vout_buffer_new( p_filter ); + p_outpic = filter_NewPicture( p_filter ); if( !p_outpic ) { - msg_Warn( p_filter, "can't get output picture" ); picture_Release( p_pic ); return NULL; } -- 2.39.2