[vlc-commits] [Git][videolan/vlc][master] 7 commits: vout: break early

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Aug 2 15:39:56 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
7fc0ba68 by Thomas Guillem at 2024-08-02T15:23:21+00:00
vout: break early

The indention is not changed yet, cf. next commits.

- - - - -
a3631148 by Thomas Guillem at 2024-08-02T15:23:21+00:00
vout: reindent format crop check

No functional changes.

- - - - -
b7f6c5ee by Thomas Guillem at 2024-08-02T15:23:21+00:00
vout: don't convert pts if forced

- - - - -
50c14d9b by Thomas Guillem at 2024-08-02T15:23:21+00:00
vout: don't lock the clock when not needed

- - - - -
a184fb26 by Thomas Guillem at 2024-08-02T15:23:21+00:00
vout: overwrite subtitle rendering date if forced

- - - - -
7e07f669 by Thomas Guillem at 2024-08-02T15:23:21+00:00
vout: assert that the picture is not forced before using the clock

- - - - -
aa997df3 by Thomas Guillem at 2024-08-02T15:23:21+00:00
vout: don't query the clock for the first picture

This will avoid to convert ts from a forced picture, thus triggering a
the mononotic clock setup from invalid timestamps.

This is tied to the "Received first picture" hack in input/decoder.c.

- - - - -


1 changed file:

- src/video_output/video_output.c


Changes:

=====================================
src/video_output/video_output.c
=====================================
@@ -82,6 +82,7 @@ typedef struct vout_thread_sys_t
     vlc_mutex_t clock_lock;
     bool clock_nowait; /* protected by vlc_clock_Lock()/vlc_clock_Unlock() */
     bool wait_interrupted;
+    bool first_picture;
 
     vlc_clock_t     *clock;
     vlc_clock_listener_id *clock_listener_id;
@@ -993,10 +994,15 @@ static picture_t *PreparePicture(vout_thread_sys_t *vout, bool reuse_decoded,
         picture_t *decoded;
         if (unlikely(reuse_decoded && sys->displayed.decoded)) {
             decoded = picture_Hold(sys->displayed.decoded);
+            if (decoded == NULL)
+                break;
         } else {
             decoded = picture_fifo_Pop(sys->decoder_fifo);
+            if (decoded == NULL)
+                break;
 
-            if (decoded) {
+            if (!decoded->b_force)
+            {
                 const vlc_tick_t system_now = vlc_tick_now();
                 uint32_t clock_id;
                 vlc_clock_Lock(sys->clock);
@@ -1018,8 +1024,9 @@ static picture_t *PreparePicture(vout_thread_sys_t *vout, bool reuse_decoded,
                     filter_chain_VideoFlush(sys->filter.chain_static);
                 }
 
-                if (is_late_dropped && !decoded->b_force
-                 && IsPictureLateToStaticFilter(vout, &decoded->format, system_pts - system_now))
+                if (is_late_dropped
+                 && IsPictureLateToStaticFilter(vout, &decoded->format,
+                                                system_pts - system_now))
                 {
                     picture_Release(decoded);
                     vout_statistic_AddLost(&sys->statistic, 1);
@@ -1029,25 +1036,23 @@ static picture_t *PreparePicture(vout_thread_sys_t *vout, bool reuse_decoded,
                     filter_chain_VideoFlush(sys->filter.chain_static);
                     continue;
                 }
+            }
 
-                if (!VideoFormatIsCropArEqual(&decoded->format, &sys->filter.src_fmt))
-                {
-                    // we received an aspect ratio change
-                    // Update the filters with the filter source format with the new aspect ratio
-                    video_format_Clean(&sys->filter.src_fmt);
-                    video_format_Copy(&sys->filter.src_fmt, &decoded->format);
-                    if (sys->filter.src_vctx)
-                        vlc_video_context_Release(sys->filter.src_vctx);
-                    vlc_video_context *pic_vctx = picture_GetVideoContext(decoded);
-                    sys->filter.src_vctx = pic_vctx ? vlc_video_context_Hold(pic_vctx) : NULL;
-
-                    ChangeFilters(vout);
-                }
+            if (!VideoFormatIsCropArEqual(&decoded->format, &sys->filter.src_fmt))
+            {
+                // we received an aspect ratio change
+                // Update the filters with the filter source format with the new aspect ratio
+                video_format_Clean(&sys->filter.src_fmt);
+                video_format_Copy(&sys->filter.src_fmt, &decoded->format);
+                if (sys->filter.src_vctx)
+                    vlc_video_context_Release(sys->filter.src_vctx);
+                vlc_video_context *pic_vctx = picture_GetVideoContext(decoded);
+                sys->filter.src_vctx = pic_vctx ? vlc_video_context_Hold(pic_vctx) : NULL;
+
+                ChangeFilters(vout);
             }
         }
 
-        if (!decoded)
-            break;
         reuse_decoded = false;
 
         if (sys->displayed.decoded)
@@ -1174,6 +1179,8 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
     vlc_tick_t render_subtitle_date;
     if (sys->pause.is_on)
         render_subtitle_date = sys->pause.date;
+    else if (filtered->b_force)
+        render_subtitle_date = system_now;
     else
     {
         vlc_clock_Lock(sys->clock);
@@ -1350,10 +1357,17 @@ static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
 
     vlc_tick_t system_now = vlc_tick_now();
     const vlc_tick_t pts = todisplay->date;
-    vlc_clock_Lock(sys->clock);
-    vlc_tick_t system_pts = render_now ? system_now :
-        vlc_clock_ConvertToSystem(sys->clock, system_now, pts, sys->rate, NULL);
-    vlc_clock_Unlock(sys->clock);
+    vlc_tick_t system_pts;
+    if (render_now)
+        system_pts = system_now;
+    else
+    {
+        vlc_clock_Lock(sys->clock);
+        assert(!sys->displayed.current->b_force);
+        system_pts = vlc_clock_ConvertToSystem(sys->clock, system_now, pts,
+                                               sys->rate, NULL);
+        vlc_clock_Unlock(sys->clock);
+    }
 
     const unsigned frame_rate = todisplay->format.i_frame_rate;
     const unsigned frame_rate_base = todisplay->format.i_frame_rate_base;
@@ -1396,6 +1410,7 @@ static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
                     deadline = max_deadline;
                 else
                 {
+                    assert(!sys->displayed.current->b_force);
                     deadline = vlc_clock_ConvertToSystem(sys->clock,
                                                          vlc_tick_now(), pts,
                                                          sys->rate, NULL);
@@ -1502,6 +1517,19 @@ static bool UpdateCurrentPicture(vout_thread_sys_t *sys)
     if (sys->pause.is_on || sys->wait_interrupted)
         return false;
 
+    /* Prevent to query the clock if we know that there are no next pictures.
+     * Since the clock is likely no properly setup at that stage. Indeed, the
+     * input/decoder.c send a first forced picture quickly, then a next one
+     * when the clock is configured. */
+    if (sys->first_picture)
+    {
+        bool has_next_pic = !picture_fifo_IsEmpty(sys->decoder_fifo);
+        if (!has_next_pic)
+            return false;
+
+        sys->first_picture = false;
+    }
+
     const vlc_tick_t system_now = vlc_tick_now();
     vlc_clock_Lock(sys->clock);
     const vlc_tick_t system_swap_current =
@@ -1645,6 +1673,7 @@ static void vout_FlushUnlocked(vout_thread_sys_t *vout, bool below,
         vlc_clock_SetDelay(sys->clock, sys->delay);
         vlc_clock_Unlock(sys->clock);
     }
+    sys->first_picture = true;
 }
 
 void vout_Flush(vout_thread_t *vout, vlc_tick_t date)
@@ -1958,6 +1987,7 @@ static void vout_ReleaseDisplay(vout_thread_sys_t *vout)
     vlc_mutex_unlock(&sys->clock_lock);
     sys->str_id = NULL;
     sys->clock_id = 0;
+    sys->first_picture = true;
 }
 
 void vout_StopDisplay(vout_thread_t *vout)
@@ -2135,6 +2165,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
     vlc_mutex_init(&sys->clock_lock);
     sys->clock_nowait = false;
     sys->wait_interrupted = false;
+    sys->first_picture = true;
 
     /* Display */
     sys->display = NULL;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2263f53232c7ec96555bd2409580757de0f97f37...aa997df3923848db9607a6cc7617e4ecc5e10d97

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


VideoLAN code repository instance


More information about the vlc-commits mailing list