vo: add frame vsync and vsync duration

Relative to frame PTS timeline as oposed to display vblank.

Those values are relative to unadjusted video timeline. They will be
used by gpu-next where it expect virtual frame vsync, not display vblank
time.
This commit is contained in:
Kacper Michajłow 2023-11-10 22:37:52 +01:00 committed by Dudemanguy
parent 332619042f
commit 5e5a32534a
3 changed files with 9 additions and 2 deletions

View File

@ -834,8 +834,8 @@ static void handle_display_sync_frame(struct MPContext *mpctx,
if (vsync <= 0)
return;
double adjusted_duration = MPMAX(0, mpctx->past_frames[0].approx_duration);
adjusted_duration /= opts->playback_speed;
double approx_duration = MPMAX(0, mpctx->past_frames[0].approx_duration);
double adjusted_duration = approx_duration / opts->playback_speed;
if (adjusted_duration > 0.5)
return;
@ -919,6 +919,8 @@ static void handle_display_sync_frame(struct MPContext *mpctx,
frame->vsync_interval = vsync;
frame->vsync_offset = -prev_error;
frame->ideal_frame_duration = frame_duration;
frame->ideal_frame_vsync = (-prev_error / frame_duration) * approx_duration;
frame->ideal_frame_vsync_duration = approx_duration / num_vsyncs;
frame->num_vsyncs = num_vsyncs;
frame->display_synced = true;

View File

@ -898,6 +898,7 @@ static bool render_frame(struct vo *vo)
in->current_frame->repeat = true;
if (frame->display_synced) {
in->current_frame->vsync_offset += in->current_frame->vsync_interval;
in->current_frame->ideal_frame_vsync += in->current_frame->ideal_frame_vsync_duration;
in->dropped_frame |= in->current_frame->num_vsyncs < 1;
}
if (in->current_frame->num_vsyncs > 0)

View File

@ -218,6 +218,10 @@ struct vo_frame {
// "ideal" frame duration (can be different from num_vsyncs*vsync_interval
// up to a vsync) - valid for the entire frame, i.e. not changed for repeats
double ideal_frame_duration;
// "ideal" frame vsync point relative to the pts
double ideal_frame_vsync;
// "ideal" frame duration relative to the pts
double ideal_frame_vsync_duration;
// how often the frame will be repeated (does not include OSD redraws)
int num_vsyncs;
// Set if the current frame is repeated from the previous. It's guaranteed