1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-17 04:15:13 +00:00

vo_opengl, vo_opengl_cb: drop unneeded vo_frame fields

next_vsync/prev_vsync was only used to retrieve the vsync duration. We
can get this in a simpler way.

This also removes the vsync duration estimation from vo_opengl_cb.c,
which is probably worthless anyway. (And once interpolation is made
display-sync only, this won't matter at all.)
This commit is contained in:
wm4 2015-11-04 14:26:28 +01:00
parent be49da72ea
commit e6a395c297
4 changed files with 6 additions and 28 deletions

View File

@ -1859,8 +1859,7 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t,
// Blend the frames together
if (oversample) {
double vsync_dist = (t->next_vsync - t->prev_vsync)/1e6
/ (pts_nxt - pts_now),
double vsync_dist = t->vsync_interval / 1e6 / (pts_nxt - pts_now),
threshold = tscale->conf.kernel.params[0];
threshold = isnan(threshold) ? 0.0 : threshold;
mix = (1 - mix) / vsync_dist;
@ -1884,7 +1883,7 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t,
MP_STATS(p, "frame-mix");
MP_DBG(p, "inter frame pts: %lld, vsync: %lld, mix: %f\n",
(long long)t->pts, (long long)t->next_vsync, mix);
(long long)t->pts, (long long)t->vsync_interval, mix);
p->is_interpolated = true;
}
pass_draw_to_screen(p, fbo);

View File

@ -640,8 +640,7 @@ static bool render_frame(struct vo *vo)
int64_t prev_vsync = prev_sync(vo, mp_time_us());
int64_t next_vsync = prev_vsync + in->vsync_interval;
frame->next_vsync = next_vsync;
frame->prev_vsync = prev_vsync;
frame->vsync_interval = in->vsync_interval;
// Time at which we should flip_page on the VO.
int64_t target = frame->display_synced ? 0 : pts - in->flip_queue_offset;

View File

@ -157,9 +157,8 @@ struct vo_frame {
int64_t pts;
// Approximate frame duration, in us.
int duration;
// Realtime of estimated previous and next vsync events.
int64_t next_vsync;
int64_t prev_vsync;
// Realtime of estimated distance between 2 vsync events.
int64_t vsync_interval;
// "ideal" display time within the vsync
int64_t vsync_offset;
// how often the frame will be repeated (does not include OSD redraws)

View File

@ -81,7 +81,6 @@ struct mpv_opengl_cb_context {
bool eq_changed;
struct mp_csp_equalizer eq;
int64_t recent_flip;
int64_t approx_vsync;
bool frozen; // libmpv user is not redrawing frames
struct vo *active;
int hwdec_api;
@ -284,16 +283,6 @@ int mpv_opengl_cb_uninit_gl(struct mpv_opengl_cb_context *ctx)
return 0;
}
// needs lock
static int64_t prev_sync(mpv_opengl_cb_context *ctx, int64_t ts)
{
int64_t diff = (int64_t)(ts - ctx->recent_flip);
int64_t offset = diff % ctx->approx_vsync;
if (offset < 0)
offset += ctx->approx_vsync;
return ts - offset;
}
int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h)
{
assert(ctx->renderer);
@ -370,11 +359,6 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h)
if (!frame)
frame = &dummy;
if (ctx->approx_vsync > 0) {
frame->prev_vsync = prev_sync(ctx, mp_time_us());
frame->next_vsync = frame->prev_vsync + ctx->approx_vsync;
}
pthread_mutex_unlock(&ctx->lock);
gl_video_render_frame(ctx->renderer, frame, fbo);
@ -396,10 +380,7 @@ int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int vp_w, int vp_h)
int mpv_opengl_cb_report_flip(mpv_opengl_cb_context *ctx, int64_t time)
{
pthread_mutex_lock(&ctx->lock);
int64_t next = time > 0 ? time : mp_time_us();
if (ctx->recent_flip)
ctx->approx_vsync = next - ctx->recent_flip;
ctx->recent_flip = next;
ctx->recent_flip = time > 0 ? time : mp_time_us();
pthread_mutex_unlock(&ctx->lock);
return 0;