[vlc-commits] [Git][videolan/vlc][master] 3 commits: vout: fix DisplayPicture() return value

Jean-Baptiste Kempf gitlab at videolan.org
Tue Jun 22 08:08:04 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
633c4ee1 by Romain Vimont at 2021-06-22T07:49:39+00:00
vout: fix DisplayPicture() return value

If deadline is NULL, then frame_by_frame is true, then render_now is
true, so DisplayPicture() returns VLC_EGENERIC.

Therefore, DisplayPicture() called from vout_NextPicture() could never
return 0 (VLC_SUCCESS), so the if-block in vout_NextPicture() was
unreachable.

- - - - -
c8ed4785 by Romain Vimont at 2021-06-22T07:49:39+00:00
vout: move deint handling to a separate function

This paves the way to handle frame-by-frame separetely.

Note: This commit is more comprehensible with:

    git show --patience

- - - - -
ad32fb4e by Romain Vimont at 2021-06-22T07:49:39+00:00
vout: move frame-by-frame to a separate function

The function DisplayPicture() handled both the frame-by-frame mode and
the "normal" mode (the mode depended on whether the deadline parameter
was NULL).

But almost the whole function is different for both cases, so use
separate functions.

Note: This commit is more comprehensible with:

    git show --patience -b

- - - - -


1 changed file:

- src/video_output/video_output.c


Changes:

=====================================
src/video_output/video_output.c
=====================================
@@ -1359,122 +1359,129 @@ static int RenderPicture(vout_thread_sys_t *vout, bool render_now)
     return VLC_SUCCESS;
 }
 
-static int DisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
+static void UpdateDeinterlaceFilter(vout_thread_sys_t *sys)
 {
-    vout_thread_sys_t *sys = vout;
-    bool frame_by_frame = !deadline;
-    bool paused = sys->pause.is_on;
-
-    assert(sys->clock);
-
     vlc_mutex_lock(&sys->filter.lock);
     if (sys->filter.changed ||
         sys->private.interlacing.has_deint != sys->filter.new_interlaced)
     {
         sys->private.interlacing.has_deint = sys->filter.new_interlaced;
-        ChangeFilters(vout);
+        ChangeFilters(sys);
     }
     vlc_mutex_unlock(&sys->filter.lock);
+}
 
-    bool render_now = true;
-    if (frame_by_frame)
-    {
-        picture_t *next;
-        next = PreparePicture(vout, !sys->displayed.current, true);
+static int DisplayNextFrame(vout_thread_sys_t *sys)
+{
+    UpdateDeinterlaceFilter(sys);
 
-        if (next)
-        {
-            if (likely(sys->displayed.current != NULL))
-                picture_Release(sys->displayed.current);
-            sys->displayed.current = next;
-        }
+    picture_t *next = PreparePicture(sys, !sys->displayed.current, true);
 
-        if (!sys->displayed.current)
-            return VLC_EGENERIC;
+    if (next)
+    {
+        if (likely(sys->displayed.current != NULL))
+            picture_Release(sys->displayed.current);
+        sys->displayed.current = next;
     }
-    else
+
+    if (!sys->displayed.current)
+        return VLC_EGENERIC;
+
+    return RenderPicture(sys, true);
+}
+
+static int DisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
+{
+    assert(deadline);
+
+    vout_thread_sys_t *sys = vout;
+    bool paused = sys->pause.is_on;
+
+    assert(sys->clock);
+
+    UpdateDeinterlaceFilter(sys);
+
+    bool render_now = true;
+    const vlc_tick_t system_now = vlc_tick_now();
+    const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
+    const bool first = !sys->displayed.current;
+
+    bool dropped_current_frame = false;
+
+    /* 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 refresh = false;
+
+    vlc_tick_t date_refresh = VLC_TICK_INVALID;
+
+    picture_t *next = NULL;
+    if (first)
     {
-        const vlc_tick_t system_now = vlc_tick_now();
-        const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
-        const bool first = !sys->displayed.current;
-
-        bool dropped_current_frame = false;
-
-        /* 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 refresh = false;
-
-        vlc_tick_t date_refresh = VLC_TICK_INVALID;
-
-        picture_t *next = NULL;
-        if (first)
+        next = PreparePicture(vout, true, false);
+        if (!next)
         {
-            next = PreparePicture(vout, true, false);
-            if (!next)
-            {
-                *deadline = VLC_TICK_INVALID;
-                return VLC_EGENERIC; // wait with no known deadline
-            }
+            *deadline = VLC_TICK_INVALID;
+            return VLC_EGENERIC; // wait with no known deadline
         }
-        else if (!paused)
+    }
+    else if (!paused)
+    {
+        const vlc_tick_t next_system_pts =
+            vlc_clock_ConvertToSystem(sys->clock, system_now,
+                                      sys->displayed.current->date, sys->rate);
+        if (likely(next_system_pts != INT64_MAX))
         {
-            const vlc_tick_t next_system_pts =
-                vlc_clock_ConvertToSystem(sys->clock, system_now,
-                                          sys->displayed.current->date, sys->rate);
-            if (likely(next_system_pts != INT64_MAX))
+            vlc_tick_t date_next = next_system_pts - render_delay;
+            if (date_next <= system_now)
             {
-                vlc_tick_t date_next = next_system_pts - render_delay;
-                if (date_next <= system_now)
-                {
-                    // the current frame will be late, look for the next not late one
-                    next = PreparePicture(vout, false, false);
-                }
+                // the current frame will be late, look for the next not late one
+                next = PreparePicture(vout, false, false);
             }
         }
+    }
 
-        if (next != NULL)
-        {
-            const vlc_tick_t swap_next_pts =
-                vlc_clock_ConvertToSystem(sys->clock, vlc_tick_now(),
-                                            next->date, sys->rate);
-            if (likely(swap_next_pts != INT64_MAX))
-                date_refresh = swap_next_pts - render_delay;
-
-            // next frame will still need some waiting before display
-            dropped_current_frame = sys->displayed.current != NULL;
-            render_now = false;
-
-            if (likely(dropped_current_frame))
-                picture_Release(sys->displayed.current);
-            sys->displayed.current = next;
-        }
-        else if (likely(sys->displayed.date != VLC_TICK_INVALID))
-        {
-            // next date we need to display again the current picture
-            date_refresh = sys->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
-            refresh = date_refresh <= system_now;
-            render_now = refresh;
-        }
-
-        if (date_refresh != VLC_TICK_INVALID)
-            *deadline = date_refresh;
+    if (next != NULL)
+    {
+        const vlc_tick_t swap_next_pts =
+            vlc_clock_ConvertToSystem(sys->clock, vlc_tick_now(),
+                                        next->date, sys->rate);
+        if (likely(swap_next_pts != INT64_MAX))
+            date_refresh = swap_next_pts - render_delay;
+
+        // next frame will still need some waiting before display
+        dropped_current_frame = sys->displayed.current != NULL;
+        render_now = false;
+
+        if (likely(dropped_current_frame))
+            picture_Release(sys->displayed.current);
+        sys->displayed.current = next;
+    }
+    else if (likely(sys->displayed.date != VLC_TICK_INVALID))
+    {
+        // next date we need to display again the current picture
+        date_refresh = sys->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
+        refresh = date_refresh <= system_now;
+        render_now = refresh;
+    }
 
-        if (!first && !refresh && !dropped_current_frame) {
-            // nothing changed, wait until the next deadline or a control
-            return VLC_EGENERIC;
-        }
+    if (date_refresh != VLC_TICK_INVALID)
+        *deadline = date_refresh;
 
-        /* display the picture immediately */
-        render_now |= sys->displayed.current->b_force;
+    if (!first && !refresh && !dropped_current_frame) {
+        // nothing changed, wait until the next deadline or a control
+        return VLC_EGENERIC;
     }
 
+    /* display the picture immediately */
+    render_now |= sys->displayed.current->b_force;
+
     int ret = RenderPicture(vout, render_now);
     return render_now ? VLC_EGENERIC : ret;
 }
@@ -1559,7 +1566,7 @@ void vout_NextPicture(vout_thread_t *vout, vlc_tick_t *duration)
     if (sys->step.last == VLC_TICK_INVALID)
         sys->step.last = sys->displayed.timestamp;
 
-    if (DisplayPicture(sys, NULL) == 0) {
+    if (DisplayNextFrame(sys) == VLC_SUCCESS) {
         sys->step.timestamp = sys->displayed.timestamp;
 
         if (sys->step.last != VLC_TICK_INVALID &&



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a869a8c1ad2c2a560fccd68a815c15210e21796b...ad32fb4eb1fecc04f30d28a8646521b49e3b30c6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a869a8c1ad2c2a560fccd68a815c15210e21796b...ad32fb4eb1fecc04f30d28a8646521b49e3b30c6
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list