[vlc-devel] [PATCH 3/7] video_output: use a function to check if a display picture should be dropped

Steve Lhomme robux4 at ycbcr.xyz
Tue Oct 20 11:04:34 CEST 2020


If the frame is dropped, the picture is released and we continue looping until
there's a decoded picture that is not late or no decoded picture at all.

No functional changes.
---
 src/video_output/video_output.c | 75 ++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 33 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index f582b5c1cff..beb2bf21e16 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1058,6 +1058,46 @@ static void ThreadChangeFilters(vout_thread_sys_t *vout)
     sys->filter.changed = false;
 }
 
+static bool DropLate(vout_thread_sys_t *vout, picture_t *decoded, bool can_drop_late, bool *paused)
+{
+    vout_thread_sys_t *sys = vout;
+
+    const vlc_tick_t system_now = vlc_tick_now();
+    const vlc_tick_t system_pts =
+        vlc_clock_ConvertToSystem(sys->clock, system_now,
+                                  decoded->date, sys->rate);
+
+    if (system_pts == INT64_MAX)
+    {
+        /* The clock is paused, notify it (so that the current
+            * picture is displayed but not the next one), this
+            * current picture can't be be late. */
+        *paused = true;
+    }
+    else if (sys->is_late_dropped && can_drop_late && !decoded->b_force)
+    {
+        vlc_tick_t late = system_now - system_pts;
+
+        vlc_tick_t late_threshold;
+        if (decoded->format.i_frame_rate && decoded->format.i_frame_rate_base) {
+            late_threshold = vlc_tick_from_samples(decoded->format.i_frame_rate_base, decoded->format.i_frame_rate);
+            late_threshold /=  2;
+        }
+        else
+            late_threshold = VOUT_DISPLAY_LATE_THRESHOLD;
+        if (late > late_threshold) {
+            msg_Warn(&vout->obj, "picture is too late to be displayed (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
+            picture_Release(decoded);
+            vout_statistic_AddLost(&sys->statistic, 1);
+            return true;
+        }
+        if (late > 0) {
+            msg_Dbg(&vout->obj, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
+            vout_statistic_AddLate(&sys->statistic, 1);
+        }
+    }
+    return false;
+}
 
 /* */
 VLC_USED
@@ -1077,39 +1117,8 @@ static picture_t *ThreadGetPrerenderedLocked(vout_thread_sys_t *vout, bool reuse
             decoded = picture_fifo_Pop(sys->decoder_fifo);
 
             if (decoded) {
-                const vlc_tick_t system_now = vlc_tick_now();
-                const vlc_tick_t system_pts =
-                    vlc_clock_ConvertToSystem(sys->clock, system_now,
-                                              decoded->date, sys->rate);
-
-                if (system_pts == INT64_MAX)
-                {
-                    /* The clock is paused, notify it (so that the current
-                        * picture is displayed but not the next one), this
-                        * current picture can't be be late. */
-                    *paused = true;
-                }
-                else if (sys->is_late_dropped && can_drop_late && !decoded->b_force)
-                {
-                    vlc_tick_t late = system_now - system_pts;
-
-                    vlc_tick_t late_threshold;
-                    if (decoded->format.i_frame_rate && decoded->format.i_frame_rate_base) {
-                        late_threshold = vlc_tick_from_samples(decoded->format.i_frame_rate_base, decoded->format.i_frame_rate);
-                        late_threshold /=  2;
-                    }
-                    else
-                        late_threshold = VOUT_DISPLAY_LATE_THRESHOLD;
-                    if (late > late_threshold) {
-                        msg_Warn(&vout->obj, "picture is too late to be displayed (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
-                        picture_Release(decoded);
-                        vout_statistic_AddLost(&sys->statistic, 1);
-                        continue;
-                    } else if (late > 0) {
-                        msg_Dbg(&vout->obj, "picture might be displayed late (missing %"PRId64" ms)", MS_FROM_VLC_TICK(late));
-                        vout_statistic_AddLate(&sys->statistic, 1);
-                    }
-                }
+                if (DropLate(vout, decoded, can_drop_late, paused))
+                    continue;
                 vlc_video_context *pic_vctx = picture_GetVideoContext(decoded);
                 if (!VideoFormatIsCropArEqual(&decoded->format, &sys->filter.src_fmt))
                 {
-- 
2.26.2



More information about the vlc-devel mailing list