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

Steve Lhomme robux4 at ycbcr.xyz
Fri Nov 6 15:32:32 CET 2020


The first deinterlaced 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 e6fe8d23b4e..761be2d6180 100644
--- a/src/video_output/interlacing.c
+++ b/src/video_output/interlacing.c
@@ -179,7 +179,7 @@ void vout_SetInterlacingState(vout_thread_t *vout, vout_thread_private_t *sys, b
         msg_Dbg(vout, "Detected %s video",
                  is_interlaced ? "interlaced" : "progressive");
         sys->interlacing.is_interlaced = is_interlaced;
-        ChangeInterlacing(vout, false);
+        ChangeInterlacing(vout, true);
     }
     if (is_interlaced)
         sys->interlacing.date = vlc_tick_now();
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 0a71457d4f9..20e569e173c 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -121,7 +121,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;
@@ -1091,6 +1090,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->sys.obj, &sys->sys.private, !decoded->b_progressive);
+
+                if (sys->filter.changed ||
+                    sys->sys.private.interlacing.has_deint != sys->filter.new_interlaced)
+                {
+                    sys->sys.private.interlacing.has_deint = sys->filter.new_interlaced;
                     ThreadChangeFilters(vout);
                 }
 
@@ -1139,7 +1147,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);
     }
@@ -1464,15 +1471,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->sys.private.interlacing.has_deint != sys->filter.new_interlaced)
-    {
-        sys->sys.private.interlacing.has_deint = sys->filter.new_interlaced;
-        ThreadChangeFilters(vout);
-    }
-    vlc_mutex_unlock(&sys->filter.lock);
-
     if (deadline)
         *deadline = VLC_TICK_INVALID;
 
@@ -1841,7 +1839,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;
@@ -1913,10 +1910,6 @@ static void *Thread(void *object)
         }
 
         wait = ThreadDisplayPicture(vout, &deadline) != VLC_SUCCESS;
-
-        const bool picture_interlaced = sys->displayed.is_interlaced;
-
-        vout_SetInterlacingState(&vout->sys.obj, &sys->sys.private, picture_interlaced);
     }
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list