diff options
author | Christoph Heinrich <christoph.heinrich@student.tugraz.at> | 2022-08-03 23:47:07 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-01-09 15:17:09 +0000 |
commit | c4ec47a65e5840643024ba056ba4db20a4300ed2 (patch) | |
tree | 290cb471e55301f374a0607c30b4725c459c5966 /player/video.c | |
parent | 67321b14402838eade127fa1d788a41906129b70 (diff) | |
download | mpv-c4ec47a65e5840643024ba056ba4db20a4300ed2.tar.bz2 mpv-c4ec47a65e5840643024ba056ba4db20a4300ed2.tar.xz |
player: add video-sync=display-tempo
So far there was no way to sync video to display and have audio sync to
video without changes in pitch.
With this option the audio does not get resampled (pitch change) and
instead the corrected audio speed is applied to audio filters.
Diffstat (limited to 'player/video.c')
-rw-r--r-- | player/video.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/player/video.c b/player/video.c index 1ea68f92df..63763d22e5 100644 --- a/player/video.c +++ b/player/video.c @@ -736,12 +736,14 @@ static double compute_audio_drift(struct MPContext *mpctx, double vsync) return (sum_x * sum_y - num * sum_xy) / (sum_x * sum_x - num * sum_xx); } -static void adjust_audio_resample_speed(struct MPContext *mpctx, double vsync) +static void adjust_audio_drift_compensation(struct MPContext *mpctx, double vsync) { struct MPOpts *opts = mpctx->opts; int mode = mpctx->video_out->opts->video_sync; - if (mode != VS_DISP_RESAMPLE || mpctx->audio_status != STATUS_PLAYING) { + if ((mode != VS_DISP_RESAMPLE && mode != VS_DISP_TEMPO) || + mpctx->audio_status != STATUS_PLAYING) + { mpctx->speed_factor_a = mpctx->speed_factor_v; return; } @@ -813,7 +815,8 @@ static void handle_display_sync_frame(struct MPContext *mpctx, bool resample = mode == VS_DISP_RESAMPLE || mode == VS_DISP_RESAMPLE_VDROP || mode == VS_DISP_RESAMPLE_NONE; bool drop = mode == VS_DISP_VDROP || mode == VS_DISP_RESAMPLE || - mode == VS_DISP_ADROP || mode == VS_DISP_RESAMPLE_VDROP; + mode == VS_DISP_ADROP || mode == VS_DISP_RESAMPLE_VDROP || + mode == VS_DISP_TEMPO; drop &= frame->can_drop; if (resample && using_spdif_passthrough(mpctx)) @@ -896,8 +899,8 @@ static void handle_display_sync_frame(struct MPContext *mpctx, mpctx->past_frames[0].num_vsyncs = num_vsyncs; mpctx->past_frames[0].av_diff = mpctx->last_av_difference; - if (resample || mode == VS_DISP_ADROP) { - adjust_audio_resample_speed(mpctx, vsync); + if (resample || mode == VS_DISP_ADROP || mode == VS_DISP_TEMPO) { + adjust_audio_drift_compensation(mpctx, vsync); } else { mpctx->speed_factor_a = 1.0; } |