[vlc-commits] [Git][videolan/vlc][master] video_output: reset chrono on Request and Flush
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Wed May 25 14:46:08 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
ca40c0c0 by Alexandre Janniaux at 2022-05-25T14:32:42+00:00
video_output: reset chrono on Request and Flush
Chrono are estimating the duration of the rendering when displaying
frames, but they were only initialized at the vout thread creation, and
not whenever the decoder outputs a different format (eg. because it's a
different decoder). It means that when rendering a 8k 24fps frame, and
then 360p 60fps picture, we'd expect that the first frames from the 360p
stream renders with the same timing as the 8k 24fps, which could lead to
useless drops. vout_Request was usually followed with a forced picture,
which helped mitigate the issue, but the chrono are averaging with
previous values, leading to local increase of expected rendering time at
the beginning.
Likewise, when flushing, timing constraints could have change, though
admittedly there is less obvious reason for the constraints to change
in this case. It still solves issues in the following cases:
- The framerate matches the refresh rate and the offset-to-VSYNC has
changed. It would reduce or increase the rendering time virtually
without controls from VLC.
- The rendering has been paused by a debugger at the middle of the
measurement. It would artifically set chrono to a very high value,
like 30 seconds, which means that a frame must arrive 30 seconds in
advance from the decoder to the video output to be displayed.
Rationnally, the chrono system is a heuristic to fast-forward the video
pipeline when the stream cannot be rendered in normal condition and
resetting the timestamps would not break already working streams,
whereas it would only display at most one more late picture in the
broken stream, which was already the case at the beginning of the stream
because of forced pictures.
- - - - -
1 changed file:
- src/video_output/video_output.c
Changes:
=====================================
src/video_output/video_output.c
=====================================
@@ -192,6 +192,15 @@ static inline struct vlc_tracer *GetTracer(vout_thread_sys_t *sys)
vlc_object_get_tracer(VLC_OBJECT(&sys->obj));
}
+static inline void VoutResetChronoLocked(vout_thread_sys_t *sys)
+{
+ vlc_mutex_assert(&sys->display_lock);
+
+ /* Arbitrary initial time */
+ vout_chrono_Init(&sys->chrono.render, 5, VLC_TICK_FROM_MS(10));
+ vout_chrono_Init(&sys->chrono.static_filter, 4, VLC_TICK_FROM_MS(0));
+}
+
static bool VoutCheckFormat(const video_format_t *src)
{
if (src->i_width == 0 || src->i_width > 8192 ||
@@ -1501,6 +1510,8 @@ static void vout_FlushUnlocked(vout_thread_sys_t *vout, bool below,
vlc_mutex_lock(&sys->display_lock);
if (sys->display != NULL)
vout_FilterFlush(sys->display);
+ /* Reinitialize chrono to ensure we re-compute any new render timing. */
+ VoutResetChronoLocked(sys);
vlc_mutex_unlock(&sys->display_lock);
if (sys->clock != NULL)
@@ -1649,6 +1660,9 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
vlc_mutex_lock(&sys->display_lock);
vlc_mutex_unlock(&sys->window_lock);
+ /* Reinitialize chrono to ensure we re-compute any new render timing. */
+ VoutResetChronoLocked(sys);
+
/* Setup the window size, protected by the display_lock */
dcfg.display.width = sys->window_width;
dcfg.display.height = sys->window_height;
@@ -1996,10 +2010,6 @@ vout_thread_t *vout_Create(vlc_object_t *object)
sys->window_enabled = false;
vlc_mutex_init(&sys->window_lock);
- /* Arbitrary initial time */
- vout_chrono_Init(&sys->chrono.render, 5, VLC_TICK_FROM_MS(10));
- vout_chrono_Init(&sys->chrono.static_filter, 4, VLC_TICK_FROM_MS(0));
-
if (var_InheritBool(vout, "video-wallpaper"))
vlc_window_SetState(sys->display_cfg.window, VLC_WINDOW_STATE_BELOW);
else if (var_InheritBool(vout, "video-on-top"))
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ca40c0c0496196fcdc415a2ed8262f6aa5beb590
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ca40c0c0496196fcdc415a2ed8262f6aa5beb590
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