Commit 1fa88f66 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

filter_t: use struct of non-anymous unions, seems more portable

parent a8421c57
......@@ -62,48 +62,64 @@ struct filter_t
union
{
picture_t * (*pf_video_filter) ( filter_t *, picture_t * );
block_t * (*pf_audio_filter) ( filter_t *, block_t * );
void (*pf_video_blend) ( filter_t *,
picture_t *, const picture_t *,
int, int, int );
subpicture_t * (*pf_sub_filter) ( filter_t *, mtime_t );
int (*pf_render_text) ( filter_t *, subpicture_region_t *,
subpicture_region_t * );
};
union
{
/* Filter mouse state.
*
* If non-NULL, you must convert from output format to input format:
* - If VLC_SUCCESS is returned, the mouse state is then propagated.
* - Otherwise, the mouse change is not propagated.
* If NULL, the mouse state is considered unchanged and will be
* propagated.
*/
int (*pf_mouse)( filter_t *, vlc_mouse_t *,
struct
{
picture_t * (*pf_filter) ( filter_t *, picture_t * );
picture_t * (*pf_buffer_new) ( filter_t * );
void (*pf_buffer_del) ( filter_t *, picture_t * );
/* Filter mouse state.
*
* If non-NULL, you must convert from output to input formats:
* - If VLC_SUCCESS is returned, the mouse state is propagated.
* - Otherwise, the mouse change is not propagated.
* If NULL, the mouse state is considered unchanged and will be
* propagated.
*/
int (*pf_mouse)( filter_t *, vlc_mouse_t *,
const vlc_mouse_t *p_old,
const vlc_mouse_t *p_new );
int (*pf_render_html) ( filter_t *, subpicture_region_t *,
subpicture_region_t * );
};
/*
* Buffers allocation
*/
union
{
block_t * (*pf_audio_buffer_new) ( filter_t *, int );
picture_t * (*pf_vout_buffer_new) ( filter_t * );
subpicture_t * (*pf_sub_buffer_new) ( filter_t * );
};
union
{
void (*pf_vout_buffer_del) ( filter_t *, picture_t * );
void (*pf_sub_buffer_del) ( filter_t *, subpicture_t * );
};
} video;
#define pf_video_filter u.video.pf_filter
#define pf_video_mouse u.video.pf_mouse
#define pf_video_buffer_new u.video.pf_buffer_new
#define pf_video_buffer_del u.video.pf_buffer_del
struct
{
block_t * (*pf_filter) ( filter_t *, block_t * );
block_t * (*pf_buffer_new) ( filter_t *, int );
} audio;
#define pf_audio_filter u.audio.pf_filter
#define pf_audio_buffer_new u.audio.pf_buffer_new
struct
{
void (*pf_blend) ( filter_t *, picture_t *,
const picture_t *, int, int, int );
} blend;
#define pf_video_blend u.blend.pf_blend
struct
{
subpicture_t * (*pf_filter) ( filter_t *, mtime_t );
subpicture_t * (*pf_buffer_new) ( filter_t * );
void (*pf_buffer_del) ( filter_t *, subpicture_t * );
} sub;
#define pf_sub_filter u.sub.pf_filter
#define pf_sub_buffer_new u.sub.pf_buffer_new
#define pf_sub_buffer_del u.sub.pf_buffer_del
struct
{
int (*pf_text) ( filter_t *, subpicture_region_t *,
subpicture_region_t * );
int (*pf_html) ( filter_t *, subpicture_region_t *,
subpicture_region_t * );
} render;
#define pf_render_text u.render.pf_text
#define pf_render_html u.render.pf_html
} u;
/* Private structure for the owner of the decoder */
filter_owner_sys_t *p_owner;
};
......@@ -119,7 +135,7 @@ struct filter_t
*/
static inline picture_t *filter_NewPicture( filter_t *p_filter )
{
picture_t *p_picture = p_filter->pf_vout_buffer_new( p_filter );
picture_t *p_picture = p_filter->pf_video_buffer_new( p_filter );
if( !p_picture )
msg_Warn( p_filter, "can't get output picture" );
return p_picture;
......@@ -134,7 +150,7 @@ static inline picture_t *filter_NewPicture( filter_t *p_filter )
*/
static inline void filter_DeletePicture( filter_t *p_filter, picture_t *p_picture )
{
p_filter->pf_vout_buffer_del( p_filter, p_picture );
p_filter->pf_video_buffer_del( p_filter, p_picture );
}
/**
......
......@@ -284,8 +284,8 @@ static void Close( vlc_object_t * p_this )
static int video_filter_buffer_allocation_init( filter_t *p_filter, void *p_data )
{
p_filter->pf_vout_buffer_new = video_new_buffer_filter;
p_filter->pf_vout_buffer_del = video_del_buffer_filter;
p_filter->pf_video_buffer_new = video_new_buffer_filter;
p_filter->pf_video_buffer_del = video_del_buffer_filter;
p_filter->p_owner = p_data;
return VLC_SUCCESS;
}
......
......@@ -114,8 +114,8 @@ static int transcode_video_filter_allocation_init( filter_t *p_filter,
void *p_data )
{
VLC_UNUSED(p_data);
p_filter->pf_vout_buffer_new = transcode_video_filter_buffer_new;
p_filter->pf_vout_buffer_del = transcode_video_filter_buffer_del;
p_filter->pf_video_buffer_new = transcode_video_filter_buffer_new;
p_filter->pf_video_buffer_del = transcode_video_filter_buffer_del;
return VLC_SUCCESS;
}
......
......@@ -374,7 +374,7 @@ static void video_del( filter_t *p_filter, picture_t *p_pic )
static int alloc_init( filter_t *p_filter, void *p_data )
{
p_filter->p_owner = p_data;
p_filter->pf_vout_buffer_new = video_new;
p_filter->pf_vout_buffer_del = video_del;
p_filter->pf_video_buffer_new = video_new;
p_filter->pf_video_buffer_del = video_del;
return VLC_SUCCESS;
}
......@@ -255,8 +255,8 @@ static void BufferDel( filter_t *p_filter, picture_t *p_pic )
}
static int BufferAllocationInit ( filter_t *p_filter, void *p_data )
{
p_filter->pf_vout_buffer_new = BufferNew;
p_filter->pf_vout_buffer_del = BufferDel;
p_filter->pf_video_buffer_new = BufferNew;
p_filter->pf_video_buffer_del = BufferDel;
p_filter->p_owner = p_data;
return VLC_SUCCESS;
}
......
......@@ -299,7 +299,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
else
{
p_filter->pf_video_filter = FilterVideo;
p_filter->pf_mouse = Mouse;
p_filter->pf_video_mouse = Mouse;
}
free( psz_filename );
......
......@@ -129,7 +129,7 @@ static int Create( vlc_object_t *p_this )
/* */
p_filter->pf_video_filter = Filter;
p_filter->pf_mouse = Mouse;
p_filter->pf_video_mouse = Mouse;
return VLC_SUCCESS;
}
......
......@@ -164,7 +164,7 @@ static int Open( vlc_object_t *p_this )
var_AddCallback( p_filter, CFG_PREFIX "black-slot", PuzzleCallback, p_sys );
p_filter->pf_video_filter = Filter;
p_filter->pf_mouse = Mouse;
p_filter->pf_video_mouse = Mouse;
return VLC_SUCCESS;
}
......
......@@ -526,16 +526,16 @@ static int FilterAllocationInit( filter_t *p_filter, void *p_data )
{
VLC_UNUSED( p_data );
p_filter->pf_vout_buffer_new = VideoBufferNew;
p_filter->pf_vout_buffer_del = VideoBufferDelete;
p_filter->pf_video_buffer_new = VideoBufferNew;
p_filter->pf_video_buffer_del = VideoBufferDelete;
p_filter->p_owner = p_data;
return VLC_SUCCESS;
}
static void FilterAllocationClean( filter_t *p_filter )
{
p_filter->pf_vout_buffer_new = NULL;
p_filter->pf_vout_buffer_del = NULL;
p_filter->pf_video_buffer_new = NULL;
p_filter->pf_video_buffer_del = NULL;
}
/* -- Splitter callbacks -- */
......
......@@ -267,13 +267,13 @@ int filter_chain_MouseFilter( filter_chain_t *p_chain, vlc_mouse_t *p_dst, const
filter_t *p_filter = &f->filter;
vlc_mouse_t *p_mouse = f->mouse;
if( p_filter->pf_mouse && p_mouse )
if( p_filter->pf_video_mouse && p_mouse )
{
vlc_mouse_t old = *p_mouse;
vlc_mouse_t filtered;
*p_mouse = current;
if( p_filter->pf_mouse( p_filter, &filtered, &old, &current ) )
if( p_filter->pf_video_mouse( p_filter, &filtered, &old, &current ) )
return VLC_EGENERIC;
current = filtered;
}
......@@ -518,20 +518,20 @@ static int InternalVideoInit( filter_t *p_filter, void *p_data )
{
VLC_UNUSED(p_data);
p_filter->pf_vout_buffer_new = VideoBufferNew;
p_filter->pf_vout_buffer_del = VideoBufferDelete;
p_filter->pf_video_buffer_new = VideoBufferNew;
p_filter->pf_video_buffer_del = VideoBufferDelete;
return VLC_SUCCESS;
}
static void InternalVideoClean( filter_t *p_filter )
{
p_filter->pf_vout_buffer_new = NULL;
p_filter->pf_vout_buffer_del = NULL;
p_filter->pf_video_buffer_new = NULL;
p_filter->pf_video_buffer_del = NULL;
}
static bool IsInternalVideoAllocator( chained_filter_t *p_filter )
{
return p_filter->filter.pf_vout_buffer_new == VideoBufferNew;
return p_filter->filter.pf_video_buffer_new == VideoBufferNew;
}
/* */
......
......@@ -341,7 +341,7 @@ static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic,
p_block = p_image->p_enc->pf_encode_video( p_image->p_enc, p_tmp_pic );
p_image->p_filter->pf_vout_buffer_del( p_image->p_filter, p_tmp_pic );
p_image->p_filter->pf_video_buffer_del( p_image->p_filter, p_tmp_pic );
}
else
{
......@@ -473,7 +473,7 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
{
/* Duplicate image */
picture_Release( p_pif ); /* XXX: Better fix must be possible */
p_pif = p_image->p_filter->pf_vout_buffer_new( p_image->p_filter );
p_pif = p_image->p_filter->pf_video_buffer_new( p_image->p_filter );
if( p_pif )
picture_Copy( p_pif, p_pic );
}
......@@ -787,9 +787,9 @@ static filter_t *CreateFilter( vlc_object_t *p_this, es_format_t *p_fmt_in,
VLC_OBJECT_GENERIC, typename );
vlc_object_attach( p_filter, p_this );
p_filter->pf_vout_buffer_new =
p_filter->pf_video_buffer_new =
(picture_t *(*)(filter_t *))video_new_buffer;
p_filter->pf_vout_buffer_del =
p_filter->pf_video_buffer_del =
(void (*)(filter_t *, picture_t *))video_del_buffer;
p_filter->fmt_in = *p_fmt_in;
......
......@@ -71,17 +71,17 @@ static void VideoBufferDelete(filter_t *filter, picture_t *picture)
static int FilterAllocationInit(filter_t *filter, void *vd)
{
filter->pf_vout_buffer_new = VideoBufferNew;
filter->pf_vout_buffer_del = VideoBufferDelete;
filter->p_owner = vd;
filter->pf_video_buffer_new = VideoBufferNew;
filter->pf_video_buffer_del = VideoBufferDelete;
filter->p_owner = vd;
return VLC_SUCCESS;
}
static void FilterAllocationClean(filter_t *filter)
{
filter->pf_vout_buffer_new = NULL;
filter->pf_vout_buffer_del = NULL;
filter->p_owner = NULL;
filter->pf_video_buffer_new = NULL;
filter->pf_video_buffer_del = NULL;
filter->p_owner = NULL;
}
/*****************************************************************************
......
......@@ -139,8 +139,8 @@ static void video_del_buffer_filter( filter_t *p_filter, picture_t *p_pic )
static int video_filter_buffer_allocation_init( filter_t *p_filter, void *p_data )
{
p_filter->pf_vout_buffer_new = video_new_buffer_filter;
p_filter->pf_vout_buffer_del = video_del_buffer_filter;
p_filter->pf_video_buffer_new = video_new_buffer_filter;
p_filter->pf_video_buffer_del = video_del_buffer_filter;
p_filter->p_owner = p_data; /* p_vout */
return VLC_SUCCESS;
}
......@@ -1493,7 +1493,7 @@ static int ChromaCreate( vout_thread_t *p_vout )
return VLC_EGENERIC;
}
p_chroma->pf_vout_buffer_new = ChromaGetPicture;
p_chroma->pf_video_buffer_new = ChromaGetPicture;
return VLC_SUCCESS;
}
......
......@@ -1026,8 +1026,8 @@ static filter_t *CreateAndLoadScale( vlc_object_t *p_obj,
p_scale->fmt_out.video.i_width =
p_scale->fmt_out.video.i_height = b_resize ? 16 : 32;
p_scale->pf_vout_buffer_new = spu_new_video_buffer;
p_scale->pf_vout_buffer_del = spu_del_video_buffer;
p_scale->pf_video_buffer_new = spu_new_video_buffer;
p_scale->pf_video_buffer_del = spu_del_video_buffer;
vlc_object_attach( p_scale, p_obj );
p_scale->p_module = module_need( p_scale, "video filter2", NULL, false );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment