[vlc-devel] [PATCH 13/16] video_output: drop the current frame as soon as we know we should

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


In the non-frame_by_frame mode. Sometimes we skip the current frame and use the
next frame.

We should actually loop in the "next" frames available until the last one
that still have time to display.

Renamed drop_next_frame to dropped_current_frame so it's clearer that it
already happened.
---
 src/video_output/video_output.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 699c9cddc30..660cf7d5338 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1512,7 +1512,7 @@ static int ThreadDisplayPicture(vout_thread_sys_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;
 
-        bool drop_next_frame = false;
+        bool dropped_current_frame = false;
         vlc_tick_t date_next = VLC_TICK_INVALID;
 
         if (!paused && sys->displayed.next) {
@@ -1523,7 +1523,14 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
             {
                 date_next = next_system_pts - render_delay;
                 if (date_next <= system_now)
-                    drop_next_frame = true;
+                {
+                    // next frame will still need some waiting before display
+                    dropped_current_frame = true;
+
+                    picture_Release(sys->displayed.current);
+                    sys->displayed.current = sys->displayed.next;
+                    sys->displayed.next    = NULL;
+                }
             }
         }
 
@@ -1543,22 +1550,16 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
             date_refresh = sys->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
             refresh = date_refresh <= system_now;
         }
-        force_refresh = !drop_next_frame && refresh;
+        force_refresh = !dropped_current_frame && refresh;
 
         if (date_refresh != VLC_TICK_INVALID)
             *deadline = date_refresh;
         if (date_next != VLC_TICK_INVALID && date_next < *deadline)
             *deadline = date_next;
 
-        if (!first && !refresh && !drop_next_frame) {
+        if (!first && !refresh && !dropped_current_frame) {
             return VLC_EGENERIC;
         }
-
-        if (drop_next_frame) {
-            picture_Release(sys->displayed.current);
-            sys->displayed.current = sys->displayed.next;
-            sys->displayed.next    = NULL;
-        }
     }
 
     if (!sys->displayed.current)
-- 
2.26.2



More information about the vlc-devel mailing list