[vlc-devel] [PATCH] vout: include static filter chain in render delay calculation

Thomas Guillem thomas at gllm.fr
Mon Jan 13 17:27:01 CET 2020


The static filter chain delay (used by deinterlace and postproc) was not taken
into account for the calculation of the render delay.

Therefore, if the static filter chain took more than VOUT_MWAIT_TOLERANCE (4ms)
to complete, the next ThreadDisplayPreparePicture() could be called too late,
causing a frame drop.

This commit fixes this issue by adding a vout_chrono_t for the static filter
chain.
---
 src/video_output/video_output.c  | 10 +++++++++-
 src/video_output/vout_internal.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 659ede546ba..c21ee8b5371 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -867,6 +867,8 @@ static void ThreadChangeFilters(vout_thread_t *vout,
         vout->p->filter.configuration = filters ? strdup(filters) : NULL;
     }
 
+    vout_chrono_Reset(&vout->p->static_filter_chrono);
+
     if (!is_locked)
         vlc_mutex_unlock(&vout->p->filter.lock);
 }
@@ -951,7 +953,9 @@ static int ThreadDisplayPreparePicture(vout_thread_t *vout, bool reuse,
         vout->p->displayed.timestamp     = decoded->date;
         vout->p->displayed.is_interlaced = !decoded->b_progressive;
 
+        vout_chrono_Start(&vout->p->static_filter_chrono);
         picture = filter_chain_VideoFilter(vout->p->filter.chain_static, decoded);
+        vout_chrono_Stop(&vout->p->static_filter_chrono);
     }
 
     vlc_mutex_unlock(&vout->p->filter.lock);
@@ -1290,7 +1294,9 @@ static int ThreadDisplayPicture(vout_thread_t *vout, vlc_tick_t *deadline)
             ;
 
     const vlc_tick_t system_now = vlc_tick_now();
-    const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
+    const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render)
+                                  + vout_chrono_GetHigh(&sys->static_filter_chrono)
+                                  + VOUT_MWAIT_TOLERANCE;
 
     bool drop_next_frame = frame_by_frame;
     vlc_tick_t date_next = VLC_TICK_INVALID;
@@ -1823,6 +1829,7 @@ void vout_Close(vout_thread_t *vout)
     vout_snapshot_End(sys->snapshot);
     vout_control_Dead(&sys->control);
     vout_chrono_Clean(&sys->render);
+    vout_chrono_Clean(&sys->static_filter_chrono);
 
     if (sys->spu)
         spu_Destroy(sys->spu);
@@ -1963,6 +1970,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
 
     /* Arbitrary initial time */
     vout_chrono_Init(&sys->render, 5, VLC_TICK_FROM_MS(10));
+    vout_chrono_Init(&sys->static_filter_chrono, 5, VLC_TICK_FROM_MS(5));
 
     /* */
     atomic_init(&sys->refs, 0);
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 0ca81871fee..2000d1e4ad5 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -188,6 +188,7 @@ struct vout_thread_sys_t
     picture_pool_t  *display_pool;
     picture_fifo_t  *decoder_fifo;
     vout_chrono_t   render;           /**< picture render time estimator */
+    vout_chrono_t   static_filter_chrono; /**< static filter time estimator */
 
     atomic_uintptr_t refs;
 };
-- 
2.20.1



More information about the vlc-devel mailing list