summaryrefslogtreecommitdiffstats
path: root/player/video.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--player/video.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/player/video.c b/player/video.c
index 48a3165..f0372b6 100644
--- a/player/video.c
+++ b/player/video.c
@@ -120,6 +120,7 @@ void reset_video_state(struct MPContext *mpctx)
mpctx->drop_message_shown = 0;
mpctx->display_sync_drift_dir = 0;
mpctx->display_sync_error = 0;
+ mpctx->display_sync_active = 0;
mpctx->video_status = mpctx->vo_chain ? STATUS_SYNCING : STATUS_EOF;
}
@@ -129,9 +130,9 @@ void uninit_video_out(struct MPContext *mpctx)
uninit_video_chain(mpctx);
if (mpctx->video_out) {
vo_destroy(mpctx->video_out);
+ mpctx->video_out = NULL;
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
}
- mpctx->video_out = NULL;
}
static void vo_chain_uninit(struct vo_chain *vo_c)
@@ -343,10 +344,9 @@ static void adjust_sync(struct MPContext *mpctx, double v_pts, double frame_time
{
struct MPOpts *opts = mpctx->opts;
- if (mpctx->audio_status == STATUS_EOF)
+ if (mpctx->audio_status != STATUS_PLAYING)
return;
- mpctx->delay -= frame_time;
double a_pts = written_audio_pts(mpctx) + opts->audio_delay - mpctx->delay;
double av_delay = a_pts - v_pts;
@@ -388,7 +388,9 @@ static void handle_new_frame(struct MPContext *mpctx)
}
}
mpctx->time_frame += frame_time / mpctx->video_speed;
- if (frame_time)
+ if (mpctx->ao_chain && mpctx->ao_chain->audio_started)
+ mpctx->delay -= frame_time;
+ if (mpctx->video_status >= STATUS_PLAYING)
adjust_sync(mpctx, pts, frame_time);
MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
}
@@ -644,8 +646,9 @@ static void update_av_diff(struct MPContext *mpctx, double offset)
if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
return;
- double a_pos = playing_audio_pts(mpctx);
+ double a_pos = written_audio_pts(mpctx);
if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
+ a_pos -= mpctx->audio_speed * ao_get_delay(mpctx->ao);
mpctx->last_av_difference = a_pos - mpctx->video_pts
+ opts->audio_delay + offset;
}
@@ -1041,19 +1044,6 @@ static void apply_video_crop(struct MPContext *mpctx, struct vo *vo)
}
}
-static bool video_reconfig_needed(const struct mp_image_params *p1,
- const struct mp_image_params *p2)
-{
- return p1->imgfmt != p2->imgfmt ||
- p1->hw_subfmt != p2->hw_subfmt ||
- p1->w != p2->w || p1->h != p2->h ||
- p1->p_w != p2->p_w || p1->p_h != p2->p_h ||
- p1->force_window != p2->force_window ||
- p1->rotate != p2->rotate ||
- p1->stereo3d != p2->stereo3d ||
- !mp_rect_equals(&p1->crop, &p2->crop);
-}
-
void write_video(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
@@ -1176,10 +1166,12 @@ void write_video(struct MPContext *mpctx)
// Filter output is different from VO input?
struct mp_image_params *p = &mpctx->next_frames[0]->params;
- if (!vo->params || video_reconfig_needed(p, vo->params)) {
+ if (!vo->params || !mp_image_params_static_equal(p, vo->params)) {
// Changing config deletes the current frame; wait until it's finished.
- if (vo_still_displaying(vo))
+ if (vo_still_displaying(vo)) {
+ vo_request_wakeup_on_done(vo);
return;
+ }
const struct vo_driver *info = mpctx->video_out->driver;
char extra[20] = {0};
@@ -1257,7 +1249,7 @@ void write_video(struct MPContext *mpctx)
diff /= mpctx->video_speed;
if (mpctx->time_frame < 0)
diff += mpctx->time_frame;
- frame->duration = MPCLAMP(diff, 0, 10) * 1e9;
+ frame->duration = MP_TIME_S_TO_NS(MPCLAMP(diff, 0, 10));
}
mpctx->video_pts = mpctx->next_frames[0]->pts;