[vlc-devel] [PATCH 12/15] video_filter:deinterlace: add function to initialize the deinterlacing context

Steve Lhomme robux4 at videolabs.io
Fri Jun 30 14:20:05 CEST 2017


---
 modules/video_filter/deinterlace/common.c      | 18 ++++++++++++++++++
 modules/video_filter/deinterlace/common.h      |  2 ++
 modules/video_filter/deinterlace/deinterlace.c | 11 +----------
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/modules/video_filter/deinterlace/common.c b/modules/video_filter/deinterlace/common.c
index a1b68dc869..cfd3a38983 100644
--- a/modules/video_filter/deinterlace/common.c
+++ b/modules/video_filter/deinterlace/common.c
@@ -33,6 +33,24 @@
 
 #include "common.h"
 
+void InitDeinterlacingContext( struct deinterlace_ctx *p_context )
+{
+    p_context->b_double_rate = false;
+    p_context->b_half_height = false;
+    p_context->b_use_frame_history = false;
+
+    p_context->meta[0].pi_date = VLC_TS_INVALID;
+    p_context->meta[0].pi_nb_fields = 2;
+    p_context->meta[0].pb_top_field_first = true;
+    for( int i = 1; i < METADATA_SIZE; i++ )
+        p_context->meta[i] = p_context->meta[i-1];
+
+    p_context->i_frame_offset = 0; /* start with default value (first-ever frame
+                                  cannot have offset) */
+    for( int i = 0; i < HISTORY_SIZE; i++ )
+        p_context->pp_history[i] = NULL;
+}
+
 void FlushDeinterlacing(struct deinterlace_ctx *p_context)
 {
     p_context->meta[0].pi_date = VLC_TS_INVALID;
diff --git a/modules/video_filter/deinterlace/common.h b/modules/video_filter/deinterlace/common.h
index a8e3de430a..ad74b5353d 100644
--- a/modules/video_filter/deinterlace/common.h
+++ b/modules/video_filter/deinterlace/common.h
@@ -89,6 +89,8 @@ struct deinterlace_ctx
 
 #define DEINTERLACE_DST_SIZE 3
 
+void InitDeinterlacingContext( struct deinterlace_ctx * );
+
 /**
  * @brief Get the field duration based on the previous fields or the frame rate
  * @param fmt output format of the deinterlacer with the frame rate
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index 98d65ca7bf..db7ca39886 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -329,16 +329,7 @@ notsupp:
     char *psz_mode = var_InheritString( p_filter, FILTER_CFG_PREFIX "mode" );
     SetFilterMethod( p_filter, psz_mode, packed );
 
-    for( int i = 0; i < METADATA_SIZE; i++ )
-    {
-        p_sys->context.meta[i].pi_date = VLC_TS_INVALID;
-        p_sys->context.meta[i].pi_nb_fields = 2;
-        p_sys->context.meta[i].pb_top_field_first = true;
-    }
-    p_sys->context.i_frame_offset = 0; /* start with default value (first-ever frame
-                                  cannot have offset) */
-    for( int i = 0; i < HISTORY_SIZE; i++ )
-        p_sys->context.pp_history[i] = NULL;
+    InitDeinterlacingContext( &p_sys->context );
 
     IVTCClearState( p_filter );
 
-- 
2.12.1



More information about the vlc-devel mailing list