From 716285782d5e4b264e18e253e9d58980183c76c6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 15 Jun 2014 20:46:57 +0200 Subject: video/out: change aspects of OSD handling Let the VOs draw the OSD on their own, instead of making OSD drawing a separate VO driver call. Further, let it be the VOs responsibility to request subtitles with the correct PTS. We also basically allow the VO to request OSD/subtitles at any time. OSX changes untested. --- player/main.c | 1 + player/playloop.c | 41 +++++++++-------------------------------- player/screenshot.c | 2 +- player/video.c | 1 + 4 files changed, 12 insertions(+), 33 deletions(-) (limited to 'player') diff --git a/player/main.c b/player/main.c index b7e683ad05..ee78fccbaf 100644 --- a/player/main.c +++ b/player/main.c @@ -435,6 +435,7 @@ int mp_initialize(struct MPContext *mpctx) if (opts->force_vo) { opts->fixed_vo = 1; mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input, + mpctx->osd, mpctx->encode_lavc_ctx); if (!mpctx->video_out) { MP_FATAL(mpctx, "Error opening/initializing " diff --git a/player/playloop.c b/player/playloop.c index c06c40bd73..96326da57c 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -132,26 +132,6 @@ end: mp_notify(mpctx, mpctx->opts->pause ? MPV_EVENT_PAUSE : MPV_EVENT_UNPAUSE, 0); } -static void draw_osd(struct MPContext *mpctx) -{ - struct vo *vo = mpctx->video_out; - - osd_set_vo_pts(mpctx->osd, mpctx->video_pts); - vo_draw_osd(vo, mpctx->osd); -} - -static bool redraw_osd(struct MPContext *mpctx) -{ - struct vo *vo = mpctx->video_out; - if (vo_redraw_frame(vo) < 0) - return false; - - draw_osd(mpctx); - - vo_flip_page(vo, 0, -1); - return true; -} - void add_step_frame(struct MPContext *mpctx, int dir) { if (!mpctx->d_video) @@ -630,13 +610,11 @@ static bool handle_osd_redraw(struct MPContext *mpctx) if (!mpctx->video_out || !mpctx->video_out->config_ok) return false; bool want_redraw = vo_get_want_redraw(mpctx->video_out) | - (osd_query_and_reset_want_redraw(mpctx->osd) && - mpctx->video_out->driver->draw_osd); - if (want_redraw) { - if (redraw_osd(mpctx)) - return true; - } - return false; + osd_query_and_reset_want_redraw(mpctx->osd); + if (!want_redraw) + return false; + vo_redraw(mpctx->video_out); + return true; } static void handle_metadata_update(struct MPContext *mpctx) @@ -890,7 +868,7 @@ void handle_force_window(struct MPContext *mpctx, bool reconfig) .d_w = w, .d_h = h, }; vo_reconfig(vo, &p, 0); - redraw_osd(mpctx); + vo_redraw(vo); mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL); } } @@ -1103,9 +1081,7 @@ void run_playloop(struct MPContext *mpctx) //=================== FLIP PAGE (VIDEO BLT): ====================== - MP_STATS(mpctx, "vo draw frame"); - vo_new_frame_imminent(vo); mpctx->video_pts = mpctx->video_next_pts; mpctx->last_vo_pts = mpctx->video_pts; mpctx->playback_pts = mpctx->video_pts; @@ -1113,8 +1089,9 @@ void run_playloop(struct MPContext *mpctx) update_subtitles(mpctx); update_osd_msg(mpctx); - MP_STATS(mpctx, "draw OSD"); - draw_osd(mpctx); + MP_STATS(mpctx, "vo draw frame"); + + vo_new_frame_imminent(vo); MP_STATS(mpctx, "vo sleep"); diff --git a/player/screenshot.c b/player/screenshot.c index 1c3177cff7..30eceedafc 100644 --- a/player/screenshot.c +++ b/player/screenshot.c @@ -304,7 +304,7 @@ static void add_subs(struct MPContext *mpctx, struct mp_image *image) .display_par = sar / dar, }; - osd_draw_on_image(mpctx->osd, res, osd_get_vo_pts(mpctx->osd), + osd_draw_on_image(mpctx->osd, res, mpctx->video_pts, OSD_DRAW_SUB_ONLY, image); } diff --git a/player/video.c b/player/video.c index 50f0956f1e..e0aeaadf9e 100644 --- a/player/video.c +++ b/player/video.c @@ -187,6 +187,7 @@ int reinit_video_chain(struct MPContext *mpctx) //================== Init VIDEO (codec & libvo) ========================== if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) { mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input, + mpctx->osd, mpctx->encode_lavc_ctx); if (!mpctx->video_out) { MP_FATAL(mpctx, "Error opening/initializing " -- cgit v1.2.3