[vlc-devel] [PATCH v1 09/33] fps: add a filter callback using the video sink
Steve Lhomme
robux4 at ycbcr.xyz
Fri Sep 25 16:46:45 CEST 2020
The old callback simulates a sink that chains the pictures with
vlc_picture_chain_Append and returns the front of the chain.
---
modules/video_filter/fps.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/modules/video_filter/fps.c b/modules/video_filter/fps.c
index 49b0d3b61c7..5681ba1dbca 100644
--- a/modules/video_filter/fps.c
+++ b/modules/video_filter/fps.c
@@ -67,7 +67,7 @@ typedef struct
vlc_tick_t i_output_frame_interval;
} filter_sys_t;
-static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
+static int FilterPush( filter_t *p_filter, picture_t *p_picture, struct vlc_video_sink *sink )
{
filter_sys_t *p_sys = p_filter->p_sys;
/* If input picture doesn't have actual valid timestamp,
@@ -77,7 +77,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
{
msg_Dbg( p_filter, "skipping non-dated picture");
picture_Release( p_picture );
- return NULL;
+ return VLC_EBADVAR;
}
p_picture->format.i_frame_rate = p_filter->fmt_out.video.i_frame_rate;
@@ -95,7 +95,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
picture_Release( p_sys->p_previous_pic );
p_sys->p_previous_pic = picture_Hold( p_picture );
date_Increment( &p_sys->next_output_pts, 1 );
- return p_picture;
+ return vlc_video_sink_PutPicture( sink, p_picture );
}
/* Check if we can skip input as better should follow */
@@ -105,30 +105,44 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
if( p_sys->p_previous_pic )
picture_Release( p_sys->p_previous_pic );
p_sys->p_previous_pic = p_picture;
- return NULL;
+ return VLC_SUCCESS;
}
p_sys->p_previous_pic->date = date_Get( &p_sys->next_output_pts );
date_Increment( &p_sys->next_output_pts, 1 );
- vlc_picture_chain_t chain;
- vlc_picture_chain_Init( &chain );
- vlc_picture_chain_Append( &chain, p_sys->p_previous_pic );
+ vlc_video_sink_PutPicture( sink, p_sys->p_previous_pic );
/* Duplicating pictures are not that effective and framerate increase
should be avoided, it's only here as filter should work in that direction too*/
while( unlikely( (date_Get( &p_sys->next_output_pts ) + p_sys->i_output_frame_interval ) < p_picture->date ) )
{
- picture_t *p_tmp = NULL;
- p_tmp = picture_NewFromFormat( &p_filter->fmt_out.video );
+ picture_t *p_tmp = picture_NewFromFormat( &p_filter->fmt_out.video );
picture_Copy( p_tmp, p_sys->p_previous_pic);
p_tmp->date = date_Get( &p_sys->next_output_pts );
- vlc_picture_chain_Append( &chain, p_tmp );
+ vlc_video_sink_PutPicture( sink, p_tmp );
date_Increment( &p_sys->next_output_pts, 1 );
}
p_sys->p_previous_pic = p_picture;
+ return VLC_SUCCESS;
+}
+
+static int SinkIntoPictureChain(struct vlc_video_sink *sink, picture_t *p_picture)
+{
+ vlc_picture_chain_t *p_chain = sink->sys;
+ vlc_picture_chain_Append( p_chain, p_picture );
+ return VLC_SUCCESS;
+}
+
+static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
+{
+ vlc_picture_chain_t chain;
+ vlc_picture_chain_Init( &chain );
+
+ struct vlc_video_sink sink = { &chain, SinkIntoPictureChain };
+ int res = FilterPush( p_filter, p_picture, &sink );
return chain.front;
}
@@ -182,6 +196,7 @@ static int Open( vlc_object_t *p_this)
p_sys->p_previous_pic = NULL;
p_filter->pf_video_filter = Filter;
+ p_filter->pf_video_filter_into = FilterPush;
/* We don't change neither the format nor the picture */
if ( p_filter->vctx_in )
--
2.26.2
More information about the vlc-devel
mailing list