diff options
author | wm4 <wm4@nowhere> | 2015-07-01 19:24:28 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-07-01 22:38:02 +0200 |
commit | 0739cfc20934ac7772ab71dbae7ecba4ba10fda4 (patch) | |
tree | 939c829441af634577d71fbdf99a60314aa3ab42 /player | |
parent | f166d1298545154618ee2d046bb3c433469469c2 (diff) | |
download | mpv-0739cfc20934ac7772ab71dbae7ecba4ba10fda4.tar.bz2 mpv-0739cfc20934ac7772ab71dbae7ecba4ba10fda4.tar.xz |
vo: change internal API for drawing frames
draw_image_timed is renamed to draw_frame. struct frame_timing is
renamed to vo_frame. flip_page_timed is merged into draw_frame (the
additional parameters are part of struct vo_frame). draw_frame also
deprecates VOCTRL_REDRAW_FRAME, and replaces it with a method that
works for both VOs which can cache the current frame, and VOs which
need to redraw it anyway.
This is preparation to making the interpolation and (work in progress)
display sync code saner.
Lots of other refactoring, and also some simplifications.
Diffstat (limited to 'player')
-rw-r--r-- | player/video.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/player/video.c b/player/video.c index da93203b7a..87e6a8fb60 100644 --- a/player/video.c +++ b/player/video.c @@ -582,6 +582,17 @@ static void handle_new_frame(struct MPContext *mpctx) MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time); } +// Remove the first frame in mpctx->next_frames +static void shift_frames(struct MPContext *mpctx) +{ + if (mpctx->num_next_frames < 1) + return; + talloc_free(mpctx->next_frames[0]); + for (int n = 0; n < mpctx->num_next_frames - 1; n++) + mpctx->next_frames[n] = mpctx->next_frames[n + 1]; + mpctx->num_next_frames -= 1; +} + static int get_req_frames(struct MPContext *mpctx, bool eof) { struct MPOpts *opts = mpctx->opts; @@ -880,17 +891,16 @@ void write_video(struct MPContext *mpctx, double endpts) update_subtitles(mpctx); assert(mpctx->num_next_frames >= 1); - struct mp_image *frames[VO_MAX_FUTURE_FRAMES + 2] = {0}; - frames[0] = mpctx->next_frames[0]; - for (int n = 0; n < mpctx->num_next_frames - 1; n++) - mpctx->next_frames[n] = mpctx->next_frames[n + 1]; - mpctx->num_next_frames -= 1; - for (int n = 0; n < mpctx->num_next_frames && n < VO_MAX_FUTURE_FRAMES; n++) { - frames[n + 1] = mp_image_new_ref(mpctx->next_frames[n]); - if (!frames[n + 1]) - break; // OOM - } - vo_queue_frame(vo, frames, pts, duration); + struct vo_frame dummy = { + .pts = pts, + .duration = duration, + .num_frames = mpctx->num_next_frames, + }; + for (int n = 0; n < dummy.num_frames; n++) + dummy.frames[n] = mpctx->next_frames[n]; + vo_queue_frame(vo, vo_frame_ref(&dummy)); + + shift_frames(mpctx); // The frames were shifted down; "initialize" the new first entry. if (mpctx->num_next_frames >= 1) |