[vlc-devel] [PATCH 16/16] video_output: compute force_refresh earlier

Steve Lhomme robux4 at ycbcr.xyz
Fri Oct 16 16:26:47 CEST 2020


First if a re-display is needed. And then if the current frame has changed it
doesn't need to be displayed ASAP, we know it's within the render delay.

Merge force_refresh and render_now since they mean the same thing.
---
 src/video_output/video_output.c | 54 ++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 4e97b342df9..0a4612c7a5a 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1483,7 +1483,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
             return VLC_EGENERIC; // wait with no known deadline
     }
 
-    bool force_refresh;
+    bool render_now;
     if (frame_by_frame)
     {
         if (!sys->displayed.next)
@@ -1496,7 +1496,7 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
         sys->displayed.current = sys->displayed.next;
         sys->displayed.next    = NULL;
 
-        force_refresh = true;
+        render_now = true;
     }
     else
     {
@@ -1513,7 +1513,24 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
         const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
 
         bool dropped_current_frame = false;
-        vlc_tick_t date_next = VLC_TICK_INVALID;
+
+        /* FIXME/XXX we must redisplay the last decoded picture (because
+        * of potential vout updated, or filters update or SPU update)
+        * For now a high update period is needed but it could be removed
+        * if and only if:
+        * - vout module emits events from themselves.
+        * - *and* SPU is modified to emit an event or a deadline when needed.
+        *
+        * So it will be done later.
+        */
+        bool redisplay_needed = false;
+
+        vlc_tick_t date_refresh = VLC_TICK_INVALID;
+        if (sys->displayed.date != VLC_TICK_INVALID) {
+            date_refresh = sys->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
+            redisplay_needed = date_refresh <= system_now;
+        }
+        render_now = redisplay_needed;
 
         if (!paused && sys->displayed.next) {
             const vlc_tick_t next_system_pts =
@@ -1521,11 +1538,15 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
                                         sys->displayed.next->date, sys->rate);
             if (likely(next_system_pts != INT64_MAX))
             {
-                date_next = next_system_pts - render_delay;
+                vlc_tick_t date_next = next_system_pts - render_delay;
+                if (date_refresh == VLC_TICK_INVALID || date_next < date_refresh)
+                    date_refresh = date_next;
+
                 if (date_next <= system_now)
                 {
                     // next frame will still need some waiting before display
                     dropped_current_frame = true;
+                    render_now = false;
 
                     picture_Release(sys->displayed.current);
                     sys->displayed.current = sys->displayed.next;
@@ -1533,29 +1554,8 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
                 }
             }
         }
-
-        /* FIXME/XXX we must redisplay the last decoded picture (because
-        * of potential vout updated, or filters update or SPU update)
-        * For now a high update period is needed but it could be removed
-        * if and only if:
-        * - vout module emits events from theselves.
-        * - *and* SPU is modified to emit an event or a deadline when needed.
-        *
-        * So it will be done later.
-        */
-        bool redisplay_needed = false;
-
-        vlc_tick_t date_refresh = VLC_TICK_INVALID;
-        if (sys->displayed.date != VLC_TICK_INVALID) {
-            date_refresh = sys->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
-            redisplay_needed = date_refresh <= system_now;
-        }
-        force_refresh = !dropped_current_frame && redisplay_needed;
-
         if (date_refresh != VLC_TICK_INVALID)
             *deadline = date_refresh;
-        if (date_next != VLC_TICK_INVALID && date_next < *deadline)
-            *deadline = date_next;
 
         if (!first && !redisplay_needed && !dropped_current_frame) {
             // nothing changed, wait until the next deadline or a control
@@ -1567,9 +1567,9 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
         return VLC_EGENERIC;
 
     /* display the picture immediately */
-    bool render_now = force_refresh || sys->displayed.current->b_force;
+    render_now |= sys->displayed.current->b_force;
     int ret = ThreadDisplayRenderPicture(vout, render_now);
-    return force_refresh ? VLC_EGENERIC : ret;
+    return render_now ? VLC_EGENERIC : ret;
 }
 
 void vout_ChangePause(vout_thread_t *vout, bool is_paused, vlc_tick_t date)
-- 
2.26.2



More information about the vlc-devel mailing list