[vlc-commits] video_output: change the deinterlacing filter before displaying the picture

Steve Lhomme git at videolan.org
Fri Nov 13 16:52:56 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Nov  6 14:34:35 2020 +0100| [270d501bf3a5fbba694a43186825a7666c8fd11b] | committer: Steve Lhomme

video_output: change the deinterlacing filter before displaying the picture

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.

filter.new_interlaced tells whether a deinterlacer is needed or not and is
updated when calling vout_SetInterlacingState() via vout_ControlChangeInterlacing()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=270d501bf3a5fbba694a43186825a7666c8fd11b
---

 src/video_output/interlacing.c  |  2 +-
 src/video_output/video_output.c | 26 ++++++++++----------------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/src/video_output/interlacing.c b/src/video_output/interlacing.c
index 8bd3170a5f..e6e422abf8 100644
--- a/src/video_output/interlacing.c
+++ b/src/video_output/interlacing.c
@@ -187,7 +187,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 203a2266a7..cf5ebc308a 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;
@@ -1089,6 +1088,14 @@ static picture_t *ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reus
                 if (!VideoFormatIsCropArEqual(&decoded->format, &sys->filter.src_fmt))
                 {
                     // we received an aspect ratio change
+                    sys->filter.changed = true;
+                }
+
+                bool had_deint = sys->filter.new_interlaced;
+                vout_SetInterlacingState(&vout->obj.obj, !decoded->b_progressive);
+
+                if (sys->filter.changed || had_deint != sys->filter.new_interlaced)
+                {
                     // Update the filters with the filter source format with the new aspect ratio
                     video_format_Clean(&sys->filter.src_fmt);
                     video_format_Copy(&sys->filter.src_fmt, &decoded->format);
@@ -1096,6 +1103,8 @@ 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->obj.interlacing.has_deint = sys->filter.new_interlaced;
+
                     ThreadChangeFilters(vout, can_flush);
                 }
 
@@ -1144,7 +1153,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);
     }
@@ -1469,15 +1477,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, true);
-    }
-    vlc_mutex_unlock(&sys->filter.lock);
-
     if (deadline)
         *deadline = VLC_TICK_INVALID;
 
@@ -1847,7 +1846,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;
@@ -1921,10 +1919,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);
     }
 }
 



More information about the vlc-commits mailing list