[vlc-commits] video_output: drop the current frame as soon as we know we should

Steve Lhomme git at videolan.org
Tue Oct 20 11:03:08 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 16 14:42:46 2020 +0200| [633a1e8067ffb4fc08b0d35b2d42bb500278d767] | committer: Steve Lhomme

video_output: drop the current frame as soon as we know we should

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.

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

 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 3b38f84aa5..18c0380a60 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1513,7 +1513,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) {
@@ -1524,7 +1524,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;
+                }
             }
         }
 
@@ -1544,23 +1551,17 @@ 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) {
             // nothing changed, wait until the next deadline or a control
             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)



More information about the vlc-commits mailing list