[vlc-devel] [PATCH 15/15] video_filter:deinterlace: move the IVTC PTS handling in the common code

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


Use a flag in the algorithm settings for IVTC to tell it needs special PTS
handling on output.
---
 modules/video_filter/deinterlace/algo_ivtc.c   |  7 -------
 modules/video_filter/deinterlace/algo_ivtc.h   |  2 --
 modules/video_filter/deinterlace/common.c      | 22 ++++++++++++++++++++++
 modules/video_filter/deinterlace/common.h      |  2 +-
 modules/video_filter/deinterlace/deinterlace.c | 20 ++++++++++----------
 5 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/modules/video_filter/deinterlace/algo_ivtc.c b/modules/video_filter/deinterlace/algo_ivtc.c
index 0de608ccba..145f981334 100644
--- a/modules/video_filter/deinterlace/algo_ivtc.c
+++ b/modules/video_filter/deinterlace/algo_ivtc.c
@@ -1521,9 +1521,6 @@ int RenderIVTC( filter_t *p_filter, picture_t *p_dst, picture_t *p_pic )
         /* Now we can... */
         bool b_have_output_frame = IVTCOutputOrDropFrame( p_filter, p_dst );
 
-        /* The next frame will get a custom timestamp, too. */
-        p_sys->context.i_frame_offset = CUSTOM_PTS;
-
         if( b_have_output_frame )
             return VLC_SUCCESS;
         else
@@ -1569,10 +1566,6 @@ int RenderIVTC( filter_t *p_filter, picture_t *p_dst, picture_t *p_pic )
         */
         p_ivtc->pi_final_scores[1] = p_ivtc->pi_scores[FIELD_PAIR_TNBN];
 
-        /* At the next frame, the filter starts. The next frame will get
-           a custom timestamp. */
-        p_sys->context.i_frame_offset = CUSTOM_PTS;
-
         picture_Copy( p_dst, p_next );
         return VLC_SUCCESS;
     }
diff --git a/modules/video_filter/deinterlace/algo_ivtc.h b/modules/video_filter/deinterlace/algo_ivtc.h
index 2a090132e9..c12dc60abf 100644
--- a/modules/video_filter/deinterlace/algo_ivtc.h
+++ b/modules/video_filter/deinterlace/algo_ivtc.h
@@ -127,8 +127,6 @@ typedef struct
  * There is no input frame parameter, because the input frames
  * are taken from the history buffer.
  *
- * This algorithm does CUSTOM_PTS timestamp mangling.
- *
  * See the file comment for a detailed description of the algorithm.
  *
  * @param p_filter The filter instance. Must be non-NULL.
diff --git a/modules/video_filter/deinterlace/common.c b/modules/video_filter/deinterlace/common.c
index 3d144f5fc1..ea9c6af464 100644
--- a/modules/video_filter/deinterlace/common.c
+++ b/modules/video_filter/deinterlace/common.c
@@ -38,6 +38,7 @@ void InitDeinterlacingContext( struct deinterlace_ctx *p_context )
     p_context->settings.b_double_rate = false;
     p_context->settings.b_half_height = false;
     p_context->settings.b_use_frame_history = false;
+    p_context->settings.b_custom_pts = false;
 
     p_context->meta[0].pi_date = VLC_TS_INVALID;
     p_context->meta[0].pi_nb_fields = 2;
@@ -122,6 +123,8 @@ void GetDeinterlacingOutput( const struct deinterlace_ctx *p_context,
     }
 }
 
+#define CUSTOM_PTS -1
+
 picture_t *DoDeinterlacing( filter_t *p_filter,
                             struct deinterlace_ctx *p_context, picture_t *p_pic )
 {
@@ -280,6 +283,25 @@ picture_t *DoDeinterlacing( filter_t *p_filter,
                                           2, !b_top_field_first );
     }
 
+    if ( p_context->settings.b_custom_pts )
+    {
+        assert(p_context->settings.b_use_frame_history);
+        if( p_context->pp_history[0] && p_context->pp_history[1] )
+        {
+            /* The next frame will get a custom timestamp, too. */
+            p_context->i_frame_offset = CUSTOM_PTS;
+        }
+        else if( !p_context->pp_history[0] && !p_context->pp_history[1] ) /* first frame */
+        {
+        }
+        else /* second frame */
+        {
+            /* At the next frame, the filter starts. The next frame will get
+               a custom timestamp. */
+            p_context->i_frame_offset = CUSTOM_PTS;
+        }
+    }
+
     /* Set output timestamps, if the algorithm didn't request CUSTOM_PTS
        for this frame. */
     assert( i_frame_offset <= METADATA_SIZE ||
diff --git a/modules/video_filter/deinterlace/common.h b/modules/video_filter/deinterlace/common.h
index 0c5fa91e75..940a87e2a9 100644
--- a/modules/video_filter/deinterlace/common.h
+++ b/modules/video_filter/deinterlace/common.h
@@ -54,11 +54,11 @@ typedef struct {
 
 #define METADATA_SIZE (3)
 #define HISTORY_SIZE (3)
-#define CUSTOM_PTS -1
 
 typedef struct  {
     bool b_double_rate;       /**< Shall we double the framerate? */
     bool b_use_frame_history; /**< Use the input frame history buffer? */
+    bool b_custom_pts;        /**< for inverse telecine */
     bool b_half_height;       /**< Shall be divide the height by 2 */
 } deinterlace_algo;
 
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index d1d83740b1..4697be91f1 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -151,25 +151,25 @@ static struct filter_mode_t filter_mode [] = {
     { "discard", .pf_render_single_pic = RenderDiscard,
                  { false, false, false, true }, true, true },
     { "bob", .pf_render_ordered = RenderBob,
-                 { true, false, false }, true, true },
+                 { true, false, false, false }, true, true },
     { "progressive-scan", .pf_render_ordered = RenderBob,
-                 { true, false, false }, true, true },
+                 { true, false, false, false }, true, true },
     { "linear", .pf_render_ordered = RenderLinear,
-                 { true, false, false }, true, true },
+                 { true, false, false, false }, true, true },
     { "mean", .pf_render_single_pic = RenderMean,
-                 { false, false, true }, true, true },
+                 { false, false, false, true }, true, true },
     { "blend", .pf_render_single_pic = RenderBlend,
-                 { false, false, false }, true, true },
+                 { false, false, false, false }, true, true },
     { "yadif", .pf_render_single_pic = RenderYadifSingle,
-                 { false, true, false }, false, true },
+                 { false, true, false, false }, false, true },
     { "yadif2x", .pf_render_ordered = RenderYadif,
-                 { true, true, false }, false, true },
+                 { true, true, false, false }, false, true },
     { "x", .pf_render_single_pic = RenderX,
-                 { false, false, false }, false, false },
+                 { false, false, false, false }, false, false },
     { "phosphor", .pf_render_ordered = RenderPhosphor,
-                 { true, true, false }, false, false },
+                 { true, true, false, false }, false, false },
     { "ivtc", .pf_render_single_pic = RenderIVTC,
-                 { false, true, false }, false, false },
+                 { false, true, true, false }, false, false },
 };
 
 /**
-- 
2.12.1



More information about the vlc-devel mailing list