[vlc-devel] [PATCH v2 6/6] video_output: change the deinterlacing filter before displaying the picture

Steve Lhomme robux4 at ycbcr.xyz
Mon Nov 9 10:32:35 CET 2020


The first interlaced picture should not be displayed without passing through
the deinterlacer. It's even more crucial when the source picture only contains
one field, at half the real height.

Now filters are only updated before filtering a decoded picture, rather than
before a picture is displayed. It is still done outside of the frame timing
checks.
---
 src/video_output/interlacing.c  |  2 +-
 src/video_output/video_output.c | 25 +++++++++----------------
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/src/video_output/interlacing.c b/src/video_output/interlacing.c
index 76ffe26d32c..1da8c02eec7 100644
--- a/src/video_output/interlacing.c
+++ b/src/video_output/interlacing.c
@@ -186,7 +186,7 @@ void vout_SetInterlacingState(vout_thread_t *vout, bool is_interlaced)
         msg_Dbg(vout, "Detected %s video",
                  is_interlaced ? "interlaced" : "progressive");
         sys->is_interlaced = is_interlaced;
-        ChangeInterlacing(vout, false);
+        ChangeInterlacing(vout, true);
     }
     if (is_interlaced)
         sys->date = vlc_tick_now();
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 8238ef3d0a9..a1b5476c1e7 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -123,7 +123,6 @@ typedef struct vout_thread_sys_t
     struct {
         vlc_tick_t  date;
         vlc_tick_t  timestamp;
-        bool        is_interlaced;
         picture_t   *decoded; // decoded picture before passed through chain_static
         picture_t   *current;
         picture_t   *next;
@@ -1093,6 +1092,15 @@ static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reus
                         vlc_video_context_Release(sys->filter.src_vctx);
                     sys->filter.src_vctx = pic_vctx ? vlc_video_context_Hold(pic_vctx) : NULL;
 
+                    sys->filter.changed = true;
+                }
+
+                vout_SetInterlacingState(&vout->obj.obj, !decoded->b_progressive);
+
+                if (sys->filter.changed ||
+                    sys->obj.interlacing.has_deint != sys->filter.new_interlaced)
+                {
+                    sys->obj.interlacing.has_deint = sys->filter.new_interlaced;
                     ThreadChangeFilters(vout);
                 }
 
@@ -1141,7 +1149,6 @@ static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reus
 
         sys->displayed.decoded       = picture_Hold(decoded);
         sys->displayed.timestamp     = decoded->date;
-        sys->displayed.is_interlaced = !decoded->b_progressive;
 
         picture = filter_chain_VideoFilter(sys->filter.chain_static, sys->displayed.decoded);
     }
@@ -1466,15 +1473,6 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
 
     assert(sys->clock);
 
-    vlc_mutex_lock(&sys->filter.lock);
-    if (sys->filter.changed ||
-        sys->obj.interlacing.has_deint != sys->filter.new_interlaced)
-    {
-        sys->obj.interlacing.has_deint = sys->filter.new_interlaced;
-        ThreadChangeFilters(vout);
-    }
-    vlc_mutex_unlock(&sys->filter.lock);
-
     if (deadline)
         *deadline = VLC_TICK_INVALID;
 
@@ -1843,7 +1841,6 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     sys->displayed.decoded       = NULL;
     sys->displayed.date          = VLC_TICK_INVALID;
     sys->displayed.timestamp     = VLC_TICK_INVALID;
-    sys->displayed.is_interlaced = false;
 
     sys->step.last               = VLC_TICK_INVALID;
     sys->step.timestamp          = VLC_TICK_INVALID;
@@ -1915,10 +1912,6 @@ static void *Thread(void *object)
         }
 
         wait = ThreadDisplayPicture(vout, &deadline) != VLC_SUCCESS;
-
-        const bool picture_interlaced = sys->displayed.is_interlaced;
-
-        vout_SetInterlacingState(&vout->obj.obj, picture_interlaced);
     }
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list