diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-12-04 18:10:17 +0200 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-12-06 02:55:13 +0200 |
commit | c9553ce82fdb80811196f40b9c1eaaa3b2351e01 (patch) | |
tree | 8a0068a1f2654637bcd90a9c8529016f568078d1 /libvo/video_out.c | |
parent | 421c840b3c061de89b426244fe75237a73f765de (diff) | |
download | mpv-c9553ce82fdb80811196f40b9c1eaaa3b2351e01.tar.bz2 mpv-c9553ce82fdb80811196f40b9c1eaaa3b2351e01.tar.xz |
vo: do final frame draw only near page flip
Separate passing a new frame to VOs using the new API into two steps.
The first, vo_draw_image(), happens after a new frame is available
from the filter chain. In constrast to old behavior, now the frame is
not actually rendered yet at this point (though possible slice draw
calls can already reach the VO before). The second step,
vo_new_frame_imminent(), happens when we're close enough to the
display time of the new frame that we'll commit to flipping it as the
next action and will not change the OSD over the previous frame any
more.
This new behavior fixes a previous problem with vo_vdpau and vo_gl in
the situation where the player is paused after decoding a new frame
but before flipping it; previously changing OSD in that state would
switch to the new frame as a side effect. It would also allow an easy
way to fix extra output files produced with something like "--vo=png
--frames=1" with precise seeking, but this is not done yet.
The code now relies on a new mp_image from the filter chain staying
valid even after the vf_vo put_image() call providing it returns. In
other words decoders/filters must not deallocate or otherwise
invalidate their output frame between passing it forward and returning
from the decode/filter call.
Diffstat (limited to 'libvo/video_out.c')
-rw-r--r-- | libvo/video_out.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c index e796784b1e..82cf0dbbfe 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -275,6 +275,11 @@ int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts) } vo->frame_loaded = true; vo->next_pts = pts; + // Guaranteed to support at least DRAW_IMAGE later + if (vo->driver->is_new) { + vo->waiting_mpi = mpi; + return 0; + } if (vo_control(vo, VOCTRL_DRAW_IMAGE, mpi) == VO_NOTIMPL) return -1; return 0; @@ -294,6 +299,7 @@ int vo_get_buffered_frame(struct vo *vo, bool eof) void vo_skip_frame(struct vo *vo) { + vo_control(vo, VOCTRL_SKIPFRAME, NULL); vo->frame_loaded = false; } @@ -310,6 +316,18 @@ int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int return vo->driver->draw_slice(vo, src, stride, w, h, x, y); } +void vo_new_frame_imminent(struct vo *vo) +{ + if (!vo->driver->is_new) + return; + if (vo->driver->buffer_frames) + vo_control(vo, VOCTRL_NEWFRAME, NULL); + else { + vo_control(vo, VOCTRL_DRAW_IMAGE, vo->waiting_mpi); + vo->waiting_mpi = NULL; + } +} + void vo_draw_osd(struct vo *vo, struct osd_state *osd) { if (!vo->config_ok) @@ -466,6 +484,8 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height, NULL, vo); vo->registered_fd = vo->event_fd; } + vo->frame_loaded = false; + vo->waiting_mpi = NULL; return ret; } |