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.
This commit is contained in:
wm4
2014-06-15 20:46:57 +02:00
parent d88aca6fb2
commit 716285782d
25 changed files with 129 additions and 188 deletions

View File

@@ -435,6 +435,7 @@ int mp_initialize(struct MPContext *mpctx)
if (opts->force_vo) { if (opts->force_vo) {
opts->fixed_vo = 1; opts->fixed_vo = 1;
mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input, mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input,
mpctx->osd,
mpctx->encode_lavc_ctx); mpctx->encode_lavc_ctx);
if (!mpctx->video_out) { if (!mpctx->video_out) {
MP_FATAL(mpctx, "Error opening/initializing " MP_FATAL(mpctx, "Error opening/initializing "

View File

@@ -132,26 +132,6 @@ end:
mp_notify(mpctx, mpctx->opts->pause ? MPV_EVENT_PAUSE : MPV_EVENT_UNPAUSE, 0); 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) void add_step_frame(struct MPContext *mpctx, int dir)
{ {
if (!mpctx->d_video) 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) if (!mpctx->video_out || !mpctx->video_out->config_ok)
return false; return false;
bool want_redraw = vo_get_want_redraw(mpctx->video_out) | bool want_redraw = vo_get_want_redraw(mpctx->video_out) |
(osd_query_and_reset_want_redraw(mpctx->osd) && osd_query_and_reset_want_redraw(mpctx->osd);
mpctx->video_out->driver->draw_osd); if (!want_redraw)
if (want_redraw) { return false;
if (redraw_osd(mpctx)) vo_redraw(mpctx->video_out);
return true; return true;
}
return false;
} }
static void handle_metadata_update(struct MPContext *mpctx) 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, .d_w = w, .d_h = h,
}; };
vo_reconfig(vo, &p, 0); vo_reconfig(vo, &p, 0);
redraw_osd(mpctx); vo_redraw(vo);
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL); mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
} }
} }
@@ -1103,9 +1081,7 @@ void run_playloop(struct MPContext *mpctx)
//=================== FLIP PAGE (VIDEO BLT): ====================== //=================== FLIP PAGE (VIDEO BLT): ======================
MP_STATS(mpctx, "vo draw frame");
vo_new_frame_imminent(vo);
mpctx->video_pts = mpctx->video_next_pts; mpctx->video_pts = mpctx->video_next_pts;
mpctx->last_vo_pts = mpctx->video_pts; mpctx->last_vo_pts = mpctx->video_pts;
mpctx->playback_pts = mpctx->video_pts; mpctx->playback_pts = mpctx->video_pts;
@@ -1113,8 +1089,9 @@ void run_playloop(struct MPContext *mpctx)
update_subtitles(mpctx); update_subtitles(mpctx);
update_osd_msg(mpctx); update_osd_msg(mpctx);
MP_STATS(mpctx, "draw OSD"); MP_STATS(mpctx, "vo draw frame");
draw_osd(mpctx);
vo_new_frame_imminent(vo);
MP_STATS(mpctx, "vo sleep"); MP_STATS(mpctx, "vo sleep");

View File

@@ -304,7 +304,7 @@ static void add_subs(struct MPContext *mpctx, struct mp_image *image)
.display_par = sar / dar, .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); OSD_DRAW_SUB_ONLY, image);
} }

View File

@@ -187,6 +187,7 @@ int reinit_video_chain(struct MPContext *mpctx)
//================== Init VIDEO (codec & libvo) ========================== //================== Init VIDEO (codec & libvo) ==========================
if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) { if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) {
mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input, mpctx->video_out = init_best_video_out(mpctx->global, mpctx->input,
mpctx->osd,
mpctx->encode_lavc_ctx); mpctx->encode_lavc_ctx);
if (!mpctx->video_out) { if (!mpctx->video_out) {
MP_FATAL(mpctx, "Error opening/initializing " MP_FATAL(mpctx, "Error opening/initializing "

View File

@@ -423,21 +423,6 @@ bool osd_query_and_reset_want_redraw(struct osd_state *osd)
return r; return r;
} }
double osd_get_vo_pts(struct osd_state *osd)
{
pthread_mutex_lock(&osd->lock);
double r = osd->vo_pts;
pthread_mutex_unlock(&osd->lock);
return r;
}
void osd_set_vo_pts(struct osd_state *osd, double vo_pts)
{
pthread_mutex_lock(&osd->lock);
osd->vo_pts = vo_pts;
pthread_mutex_unlock(&osd->lock);
}
// Scale factor to translate OSD coordinates to what the obj uses internally. // Scale factor to translate OSD coordinates to what the obj uses internally.
// osd_coordinates * (sw, sh) = obj_coordinates // osd_coordinates * (sw, sh) = obj_coordinates
void osd_object_get_scale_factor(struct osd_state *osd, int obj, void osd_object_get_scale_factor(struct osd_state *osd, int obj,

View File

@@ -149,9 +149,6 @@ void osd_free(struct osd_state *osd);
bool osd_query_and_reset_want_redraw(struct osd_state *osd); bool osd_query_and_reset_want_redraw(struct osd_state *osd);
double osd_get_vo_pts(struct osd_state *osd);
void osd_set_vo_pts(struct osd_state *osd, double vo_pts);
void osd_set_text(struct osd_state *osd, int obj, const char *text); void osd_set_text(struct osd_state *osd, int obj, const char *text);
struct osd_sub_state { struct osd_sub_state {

View File

@@ -52,8 +52,6 @@ struct osd_state {
struct osd_object *objs[MAX_OSD_PARTS]; struct osd_object *objs[MAX_OSD_PARTS];
double vo_pts;
bool render_subs_in_filter; bool render_subs_in_filter;
bool want_redraw; bool want_redraw;

View File

@@ -47,7 +47,7 @@ static const struct osd_fmt_entry osd_to_gl_legacy_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_RGBA] = {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE}, [SUBBITMAP_RGBA] = {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
}; };
struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, bool legacy) struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd)
{ {
GLint max_texture_size; GLint max_texture_size;
gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
@@ -55,8 +55,9 @@ struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, bool legacy)
struct mpgl_osd *ctx = talloc_ptrtype(NULL, ctx); struct mpgl_osd *ctx = talloc_ptrtype(NULL, ctx);
*ctx = (struct mpgl_osd) { *ctx = (struct mpgl_osd) {
.log = log, .log = log,
.osd = osd,
.gl = gl, .gl = gl,
.fmt_table = legacy ? osd_to_gl_legacy_formats : osd_to_gl3_formats, .fmt_table = osd_to_gl3_formats,
.scratch = talloc_zero_size(ctx, 1), .scratch = talloc_zero_size(ctx, 1),
}; };
@@ -79,6 +80,9 @@ struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, bool legacy)
void mpgl_osd_destroy(struct mpgl_osd *ctx) void mpgl_osd_destroy(struct mpgl_osd *ctx)
{ {
if (!ctx)
return;
GL *gl = ctx->gl; GL *gl = ctx->gl;
for (int n = 0; n < MAX_OSD_PARTS; n++) { for (int n = 0; n < MAX_OSD_PARTS; n++) {
@@ -274,7 +278,7 @@ static void draw_cb(void *pctx, struct sub_bitmaps *imgs)
} }
void mpgl_osd_draw_cb(struct mpgl_osd *ctx, void mpgl_osd_draw_cb(struct mpgl_osd *ctx,
struct osd_state *osd, double pts,
struct mp_osd_res res, struct mp_osd_res res,
void (*cb)(void *ctx, struct mpgl_osd_part *part, void (*cb)(void *ctx, struct mpgl_osd_part *part,
struct sub_bitmaps *imgs), struct sub_bitmaps *imgs),
@@ -282,7 +286,7 @@ void mpgl_osd_draw_cb(struct mpgl_osd *ctx,
{ {
struct draw_cb_closure c = {ctx, cb, cb_ctx}; struct draw_cb_closure c = {ctx, cb, cb_ctx};
reset(ctx); reset(ctx);
osd_draw(osd, res, osd_get_vo_pts(osd), 0, ctx->formats, draw_cb, &c); osd_draw(ctx->osd, res, pts, 0, ctx->formats, draw_cb, &c);
} }
void mpgl_osd_redraw_cb(struct mpgl_osd *ctx, void mpgl_osd_redraw_cb(struct mpgl_osd *ctx,
@@ -373,8 +377,11 @@ static void draw_legacy_cb(void *pctx, struct sub_bitmaps *imgs)
gl->DisableClientState(GL_COLOR_ARRAY); gl->DisableClientState(GL_COLOR_ARRAY);
} }
void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct osd_state *osd, void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, double pts,
struct mp_osd_res res) struct mp_osd_res res)
{ {
osd_draw(osd, res, osd_get_vo_pts(osd), 0, ctx->formats, draw_legacy_cb, ctx); ctx->fmt_table = osd_to_gl_legacy_formats;
for (int n = 0; n < SUBBITMAP_COUNT; n++)
ctx->formats[n] = ctx->fmt_table[n].type != 0;
osd_draw(ctx->osd, res, pts, 0, ctx->formats, draw_legacy_cb, ctx);
} }

View File

@@ -21,6 +21,7 @@ struct mpgl_osd_part {
struct mpgl_osd { struct mpgl_osd {
struct mp_log *log; struct mp_log *log;
struct osd_state *osd;
GL *gl; GL *gl;
bool use_pbo; bool use_pbo;
bool scaled; bool scaled;
@@ -30,16 +31,16 @@ struct mpgl_osd {
void *scratch; void *scratch;
}; };
struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, bool legacy); struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd);
void mpgl_osd_destroy(struct mpgl_osd *ctx); void mpgl_osd_destroy(struct mpgl_osd *ctx);
void mpgl_osd_set_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p); void mpgl_osd_set_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p);
void mpgl_osd_unset_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p); void mpgl_osd_unset_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p);
void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct osd_state *osd, void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, double pts,
struct mp_osd_res res); struct mp_osd_res res);
void mpgl_osd_draw_cb(struct mpgl_osd *ctx, void mpgl_osd_draw_cb(struct mpgl_osd *ctx,
struct osd_state *osd, double pts,
struct mp_osd_res res, struct mp_osd_res res,
void (*cb)(void *ctx, struct mpgl_osd_part *part, void (*cb)(void *ctx, struct mpgl_osd_part *part,
struct sub_bitmaps *imgs), struct sub_bitmaps *imgs),

View File

@@ -153,7 +153,9 @@ struct gl_video {
GLuint osd_programs[SUBBITMAP_COUNT]; GLuint osd_programs[SUBBITMAP_COUNT];
GLuint indirect_program, scale_sep_program, final_program; GLuint indirect_program, scale_sep_program, final_program;
struct osd_state *osd_state;
struct mpgl_osd *osd; struct mpgl_osd *osd;
double osd_pts;
GLuint lut_3d_texture; GLuint lut_3d_texture;
bool use_lut_3d; bool use_lut_3d;
@@ -1157,7 +1159,7 @@ static void recreate_osd(struct gl_video *p)
{ {
if (p->osd) if (p->osd)
mpgl_osd_destroy(p->osd); mpgl_osd_destroy(p->osd);
p->osd = mpgl_osd_init(p->gl, p->log, false); p->osd = mpgl_osd_init(p->gl, p->log, p->osd_state);
p->osd->use_pbo = p->opts.pbo; p->osd->use_pbo = p->opts.pbo;
} }
@@ -1710,6 +1712,8 @@ void gl_video_upload_image(struct gl_video *p, struct mp_image *mpi)
struct video_image *vimg = &p->image; struct video_image *vimg = &p->image;
p->osd_pts = mpi->pts;
if (p->hwdec_active) { if (p->hwdec_active) {
mp_image_setrefp(&vimg->hwimage, mpi); mp_image_setrefp(&vimg->hwimage, mpi);
p->have_image = true; p->have_image = true;
@@ -1833,12 +1837,12 @@ static void draw_osd_cb(void *ctx, struct mpgl_osd_part *osd,
debug_check_gl(p, "after drawing osd"); debug_check_gl(p, "after drawing osd");
} }
void gl_video_draw_osd(struct gl_video *p, struct osd_state *osd) void gl_video_draw_osd(struct gl_video *p)
{ {
GL *gl = p->gl; GL *gl = p->gl;
assert(p->osd); assert(p->osd);
mpgl_osd_draw_cb(p->osd, osd, p->osd_rect, draw_osd_cb, p); mpgl_osd_draw_cb(p->osd, p->osd_pts, p->osd_rect, draw_osd_cb, p);
// The playloop calls this last before waiting some time until it decides // The playloop calls this last before waiting some time until it decides
// to call flip_page(). Tell OpenGL to start execution of the GPU commands // to call flip_page(). Tell OpenGL to start execution of the GPU commands
@@ -2201,12 +2205,13 @@ void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b)
p->depth_g = g; p->depth_g = g;
} }
struct gl_video *gl_video_init(GL *gl, struct mp_log *log) struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd)
{ {
struct gl_video *p = talloc_ptrtype(NULL, p); struct gl_video *p = talloc_ptrtype(NULL, p);
*p = (struct gl_video) { *p = (struct gl_video) {
.gl = gl, .gl = gl,
.log = log, .log = log,
.osd_state = osd,
.opts = gl_video_opts_def, .opts = gl_video_opts_def,
.gl_target = GL_TEXTURE_2D, .gl_target = GL_TEXTURE_2D,
.gl_debug = true, .gl_debug = true,

View File

@@ -55,14 +55,14 @@ extern const struct gl_video_opts gl_video_opts_hq_def;
struct gl_video; struct gl_video;
struct gl_video *gl_video_init(GL *gl, struct mp_log *log); struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd);
void gl_video_uninit(struct gl_video *p); void gl_video_uninit(struct gl_video *p);
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts); void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
bool gl_video_check_format(struct gl_video *p, int mp_format); bool gl_video_check_format(struct gl_video *p, int mp_format);
void gl_video_config(struct gl_video *p, struct mp_image_params *params); void gl_video_config(struct gl_video *p, struct mp_image_params *params);
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b); void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b);
void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d); void gl_video_set_lut3d(struct gl_video *p, struct lut3d *lut3d);
void gl_video_draw_osd(struct gl_video *p, struct osd_state *osd); void gl_video_draw_osd(struct gl_video *p);
void gl_video_upload_image(struct gl_video *p, struct mp_image *img); void gl_video_upload_image(struct gl_video *p, struct mp_image *img);
void gl_video_render_frame(struct gl_video *p); void gl_video_render_frame(struct gl_video *p);
struct mp_image *gl_video_download_image(struct gl_video *p); struct mp_image *gl_video_download_image(struct gl_video *p);

View File

@@ -152,7 +152,7 @@ static int event_fd_callback(void *ctx, int fd)
} }
static struct vo *vo_create(struct mpv_global *global, static struct vo *vo_create(struct mpv_global *global,
struct input_ctx *input_ctx, struct input_ctx *input_ctx, struct osd_state *osd,
struct encode_lavc_context *encode_lavc_ctx, struct encode_lavc_context *encode_lavc_ctx,
char *name, char **args) char *name, char **args)
{ {
@@ -171,6 +171,7 @@ static struct vo *vo_create(struct mpv_global *global,
.global = global, .global = global,
.encode_lavc_ctx = encode_lavc_ctx, .encode_lavc_ctx = encode_lavc_ctx,
.input_ctx = input_ctx, .input_ctx = input_ctx,
.osd = osd,
.event_fd = -1, .event_fd = -1,
.monitor_par = 1, .monitor_par = 1,
.max_video_queue = 1, .max_video_queue = 1,
@@ -198,6 +199,7 @@ error:
struct vo *init_best_video_out(struct mpv_global *global, struct vo *init_best_video_out(struct mpv_global *global,
struct input_ctx *input_ctx, struct input_ctx *input_ctx,
struct osd_state *osd,
struct encode_lavc_context *encode_lavc_ctx) struct encode_lavc_context *encode_lavc_ctx)
{ {
struct m_obj_settings *vo_list = global->opts->vo.video_driver_list; struct m_obj_settings *vo_list = global->opts->vo.video_driver_list;
@@ -207,7 +209,7 @@ struct vo *init_best_video_out(struct mpv_global *global,
// Something like "-vo name," allows fallback to autoprobing. // Something like "-vo name," allows fallback to autoprobing.
if (strlen(vo_list[n].name) == 0) if (strlen(vo_list[n].name) == 0)
goto autoprobe; goto autoprobe;
struct vo *vo = vo_create(global, input_ctx, encode_lavc_ctx, struct vo *vo = vo_create(global, input_ctx, osd, encode_lavc_ctx,
vo_list[n].name, vo_list[n].attribs); vo_list[n].name, vo_list[n].attribs);
if (vo) if (vo)
return vo; return vo;
@@ -217,7 +219,7 @@ struct vo *init_best_video_out(struct mpv_global *global,
autoprobe: autoprobe:
// now try the rest... // now try the rest...
for (int i = 0; video_out_drivers[i]; i++) { for (int i = 0; video_out_drivers[i]; i++) {
struct vo *vo = vo_create(global, input_ctx, encode_lavc_ctx, struct vo *vo = vo_create(global, input_ctx, osd, encode_lavc_ctx,
(char *)video_out_drivers[i]->name, NULL); (char *)video_out_drivers[i]->name, NULL);
if (vo) if (vo)
return vo; return vo;
@@ -321,15 +323,6 @@ double vo_get_next_pts(struct vo *vo, int index)
return vo->video_queue[index]->pts; return vo->video_queue[index]->pts;
} }
int vo_redraw_frame(struct vo *vo)
{
if (vo->config_ok && vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) {
vo->want_redraw = false;
return 0;
}
return -1;
}
bool vo_get_want_redraw(struct vo *vo) bool vo_get_want_redraw(struct vo *vo)
{ {
return vo->config_ok && vo->want_redraw; return vo->config_ok && vo->want_redraw;
@@ -354,12 +347,6 @@ void vo_new_frame_imminent(struct vo *vo)
vo->hasframe = true; vo->hasframe = true;
} }
void vo_draw_osd(struct vo *vo, struct osd_state *osd)
{
if (vo->config_ok && vo->driver->draw_osd)
vo->driver->draw_osd(vo, osd);
}
void vo_flip_page(struct vo *vo, int64_t pts_us, int duration) void vo_flip_page(struct vo *vo, int64_t pts_us, int duration)
{ {
if (!vo->config_ok) if (!vo->config_ok)
@@ -371,6 +358,13 @@ void vo_flip_page(struct vo *vo, int64_t pts_us, int duration)
vo->driver->flip_page(vo); vo->driver->flip_page(vo);
} }
void vo_redraw(struct vo *vo)
{
vo->want_redraw = false;
if (vo->config_ok && vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true)
vo_flip_page(vo, 0, -1);
}
void vo_check_events(struct vo *vo) void vo_check_events(struct vo *vo)
{ {
vo_control(vo, VOCTRL_CHECK_EVENTS, NULL); vo_control(vo, VOCTRL_CHECK_EVENTS, NULL);

View File

@@ -54,6 +54,9 @@ enum mp_voctrl {
/* for hardware decoding */ /* for hardware decoding */
VOCTRL_GET_HWDEC_INFO, // struct mp_hwdec_info* VOCTRL_GET_HWDEC_INFO, // struct mp_hwdec_info*
// Redraw the image previously passed to draw_image() (basically, repeat
// the previous draw_image call). If this is handled, the OSD should also
// be updated and redrawn.
VOCTRL_REDRAW_FRAME, VOCTRL_REDRAW_FRAME,
VOCTRL_ONTOP, VOCTRL_ONTOP,
@@ -193,14 +196,11 @@ struct vo_driver {
* followed by a draw_osd and a flip_page[_timed] call. * followed by a draw_osd and a flip_page[_timed] call.
* mpi belongs to the caller; if the VO needs it longer, it has to create * mpi belongs to the caller; if the VO needs it longer, it has to create
* a new reference to mpi. * a new reference to mpi.
*
* This also should draw the OSD.
*/ */
void (*draw_image)(struct vo *vo, struct mp_image *mpi); void (*draw_image)(struct vo *vo, struct mp_image *mpi);
/*
* Draws OSD to the screen buffer
*/
void (*draw_osd)(struct vo *vo, struct osd_state *osd);
/* /*
* Blit/Flip buffer to the screen. Must be called after each frame! * Blit/Flip buffer to the screen. Must be called after each frame!
* pts_us is the frame presentation time, linked to mp_time_us(). * pts_us is the frame presentation time, linked to mp_time_us().
@@ -256,6 +256,7 @@ struct vo {
struct vo_wayland_state *wayland; struct vo_wayland_state *wayland;
struct encode_lavc_context *encode_lavc_ctx; struct encode_lavc_context *encode_lavc_ctx;
struct input_ctx *input_ctx; struct input_ctx *input_ctx;
struct osd_state *osd;
int event_fd; // check_events() should be called when this has input int event_fd; // check_events() should be called when this has input
// current window state // current window state
@@ -269,19 +270,19 @@ struct vo {
struct mpv_global; struct mpv_global;
struct vo *init_best_video_out(struct mpv_global *global, struct vo *init_best_video_out(struct mpv_global *global,
struct input_ctx *input_ctx, struct input_ctx *input_ctx,
struct osd_state *osd,
struct encode_lavc_context *encode_lavc_ctx); struct encode_lavc_context *encode_lavc_ctx);
int vo_reconfig(struct vo *vo, struct mp_image_params *p, int flags); int vo_reconfig(struct vo *vo, struct mp_image_params *p, int flags);
int vo_control(struct vo *vo, uint32_t request, void *data); int vo_control(struct vo *vo, uint32_t request, void *data);
void vo_queue_image(struct vo *vo, struct mp_image *mpi); void vo_queue_image(struct vo *vo, struct mp_image *mpi);
int vo_redraw_frame(struct vo *vo);
bool vo_get_want_redraw(struct vo *vo); bool vo_get_want_redraw(struct vo *vo);
bool vo_has_next_frame(struct vo *vo, bool eof); bool vo_has_next_frame(struct vo *vo, bool eof);
double vo_get_next_pts(struct vo *vo, int index); double vo_get_next_pts(struct vo *vo, int index);
bool vo_needs_new_image(struct vo *vo); bool vo_needs_new_image(struct vo *vo);
void vo_new_frame_imminent(struct vo *vo); void vo_new_frame_imminent(struct vo *vo);
void vo_draw_osd(struct vo *vo, struct osd_state *osd);
void vo_flip_page(struct vo *vo, int64_t pts_us, int duration); void vo_flip_page(struct vo *vo, int64_t pts_us, int duration);
void vo_redraw(struct vo *vo);
void vo_check_events(struct vo *vo); void vo_check_events(struct vo *vo);
void vo_seek_reset(struct vo *vo); void vo_seek_reset(struct vo *vo);
void vo_destroy(struct vo *vo); void vo_destroy(struct vo *vo);

View File

@@ -93,6 +93,7 @@ struct priv {
struct quad *quad; struct quad *quad;
struct mpgl_osd *osd; struct mpgl_osd *osd;
double vo_pts;
// functions to to deal with the the OpenGL texture for containing the // functions to to deal with the the OpenGL texture for containing the
// video frame (behaviour changes depending on the rendering path). // video frame (behaviour changes depending on the rendering path).
@@ -129,7 +130,7 @@ static int init_gl(struct vo *vo, uint32_t d_width, uint32_t d_height)
gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (!p->osd) if (!p->osd)
p->osd = mpgl_osd_init(gl, vo->log, true); p->osd = mpgl_osd_init(gl, vo->log, vo->osd);
resize(vo); resize(vo);
@@ -179,6 +180,8 @@ static void do_render(struct vo *vo)
gl->End(); gl->End();
p->fns.unbind_texture(vo); p->fns.unbind_texture(vo);
mpgl_osd_draw_legacy(p->osd, p->vo_pts, p->osd_res);
} }
static void flip_page(struct vo *vo) static void flip_page(struct vo *vo)
@@ -191,6 +194,7 @@ static void flip_page(struct vo *vo)
static void draw_image(struct vo *vo, struct mp_image *mpi) static void draw_image(struct vo *vo, struct mp_image *mpi)
{ {
struct priv *p = vo->priv; struct priv *p = vo->priv;
p->vo_pts = mpi->pts;
p->fns.prepare_texture(vo, mpi); p->fns.prepare_texture(vo, mpi);
do_render(vo); do_render(vo);
} }
@@ -198,8 +202,7 @@ static void draw_image(struct vo *vo, struct mp_image *mpi)
static void uninit(struct vo *vo) static void uninit(struct vo *vo)
{ {
struct priv *p = vo->priv; struct priv *p = vo->priv;
if (p->osd) mpgl_osd_destroy(p->osd);
mpgl_osd_destroy(p->osd);
p->fns.uninit(vo); p->fns.uninit(vo);
mpgl_uninit(p->mpglctx); mpgl_uninit(p->mpglctx);
} }
@@ -217,14 +220,6 @@ static int preinit(struct vo *vo)
return 0; return 0;
} }
static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct priv *p = vo->priv;
assert(p->osd);
mpgl_osd_draw_legacy(p->osd, osd, p->osd_res);
}
static CFStringRef get_cv_csp_matrix(enum mp_csp format) static CFStringRef get_cv_csp_matrix(enum mp_csp format)
{ {
switch (format) { switch (format) {
@@ -569,7 +564,6 @@ const struct vo_driver video_out_corevideo = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(struct priv), .priv_size = sizeof(struct priv),

View File

@@ -131,6 +131,7 @@ typedef struct d3d_priv {
struct vo *vo; struct vo *vo;
bool have_image; bool have_image;
double osd_pts;
D3DLOCKED_RECT locked_rect; /**< The locked offscreen surface */ D3DLOCKED_RECT locked_rect; /**< The locked offscreen surface */
RECT fs_movie_rect; /**< Rect (upscaled) of the movie when displayed RECT fs_movie_rect; /**< Rect (upscaled) of the movie when displayed
@@ -233,7 +234,7 @@ static void uninit(struct vo *vo);
static void flip_page(struct vo *vo); static void flip_page(struct vo *vo);
static mp_image_t *get_screenshot(d3d_priv *priv); static mp_image_t *get_screenshot(d3d_priv *priv);
static mp_image_t *get_window_screenshot(d3d_priv *priv); static mp_image_t *get_window_screenshot(d3d_priv *priv);
static void draw_osd(struct vo *vo);
static void d3d_matrix_identity(D3DMATRIX *m) static void d3d_matrix_identity(D3DMATRIX *m)
{ {
@@ -911,6 +912,8 @@ static uint32_t d3d_draw_frame(d3d_priv *priv)
} }
} }
draw_osd(priv->vo);
return VO_TRUE; return VO_TRUE;
} }
@@ -1411,6 +1414,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
} }
priv->have_image = true; priv->have_image = true;
priv->osd_pts = mpi->pts;
d3d_draw_frame(priv); d3d_draw_frame(priv);
} }
@@ -1685,13 +1689,13 @@ static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs)
} }
static void draw_osd(struct vo *vo, struct osd_state *osd) static void draw_osd(struct vo *vo)
{ {
d3d_priv *priv = vo->priv; d3d_priv *priv = vo->priv;
if (!priv->d3d_device) if (!priv->d3d_device)
return; return;
osd_draw(osd, priv->osd_res, osd_get_vo_pts(osd), 0, osd_fmt_supported, osd_draw(vo->osd, priv->osd_res, priv->osd_pts, 0, osd_fmt_supported,
draw_osd_cb, priv); draw_osd_cb, priv);
} }
@@ -1729,7 +1733,6 @@ const struct vo_driver video_out_direct3d = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(d3d_priv), .priv_size = sizeof(d3d_priv),
@@ -1745,7 +1748,6 @@ const struct vo_driver video_out_direct3d_shaders = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(d3d_priv), .priv_size = sizeof(d3d_priv),

View File

@@ -77,14 +77,9 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
struct priv *p = vo->priv; struct priv *p = vo->priv;
mp_image_setrefp(&p->current, mpi); mp_image_setrefp(&p->current, mpi);
}
static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct priv *p = vo->priv;
struct mp_osd_res dim = osd_res_from_image_params(vo->params); struct mp_osd_res dim = osd_res_from_image_params(vo->params);
osd_draw_on_image(osd, dim, osd_get_vo_pts(osd), OSD_DRAW_SUB_ONLY, p->current); osd_draw_on_image(vo->osd, dim, mpi->pts, OSD_DRAW_SUB_ONLY, p->current);
} }
static void flip_page(struct vo *vo) static void flip_page(struct vo *vo)
@@ -152,7 +147,6 @@ const struct vo_driver video_out_image =
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
}; };

View File

@@ -486,8 +486,15 @@ static void draw_image_unlocked(struct vo *vo, mp_image_t *mpi)
static void draw_image(struct vo *vo, mp_image_t *mpi) static void draw_image(struct vo *vo, mp_image_t *mpi)
{ {
struct priv *vc = vo->priv;
pthread_mutex_lock(&vo->encode_lavc_ctx->lock); pthread_mutex_lock(&vo->encode_lavc_ctx->lock);
draw_image_unlocked(vo, mpi); draw_image_unlocked(vo, mpi);
if (vc->lastimg && vc->lastimg_wants_osd && vo->params) {
struct mp_osd_res dim = osd_res_from_image_params(vo->params);
osd_draw_on_image(vo->osd, dim, mpi->pts, OSD_DRAW_SUB_ONLY,
vc->lastimg);
}
pthread_mutex_unlock(&vo->encode_lavc_ctx->lock); pthread_mutex_unlock(&vo->encode_lavc_ctx->lock);
} }
@@ -495,22 +502,6 @@ static void flip_page_timed(struct vo *vo, int64_t pts_us, int duration)
{ {
} }
static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct priv *vc = vo->priv;
pthread_mutex_lock(&vo->encode_lavc_ctx->lock);
if (vc->lastimg && vc->lastimg_wants_osd && vo->params) {
struct mp_osd_res dim = osd_res_from_image_params(vo->params);
osd_draw_on_image(osd, dim, osd_get_vo_pts(osd), OSD_DRAW_SUB_ONLY,
vc->lastimg);
}
pthread_mutex_unlock(&vo->encode_lavc_ctx->lock);
}
static int control(struct vo *vo, uint32_t request, void *data) static int control(struct vo *vo, uint32_t request, void *data)
{ {
struct priv *vc = vo->priv; struct priv *vc = vo->priv;
@@ -536,7 +527,6 @@ const struct vo_driver video_out_lavc = {
.control = control, .control = control,
.uninit = uninit, .uninit = uninit,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page_timed = flip_page_timed, .flip_page_timed = flip_page_timed,
}; };

View File

@@ -111,17 +111,6 @@ static void flip_page(struct vo *vo)
mpgl_unlock(p->glctx); mpgl_unlock(p->glctx);
} }
static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct gl_priv *p = vo->priv;
mpgl_lock(p->glctx);
gl_video_draw_osd(p->renderer, osd);
mpgl_unlock(p->glctx);
}
static void draw_image(struct vo *vo, mp_image_t *mpi) static void draw_image(struct vo *vo, mp_image_t *mpi)
{ {
struct gl_priv *p = vo->priv; struct gl_priv *p = vo->priv;
@@ -132,6 +121,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
mpgl_lock(p->glctx); mpgl_lock(p->glctx);
gl_video_upload_image(p->renderer, mpi); gl_video_upload_image(p->renderer, mpi);
gl_video_render_frame(p->renderer); gl_video_render_frame(p->renderer);
gl_video_draw_osd(p->renderer);
mpgl_unlock(p->glctx); mpgl_unlock(p->glctx);
} }
@@ -380,6 +370,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_REDRAW_FRAME: case VOCTRL_REDRAW_FRAME:
mpgl_lock(p->glctx); mpgl_lock(p->glctx);
gl_video_render_frame(p->renderer); gl_video_render_frame(p->renderer);
gl_video_draw_osd(p->renderer);
mpgl_unlock(p->glctx); mpgl_unlock(p->glctx);
return true; return true;
case VOCTRL_SET_COMMAND_LINE: { case VOCTRL_SET_COMMAND_LINE: {
@@ -434,7 +425,7 @@ static int preinit(struct vo *vo)
if (p->gl->SwapInterval) if (p->gl->SwapInterval)
p->gl->SwapInterval(p->swap_interval); p->gl->SwapInterval(p->swap_interval);
p->renderer = gl_video_init(p->gl, vo->log); p->renderer = gl_video_init(p->gl, vo->log, vo->osd);
gl_video_set_output_depth(p->renderer, p->glctx->depth_r, p->glctx->depth_g, gl_video_set_output_depth(p->renderer, p->glctx->depth_r, p->glctx->depth_g,
p->glctx->depth_b); p->glctx->depth_b);
gl_video_set_options(p->renderer, p->renderer_opts); gl_video_set_options(p->renderer, p->renderer_opts);
@@ -474,7 +465,6 @@ const struct vo_driver video_out_opengl = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(struct gl_priv), .priv_size = sizeof(struct gl_priv),
@@ -490,7 +480,6 @@ const struct vo_driver video_out_opengl_hq = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(struct gl_priv), .priv_size = sizeof(struct gl_priv),

View File

@@ -59,6 +59,7 @@ struct gl_priv {
int scaled_osd; int scaled_osd;
struct mpgl_osd *osd; struct mpgl_osd *osd;
int osd_color; int osd_color;
double osd_pts;
int use_ycbcr; int use_ycbcr;
int use_yuv; int use_yuv;
@@ -1451,7 +1452,7 @@ static void update_yuvconv(struct vo *vo)
} }
} }
static void draw_osd(struct vo *vo, struct osd_state *osd) static void draw_osd(struct vo *vo)
{ {
struct gl_priv *p = vo->priv; struct gl_priv *p = vo->priv;
GL *gl = p->gl; GL *gl = p->gl;
@@ -1475,7 +1476,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
gl->Color4ub((p->osd_color >> 16) & 0xff, (p->osd_color >> 8) & 0xff, gl->Color4ub((p->osd_color >> 16) & 0xff, (p->osd_color >> 8) & 0xff,
p->osd_color & 0xff, 0xff - (p->osd_color >> 24)); p->osd_color & 0xff, 0xff - (p->osd_color >> 24));
mpgl_osd_draw_legacy(p->osd, osd, res); mpgl_osd_draw_legacy(p->osd, p->osd_pts, res);
if (p->scaled_osd) if (p->scaled_osd)
gl->PopMatrix(); gl->PopMatrix();
@@ -1686,7 +1687,7 @@ static int initGl(struct vo *vo, uint32_t d_width, uint32_t d_height)
} }
if (gl->BindTexture) { if (gl->BindTexture) {
p->osd = mpgl_osd_init(gl, vo->log, true); p->osd = mpgl_osd_init(gl, vo->log, vo->osd);
p->osd->scaled = p->scaled_osd; p->osd->scaled = p->scaled_osd;
} }
@@ -1782,6 +1783,8 @@ static void do_render(struct vo *vo)
} }
if (p->is_yuv || p->custom_prog) if (p->is_yuv || p->custom_prog)
glDisableYUVConversion(gl, p->target, p->yuvconvtype); glDisableYUVConversion(gl, p->target, p->yuvconvtype);
draw_osd(vo);
} }
static void flip_page(struct vo *vo) static void flip_page(struct vo *vo)
@@ -1906,6 +1909,8 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
struct gl_priv *p = vo->priv; struct gl_priv *p = vo->priv;
GL *gl = p->gl; GL *gl = p->gl;
p->osd_pts = mpi->pts;
int slice = p->slice_height; int slice = p->slice_height;
int stride[3]; int stride[3];
unsigned char *planes[3]; unsigned char *planes[3];
@@ -2166,7 +2171,6 @@ const struct vo_driver video_out_opengl_old = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(struct gl_priv), .priv_size = sizeof(struct gl_priv),

View File

@@ -190,6 +190,7 @@ struct priv {
int num_targets; int num_targets;
int targets_size; int targets_size;
} osd_surfaces[MAX_OSD_PARTS]; } osd_surfaces[MAX_OSD_PARTS];
double osd_pts;
int mouse_hidden; int mouse_hidden;
int brightness, contrast; int brightness, contrast;
@@ -741,7 +742,7 @@ static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs)
draw_osd_part(vo, imgs->render_index); draw_osd_part(vo, imgs->render_index);
} }
static void draw_osd(struct vo *vo, struct osd_state *osd) static void draw_osd(struct vo *vo)
{ {
struct priv *vc = vo->priv; struct priv *vc = vo->priv;
@@ -749,7 +750,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
[SUBBITMAP_RGBA] = true, [SUBBITMAP_RGBA] = true,
}; };
osd_draw(osd, vc->osd_res, osd_get_vo_pts(osd), 0, osdformats, draw_osd_cb, vo); osd_draw(vo->osd, vc->osd_res, vc->osd_pts, 0, osdformats, draw_osd_cb, vo);
} }
static int preinit(struct vo *vo) static int preinit(struct vo *vo)
@@ -849,6 +850,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
SDL_SetTextureBlendMode(vc->tex, SDL_BLENDMODE_NONE); SDL_SetTextureBlendMode(vc->tex, SDL_BLENDMODE_NONE);
if (mpi) { if (mpi) {
vc->osd_pts = mpi->pts;
if (SDL_LockTexture(vc->tex, NULL, &pixels, &pitch)) { if (SDL_LockTexture(vc->tex, NULL, &pixels, &pitch)) {
MP_ERR(vo, "SDL_LockTexture failed\n"); MP_ERR(vo, "SDL_LockTexture failed\n");
return; return;
@@ -900,6 +902,8 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
SDL_SetTextureColorMod(vc->tex, color_mod, color_mod, color_mod); SDL_SetTextureColorMod(vc->tex, color_mod, color_mod, color_mod);
SDL_RenderCopy(vc->renderer, vc->tex, &src, &dst); SDL_RenderCopy(vc->renderer, vc->tex, &src, &dst);
} }
draw_osd(vo);
} }
static struct mp_image *get_screenshot(struct vo *vo) static struct mp_image *get_screenshot(struct vo *vo)
@@ -1020,6 +1024,5 @@ const struct vo_driver video_out_sdl = {
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.uninit = uninit, .uninit = uninit,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
}; };

View File

@@ -111,6 +111,8 @@ static const bool osd_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_RGBA] = true, [SUBBITMAP_RGBA] = true,
}; };
static void draw_osd(struct vo *vo);
static void flush_output_surfaces(struct priv *p) static void flush_output_surfaces(struct priv *p)
{ {
for (int n = 0; n < MAX_OUTPUT_SURFACES; n++) for (int n = 0; n < MAX_OUTPUT_SURFACES; n++)
@@ -283,6 +285,8 @@ static void draw_image(struct vo *vo, struct mp_image *mpi)
} }
mp_image_setrefp(&p->output_surfaces[p->output_surface], mpi); mp_image_setrefp(&p->output_surfaces[p->output_surface], mpi);
draw_osd(vo);
} }
static struct mp_image *get_screenshot(struct priv *p) static struct mp_image *get_screenshot(struct priv *p)
@@ -407,10 +411,13 @@ error:
; ;
} }
static void draw_osd(struct vo *vo, struct osd_state *osd) static void draw_osd(struct vo *vo)
{ {
struct priv *p = vo->priv; struct priv *p = vo->priv;
struct mp_image *cur = p->output_surfaces[p->output_surface];
double pts = cur ? cur->pts : 0;
if (!p->osd_format.fourcc) if (!p->osd_format.fourcc)
return; return;
@@ -425,7 +432,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
for (int n = 0; n < MAX_OSD_PARTS; n++) for (int n = 0; n < MAX_OSD_PARTS; n++)
p->osd_parts[n].active = false; p->osd_parts[n].active = false;
osd_draw(osd, *res, osd_get_vo_pts(osd), 0, osd_formats, draw_osd_cb, p); osd_draw(vo->osd, *res, pts, 0, osd_formats, draw_osd_cb, p);
} }
static int get_displayattribtype(const char *name) static int get_displayattribtype(const char *name)
@@ -524,6 +531,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
} }
case VOCTRL_REDRAW_FRAME: case VOCTRL_REDRAW_FRAME:
p->output_surface = p->visible_surface; p->output_surface = p->visible_surface;
draw_osd(vo);
return true; return true;
case VOCTRL_SCREENSHOT: { case VOCTRL_SCREENSHOT: {
struct voctrl_screenshot_args *args = data; struct voctrl_screenshot_args *args = data;
@@ -654,7 +662,6 @@ const struct vo_driver video_out_vaapi = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(struct priv), .priv_size = sizeof(struct priv),

View File

@@ -145,6 +145,7 @@ struct vdpctx {
}; };
static bool status_ok(struct vo *vo); static bool status_ok(struct vo *vo);
static void draw_osd(struct vo *vo);
static int render_video_to_output_surface(struct vo *vo, static int render_video_to_output_surface(struct vo *vo,
VdpOutputSurface output_surface, VdpOutputSurface output_surface,
@@ -214,9 +215,11 @@ static int video_to_output_surface(struct vo *vo)
{ {
struct vdpctx *vc = vo->priv; struct vdpctx *vc = vo->priv;
return render_video_to_output_surface(vo, int r = render_video_to_output_surface(vo,
vc->output_surfaces[vc->surface_num], vc->output_surfaces[vc->surface_num],
&vc->out_rect_vid, &vc->src_rect_vid); &vc->out_rect_vid, &vc->src_rect_vid);
draw_osd(vo);
return r;
} }
static void forget_frames(struct vo *vo, bool seek_reset) static void forget_frames(struct vo *vo, bool seek_reset)
@@ -657,7 +660,7 @@ static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs)
draw_osd_part(vo, imgs->render_index); draw_osd_part(vo, imgs->render_index);
} }
static void draw_osd(struct vo *vo, struct osd_state *osd) static void draw_osd(struct vo *vo)
{ {
struct vdpctx *vc = vo->priv; struct vdpctx *vc = vo->priv;
@@ -669,7 +672,8 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
[SUBBITMAP_RGBA] = true, [SUBBITMAP_RGBA] = true,
}; };
osd_draw(osd, vc->osd_rect, osd_get_vo_pts(osd), 0, formats, draw_osd_cb, vo); double pts = vc->current_image ? vc->current_image->pts : 0;
osd_draw(vo->osd, vc->osd_rect, pts, 0, formats, draw_osd_cb, vo);
} }
static int update_presentation_queue_status(struct vo *vo) static int update_presentation_queue_status(struct vo *vo)
@@ -1141,7 +1145,6 @@ const struct vo_driver video_out_vdpau = {
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.filter_image = filter_image, .filter_image = filter_image,
.draw_osd = draw_osd,
.flip_page_timed = flip_page_timed, .flip_page_timed = flip_page_timed,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(struct vdpctx), .priv_size = sizeof(struct vdpctx),

View File

@@ -166,6 +166,8 @@ struct priv {
int use_triplebuffering; int use_triplebuffering;
}; };
static void draw_osd(struct vo *vo);
/* copied from weston clients */ /* copied from weston clients */
static int set_cloexec_or_close(int fd) static int set_cloexec_or_close(int fd)
{ {
@@ -678,6 +680,8 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
mp_image_setrefp(&p->original_image, mpi); mp_image_setrefp(&p->original_image, mpi);
buffer_finalise_back(buf); buffer_finalise_back(buf);
draw_osd(vo);
} }
static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs) static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs)
@@ -724,7 +728,7 @@ static const bool osd_formats[SUBBITMAP_COUNT] = {
[SUBBITMAP_RGBA] = true, [SUBBITMAP_RGBA] = true,
}; };
static void draw_osd(struct vo *vo, struct osd_state *osd) static void draw_osd(struct vo *vo)
{ {
struct priv *p = vo->priv; struct priv *p = vo->priv;
// deattach all buffers and attach all needed buffers in osd_draw // deattach all buffers and attach all needed buffers in osd_draw
@@ -737,7 +741,8 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
wl_surface_commit(s); wl_surface_commit(s);
} }
osd_draw(osd, p->osd, osd_get_vo_pts(osd), 0, osd_formats, draw_osd_cb, p); double pts = p->original_image ? p->original_image->pts : 0;
osd_draw(vo->osd, p->osd, pts, 0, osd_formats, draw_osd_cb, p);
} }
static void flip_page(struct vo *vo) static void flip_page(struct vo *vo)
@@ -923,7 +928,6 @@ const struct vo_driver video_out_wayland = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.options = (const struct m_option[]) { .options = (const struct m_option[]) {

View File

@@ -421,15 +421,6 @@ static struct mp_image get_x_buffer(struct priv *p, int buf_index)
return img; return img;
} }
static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct priv *p = vo->priv;
struct mp_image img = get_x_buffer(p, p->current_buf);
osd_draw_on_image(osd, p->osd, osd_get_vo_pts(osd), 0, &img);
}
static mp_image_t *get_screenshot(struct vo *vo) static mp_image_t *get_screenshot(struct vo *vo)
{ {
struct priv *p = vo->priv; struct priv *p = vo->priv;
@@ -490,6 +481,8 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
mp_image_clear(&img, 0, 0, img.w, img.h); mp_image_clear(&img, 0, 0, img.w, img.h);
} }
osd_draw_on_image(vo->osd, p->osd, mpi ? mpi->pts : 0, 0, &img);
mp_image_setrefp(&p->original_image, mpi); mp_image_setrefp(&p->original_image, mpi);
} }
@@ -666,7 +659,6 @@ const struct vo_driver video_out_x11 = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
}; };

View File

@@ -615,16 +615,6 @@ static struct mp_image get_xv_buffer(struct vo *vo, int buf_index)
return img; return img;
} }
static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct xvctx *ctx = vo->priv;
struct mp_image img = get_xv_buffer(vo, ctx->current_buf);
struct mp_osd_res res = osd_res_from_image_params(vo->params);
osd_draw_on_image(osd, res, osd_get_vo_pts(osd), 0, &img);
}
static void wait_for_completion(struct vo *vo, int max_outstanding) static void wait_for_completion(struct vo *vo, int max_outstanding)
{ {
#if HAVE_SHM && HAVE_XEXT #if HAVE_SHM && HAVE_XEXT
@@ -679,6 +669,9 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
mp_image_clear(&xv_buffer, 0, 0, xv_buffer.w, xv_buffer.h); mp_image_clear(&xv_buffer, 0, 0, xv_buffer.w, xv_buffer.h);
} }
struct mp_osd_res res = osd_res_from_image_params(vo->params);
osd_draw_on_image(vo->osd, res, mpi ? mpi->pts : 0, 0, &xv_buffer);
mp_image_setrefp(&ctx->original_image, mpi); mp_image_setrefp(&ctx->original_image, mpi);
} }
@@ -891,7 +884,6 @@ const struct vo_driver video_out_xv = {
.reconfig = reconfig, .reconfig = reconfig,
.control = control, .control = control,
.draw_image = draw_image, .draw_image = draw_image,
.draw_osd = draw_osd,
.flip_page = flip_page, .flip_page = flip_page,
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(struct xvctx), .priv_size = sizeof(struct xvctx),