X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Ffilter_chain.c;h=5397b067a7d600e8a6393d3a00e4f2a52fe1e161;hb=418410c4cf946f467bee5e88361b2a071aeffa9b;hp=7c204536293b57897118bb5b04bf027ce4520da3;hpb=f7b2327bfa30ea47cefc7bfa5b0edc15ae8c66fd;p=vlc diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c index 7c20453629..5397b067a7 100644 --- a/src/misc/filter_chain.c +++ b/src/misc/filter_chain.c @@ -21,8 +21,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include +#include struct filter_chain_t { @@ -49,7 +54,6 @@ static int filter_chain_DeleteFilterInternal( filter_chain_t *, filter_t * ); static int UpdateBufferFunctions( filter_chain_t * ); static picture_t *VideoBufferNew( filter_t * ); -static void VideoBufferRelease( picture_t * ); /** * Filter chain initialisation @@ -128,8 +132,10 @@ static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain, const es_format_t *p_fmt_in, const es_format_t *p_fmt_out ) { + static const char typename[] = "filter"; filter_t *p_filter = - vlc_object_create( p_chain->p_this, VLC_OBJECT_FILTER ); + vlc_custom_create( p_chain->p_this, sizeof(filter_t), + VLC_OBJECT_GENERIC, typename ); if( !p_filter ) return NULL; vlc_object_attach( p_filter, p_chain->p_this ); @@ -340,19 +346,31 @@ picture_t *filter_chain_VideoFilter( filter_chain_t *p_chain, picture_t *p_pic ) { filter_t *p_filter = pp_filter[i]; picture_t *p_newpic = p_filter->pf_video_filter( p_filter, p_pic ); - if( !p_newpic ) - return NULL; + /* FIXME Ugly hack to make it work in picture core. * FIXME Remove this code when the picture release API has been * FIXME cleaned up (a git revert of the commit should work) */ if( p_chain->p_this->i_object_type == VLC_OBJECT_VOUT ) { + vout_thread_t *p_vout = (vout_thread_t*)p_chain->p_this; + vlc_mutex_lock( &p_vout->picture_lock ); if( p_pic->i_refcount ) + { p_pic->i_status = DISPLAYED_PICTURE; + } else + { p_pic->i_status = DESTROYED_PICTURE; - p_newpic->i_status = READY_PICTURE; + p_vout->i_heap_size--; + } + vlc_mutex_unlock( &p_vout->picture_lock ); + + if( p_newpic ) + p_newpic->i_status = READY_PICTURE; } + if( !p_newpic ) + return NULL; + p_pic = p_newpic; } return p_pic; @@ -438,29 +456,13 @@ static int UpdateBufferFunctions( filter_chain_t *p_chain ) static picture_t *VideoBufferNew( filter_t *p_filter ) { - picture_t *p_pic = malloc( sizeof( picture_t ) ); - if( !p_pic ) return NULL; - memset( p_pic, 0, sizeof( picture_t * ) ); - int i_ret = vout_AllocatePicture( VLC_OBJECT( p_filter ), p_pic, - p_filter->fmt_out.video.i_chroma, - p_filter->fmt_out.video.i_width, - p_filter->fmt_out.video.i_height, - p_filter->fmt_out.video.i_aspect ); - if( i_ret != VLC_SUCCESS ) - { - msg_Err( p_filter, "Failed to allocate picture: %s", - vlc_error( i_ret ) ); - free( p_pic ); - return NULL; - } - p_pic->pf_release = VideoBufferRelease; - p_pic->i_type = MEMORY_PICTURE; - p_pic->i_status = RESERVED_PICTURE; - return p_pic; + const video_format_t *p_fmt = &p_filter->fmt_out.video; + + picture_t *p_picture = picture_New( p_fmt->i_chroma, + p_fmt->i_width, p_fmt->i_height, + p_fmt->i_aspect ); + if( !p_picture ) + msg_Err( p_filter, "Failed to allocate picture\n" ); + return p_picture; } -static void VideoBufferRelease( picture_t *p_pic ) -{ - free( p_pic->p_data_orig ); - free( p_pic ); -}