[vlc-commits] video_output: handle the case where frame_by_frame is set separately
Steve Lhomme
git at videolan.org
Tue Oct 20 11:03:07 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 16 14:13:46 2020 +0200| [a7daab0bfc0d0a9ceb3deafb19f25ecfbff8b4d6] | committer: Steve Lhomme
video_output: handle the case where frame_by_frame is set separately
Simply add "if (frame_by_frame) {} else {}" and double the code. Then simplify
the code for always true or always false conditions.
in the end it's clear the frame_by_frame part only gets the next picture to set
in the current one (and reuse the store displayed.next if there was one).
force_refresh is set to true when frame_by_frame is true, so we can simplify
the is_forced test. (it was false before but is_forced would end up true anyway).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a7daab0bfc0d0a9ceb3deafb19f25ecfbff8b4d6
---
src/video_output/video_output.c | 103 +++++++++++++++++++++++-----------------
1 file changed, 60 insertions(+), 43 deletions(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 8db148c0bd..3b38f84aa5 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1484,73 +1484,90 @@ static int ThreadDisplayPicture(vout_thread_sys_t *vout, vlc_tick_t *deadline)
return VLC_EGENERIC; // wait with no known deadline
}
- if (!paused || frame_by_frame)
+ bool force_refresh;
+ if (frame_by_frame)
{
if (!sys->displayed.next)
{
sys->displayed.next =
- ThreadDisplayPreparePicture(vout, false, frame_by_frame, &paused);
+ ThreadDisplayPreparePicture(vout, false, true, &paused);
}
- }
-
- const vlc_tick_t system_now = vlc_tick_now();
- const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
- bool drop_next_frame = frame_by_frame;
- vlc_tick_t date_next = VLC_TICK_INVALID;
+ picture_Release(sys->displayed.current);
+ sys->displayed.current = sys->displayed.next;
+ sys->displayed.next = NULL;
- if (!paused && sys->displayed.next) {
- const vlc_tick_t next_system_pts =
- vlc_clock_ConvertToSystem(sys->clock, system_now,
- sys->displayed.next->date, sys->rate);
- if (likely(next_system_pts != INT64_MAX))
+ force_refresh = true;
+ }
+ else
+ {
+ if (!paused)
{
- date_next = next_system_pts - render_delay;
- if (date_next <= system_now)
- drop_next_frame = true;
+ if (!sys->displayed.next)
+ {
+ sys->displayed.next =
+ ThreadDisplayPreparePicture(vout, false, false, &paused);
+ }
}
- }
- /* 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 theselves.
- * - *and* SPU is modified to emit an event or a deadline when needed.
- *
- * So it will be done later.
- */
- bool refresh = false;
+ const vlc_tick_t system_now = vlc_tick_now();
+ const vlc_tick_t render_delay = vout_chrono_GetHigh(&sys->render) + VOUT_MWAIT_TOLERANCE;
- vlc_tick_t date_refresh = VLC_TICK_INVALID;
- if (sys->displayed.date != VLC_TICK_INVALID) {
- date_refresh = sys->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
- refresh = date_refresh <= system_now;
- }
- bool force_refresh = !drop_next_frame && refresh;
+ bool drop_next_frame = false;
+ vlc_tick_t date_next = VLC_TICK_INVALID;
+
+ if (!paused && sys->displayed.next) {
+ const vlc_tick_t next_system_pts =
+ vlc_clock_ConvertToSystem(sys->clock, system_now,
+ sys->displayed.next->date, sys->rate);
+ if (likely(next_system_pts != INT64_MAX))
+ {
+ date_next = next_system_pts - render_delay;
+ if (date_next <= system_now)
+ drop_next_frame = true;
+ }
+ }
+
+ /* 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 theselves.
+ * - *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;
+ if (sys->displayed.date != VLC_TICK_INVALID) {
+ date_refresh = sys->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
+ refresh = date_refresh <= system_now;
+ }
+ force_refresh = !drop_next_frame && refresh;
- if (!frame_by_frame) {
if (date_refresh != VLC_TICK_INVALID)
*deadline = date_refresh;
if (date_next != VLC_TICK_INVALID && date_next < *deadline)
*deadline = date_next;
- }
- if (!first && !refresh && !drop_next_frame) {
- return VLC_EGENERIC;
- }
+ if (!first && !refresh && !drop_next_frame) {
+ // nothing changed, wait until the next deadline or a control
+ return VLC_EGENERIC;
+ }
- if (drop_next_frame) {
- picture_Release(sys->displayed.current);
- sys->displayed.current = sys->displayed.next;
- sys->displayed.next = NULL;
+ if (drop_next_frame) {
+ picture_Release(sys->displayed.current);
+ sys->displayed.current = sys->displayed.next;
+ sys->displayed.next = NULL;
+ }
}
if (!sys->displayed.current)
return VLC_EGENERIC;
/* display the picture immediately */
- bool is_forced = frame_by_frame || force_refresh || sys->displayed.current->b_force;
+ bool is_forced = force_refresh || sys->displayed.current->b_force;
int ret = ThreadDisplayRenderPicture(vout, is_forced);
return force_refresh ? VLC_EGENERIC : ret;
}
More information about the vlc-commits
mailing list