X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Ffilter_chain.c;h=5397b067a7d600e8a6393d3a00e4f2a52fe1e161;hb=75a1834d394b6a89a6ead139d57c097704d3943a;hp=ec73a8abaa2ad650d681947eb01c1d7b3de0b7f8;hpb=deef7f86ffe121398d3c86ab828e29a621dbad9d;p=vlc diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c index ec73a8abaa..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 ); @@ -170,13 +176,16 @@ static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain, vlc_array_append( &p_chain->filters, p_filter ); msg_Dbg( p_chain->p_this, "Filter '%s' (%p) appended to chain", - psz_name, p_filter ); + psz_name?:p_filter->psz_object_name, p_filter ); return p_filter; error: - msg_Err( p_chain->p_this, "Failed to create video filter '%s'", - psz_name ); + if( psz_name ) + msg_Err( p_chain->p_this, "Failed to create video filter '%s'", + psz_name ); + else + msg_Err( p_chain->p_this, "Failed to create video filter" ); if( p_filter->p_module ) module_Unneed( p_filter, p_filter->p_module ); es_format_Clean( &p_filter->fmt_in ); @@ -337,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; @@ -435,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 ); -}