[vlc-devel] [PATCH v1 11/33] video_output: keep the output of the static filters in a FIFO

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 25 16:46:47 CEST 2020


Use filter_chain_VideoFilterInto instead of filter_chain_VideoFilter, allowing
static filters to push multiple pictures.

Loop until we get a picture out of the static filters and there are pictures
coming from the decoder.

We use a picture_fifo_t because it can be flushed based on a date.
---
 src/video_output/video_output.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index de9329bfcb9..a7c28fadbc1 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -182,6 +182,7 @@ typedef struct vout_thread_sys_t
     } filter;
 
     picture_fifo_t  *decoder_fifo;
+    picture_fifo_t  *static_fifo;     /**< decoder_fifo passed through static filters */
     vout_chrono_t   render;           /**< picture render time estimator */
 
     vlc_atomic_rc_t rc;
@@ -361,10 +362,10 @@ bool vout_IsEmpty(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
     assert(!sys->dummy);
-    if (!sys->decoder_fifo)
+    if (!sys->decoder_fifo || !sys->static_fifo)
         return true;
 
-    return picture_fifo_IsEmpty(sys->decoder_fifo);
+    return picture_fifo_IsEmpty(sys->decoder_fifo) && picture_fifo_IsEmpty(sys->static_fifo);
 }
 
 void vout_DisplayTitle(vout_thread_t *vout, const char *title)
@@ -1061,6 +1062,12 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
     sys->filter.changed = false;
 }
 
+static int SinkToStaticFifo(struct vlc_video_sink *sink, picture_t *pic)
+{
+    vout_thread_sys_t *sys = sink->sys;
+    picture_fifo_Push(sys->static_fifo, pic);
+    return VLC_SUCCESS;
+}
 
 /* */
 static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse,
@@ -1071,7 +1078,7 @@ static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse,
 
     vlc_mutex_lock(&sys->filter.lock);
 
-    picture_t *picture = filter_chain_VideoFilter(sys->filter.chain_static, NULL);
+    picture_t *picture = picture_fifo_Pop(sys->static_fifo);
     assert(!reuse || !picture);
 
     while (!picture) {
@@ -1142,7 +1149,9 @@ static int ThreadDisplayPreparePicture(vout_thread_sys_t *vout, bool reuse,
         sys->displayed.timestamp     = decoded->date;
         sys->displayed.is_interlaced = !decoded->b_progressive;
 
-        picture = filter_chain_VideoFilter(sys->filter.chain_static, decoded);
+        struct vlc_video_sink sink_to_static_fifo = { sys, SinkToStaticFifo };
+        filter_chain_VideoFilterInto(sys->filter.chain_static, decoded, &sink_to_static_fifo);
+        picture = picture_fifo_Pop(sys->static_fifo);
     }
 
     vlc_mutex_unlock(&sys->filter.lock);
@@ -1607,6 +1616,7 @@ static void vout_FlushUnlocked(vout_thread_sys_t *vout, bool below,
     }
 
     picture_fifo_Flush(sys->decoder_fifo, date, below);
+    picture_fifo_Flush(sys->static_fifo,  date, below);
 
     vlc_mutex_lock(&sys->display_lock);
     if (sys->display != NULL)
@@ -1737,6 +1747,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     vlc_mouse_Init(&sys->mouse);
 
     sys->decoder_fifo = picture_fifo_New();
+    sys->static_fifo = picture_fifo_New();
     sys->private.display_pool = NULL;
     sys->private.private_pool = NULL;
 
@@ -1859,6 +1870,11 @@ error:
         picture_fifo_Delete(sys->decoder_fifo);
         sys->decoder_fifo = NULL;
     }
+    if (sys->static_fifo != NULL)
+    {
+        picture_fifo_Delete(sys->static_fifo);
+        sys->static_fifo = NULL;
+    }
     return VLC_EGENERIC;
 }
 
@@ -1941,6 +1957,11 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout)
         picture_fifo_Delete(sys->decoder_fifo);
         sys->decoder_fifo = NULL;
     }
+    if (sys->static_fifo != NULL)
+    {
+        picture_fifo_Delete(sys->static_fifo);
+        sys->static_fifo = NULL;
+    }
     assert(sys->private.display_pool == NULL);
 
     if (sys->mouse_event)
-- 
2.26.2



More information about the vlc-devel mailing list