[vlc-commits] video_output: use filter lock to change filters in the vout thread

Steve Lhomme git at videolan.org
Tue Sep 15 12:24:42 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Aug 17 10:14:41 2020 +0200| [211b02b8b9718d2dd6dc6de18cd16103bd2abf29] | committer: Steve Lhomme

video_output: use filter lock to change filters in the vout thread

We don't need to wait when enabling filters, it's OK if we miss the current
frame and apply it in the next loop iteration. The filter changes will
be applied just before the picture is rendered, only once between frames. It is
now done after the control pop deadline, so will eat some of the rendering
time.

We don't use the control lock anymore (from vout_control_PushString), just the
filters lock.

Now the filter changes are applied even in frame by frame mode.

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

 src/video_output/video_output.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index ed1e3bfcb0..343f01dd21 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -172,6 +172,8 @@ typedef struct vout_thread_sys_t
     /* Video filter2 chain */
     struct {
         vlc_mutex_t     lock;
+        bool            changed;
+        char            *new_filters;
         char            *configuration;
         video_format_t    src_fmt;
         vlc_video_context *src_vctx;
@@ -771,8 +773,22 @@ void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters)
 {
     vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
     assert(!sys->dummy);
-    vout_control_PushString(&sys->control, VOUT_CONTROL_CHANGE_FILTERS,
-                            filters);
+    vlc_mutex_lock(&sys->filter.lock);
+    if (sys->filter.new_filters)
+    {
+        if (filters == NULL || strcmp(sys->filter.new_filters, filters))
+        {
+            free(sys->filter.new_filters);
+            sys->filter.new_filters = filters ? strdup(filters) : NULL;
+            sys->filter.changed = true;
+        }
+    }
+    else if (filters != NULL)
+    {
+        sys->filter.new_filters = strdup(filters);
+        sys->filter.changed = true;
+    }
+    vlc_mutex_unlock(&sys->filter.lock);
 }
 
 void vout_ControlChangeInterlacing(vout_thread_t *vout, bool set)
@@ -1059,6 +1075,8 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout,
         sys->filter.configuration = filters ? strdup(filters) : NULL;
     }
 
+    sys->filter.changed = false;
+
     if (!is_locked)
         vlc_mutex_unlock(&sys->filter.lock);
 }
@@ -1474,6 +1492,13 @@ 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)
+    {
+        ThreadChangeFilters(vout, sys->filter.new_filters, NULL, true);
+    }
+    vlc_mutex_unlock(&sys->filter.lock);
+
     if (first)
         if (ThreadDisplayPreparePicture(vout, true, frame_by_frame, &paused)) /* FIXME not sure it is ok */
             return VLC_EGENERIC;



More information about the vlc-commits mailing list