[vlc-devel] [PATCH 3/5] video_output: rework the frame by frame mode picture picking

Steve Lhomme robux4 at ycbcr.xyz
Thu Jan 21 12:13:13 UTC 2021


We only update the displayed.current if there is a next picture to use.
If there was a remaining displayed.next picture we use that as the next picture.

We no longer lose the displayed.current if there is no next picture yet.
---
 src/video_output/video_output.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index a2d25194504..c0bcb89ba8a 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1484,25 +1484,25 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
     bool render_now;
     if (frame_by_frame)
     {
-        if (!sys->displayed.current)
+        picture_t *next;
+        if (likely(!sys->displayed.next))
         {
-            assert(!sys->displayed.next);
-            sys->displayed.current =
-                ThreadDisplayPreparePicture(vout, true, true, &paused);
-            if (!sys->displayed.current)
-                return VLC_EGENERIC; // wait with no known deadline
+            next =
+                ThreadDisplayPreparePicture(vout, !sys->displayed.current, true, &paused);
         }
-
-        if (!sys->displayed.next)
+        else
         {
-            sys->displayed.next =
-                ThreadDisplayPreparePicture(vout, false, true, &paused);
+            // remaining from normal playback
+            next = sys->displayed.next;
+            sys->displayed.next = NULL;
         }
 
-        if (likely(sys->displayed.current != NULL))
-            picture_Release(sys->displayed.current);
-        sys->displayed.current = sys->displayed.next;
-        sys->displayed.next    = NULL;
+        if (next)
+        {
+            if (likely(sys->displayed.current != NULL))
+                picture_Release(sys->displayed.current);
+            sys->displayed.current = next;
+        }
 
         if (!sys->displayed.current)
             return VLC_EGENERIC;
-- 
2.29.2



More information about the vlc-devel mailing list