[vlc-devel] [PATCH v3 17/24] fps: use a fonction to empty the chain of pictures

Steve Lhomme robux4 at ycbcr.xyz
Mon Sep 21 08:29:53 CEST 2020


We should probably release all pictures in the chain, not just the first one.
---
 modules/video_filter/fps.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/modules/video_filter/fps.c b/modules/video_filter/fps.c
index d2e524154d0..e6688c4f20b 100644
--- a/modules/video_filter/fps.c
+++ b/modules/video_filter/fps.c
@@ -67,6 +67,12 @@ typedef struct
     vlc_tick_t      i_output_frame_interval;
 } filter_sys_t;
 
+static void EmptyPictureChain(picture_t *chain)
+{
+    if( chain )
+        picture_Release( chain );
+}
+
 static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
 {
     filter_sys_t *p_sys = p_filter->p_sys;
@@ -91,8 +97,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
     {
         msg_Dbg( p_filter, "Resetting timestamps" );
         date_Set( &p_sys->next_output_pts, p_picture->date );
-        if( p_sys->p_previous_pic )
-            picture_Release( p_sys->p_previous_pic );
+        EmptyPictureChain( 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;
@@ -102,8 +107,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
     if( p_picture->date <
         ( date_Get( &p_sys->next_output_pts ) - p_sys->i_output_frame_interval ) )
     {
-        if( p_sys->p_previous_pic )
-            picture_Release( p_sys->p_previous_pic );
+        EmptyPictureChain( p_sys->p_previous_pic );
         p_sys->p_previous_pic = p_picture;
         return NULL;
     }
@@ -116,8 +120,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
         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 );
@@ -195,8 +198,7 @@ static void Close( vlc_object_t *p_this )
 {
     filter_t *p_filter = (filter_t*)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
-    if( p_sys->p_previous_pic )
-        picture_Release( p_sys->p_previous_pic );
+    EmptyPictureChain( p_sys->p_previous_pic );
     if( p_filter->vctx_out )
         vlc_video_context_Release( p_filter->vctx_out );
     free( p_sys );
-- 
2.26.2



More information about the vlc-devel mailing list