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.
This commit is contained in:
wm4
2015-07-01 19:24:28 +02:00
parent f166d12985
commit 0739cfc209
8 changed files with 267 additions and 270 deletions

View File

@@ -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)