diff options
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/gl_osd.c | 33 | ||||
-rw-r--r-- | libvo/gl_osd.h | 11 | ||||
-rw-r--r-- | libvo/video_out.h | 3 | ||||
-rw-r--r-- | libvo/vo_corevideo.m | 42 | ||||
-rw-r--r-- | libvo/vo_direct3d.c | 98 | ||||
-rw-r--r-- | libvo/vo_lavc.c | 20 | ||||
-rw-r--r-- | libvo/vo_opengl.c | 52 | ||||
-rw-r--r-- | libvo/vo_opengl_old.c | 50 | ||||
-rw-r--r-- | libvo/vo_vdpau.c | 103 | ||||
-rw-r--r-- | libvo/vo_x11.c | 16 | ||||
-rw-r--r-- | libvo/vo_xv.c | 18 |
11 files changed, 237 insertions, 209 deletions
diff --git a/libvo/gl_osd.c b/libvo/gl_osd.c index 5266dca4ac..81485cabe9 100644 --- a/libvo/gl_osd.c +++ b/libvo/gl_osd.c @@ -68,6 +68,9 @@ struct mpgl_osd *mpgl_osd_init(GL *gl, bool legacy) ctx->parts[n] = p; } + for (int n = 0; n < SUBBITMAP_COUNT; n++) + ctx->formats[n] = ctx->fmt_table[n].type != 0; + return ctx; } @@ -84,11 +87,6 @@ void mpgl_osd_destroy(struct mpgl_osd *ctx) talloc_free(ctx); } -bool mpgl_osd_query_format(struct mpgl_osd *ctx, int osd_format) -{ - return ctx->fmt_table[osd_format].type != 0; -} - static bool upload_pbo(struct mpgl_osd *ctx, struct mpgl_osd_part *osd, struct sub_bitmaps *imgs) { @@ -159,9 +157,9 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd, osd->packer->padding = ctx->scaled || imgs->scaled; int r = packer_pack_from_subbitmaps(osd->packer, imgs); if (r < 0) { - mp_msg(MSGT_VO, MSGL_ERR, "[gl] EOSD bitmaps do not fit on " - "a surface with the maximum supported size %dx%d.\n", - osd->packer->w_max, osd->packer->h_max); + mp_msg(MSGT_VO, MSGL_ERR, "[gl] OSD bitmaps do not fit on " + "a surface with the maximum supported size %dx%d.\n", + osd->packer->w_max, osd->packer->h_max); return false; } @@ -207,7 +205,7 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd, struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx, struct sub_bitmaps *imgs) { - if (imgs->num_parts == 0 || !mpgl_osd_query_format(ctx, imgs->format)) + if (imgs->num_parts == 0 || !ctx->formats[imgs->format]) return NULL; struct mpgl_osd_part *osd = ctx->parts[imgs->render_index]; @@ -226,7 +224,7 @@ struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx, return osd->packer->count ? osd : NULL; } -void mpgl_osd_gl_set_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) { GL *gl = ctx->gl; @@ -235,7 +233,7 @@ void mpgl_osd_gl_set_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p) gl->BlendFunc(blend_factors[p->format][0], blend_factors[p->format][1]); } -void mpgl_osd_gl_unset_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) { GL *gl = ctx->gl; @@ -249,8 +247,9 @@ struct vertex { float texcoord[2]; }; -void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct sub_bitmaps *imgs) +static void draw_legacy_cb(void *pctx, struct sub_bitmaps *imgs) { + struct mpgl_osd *ctx = pctx; struct mpgl_osd_part *osd = mpgl_osd_generate(ctx, imgs); if (!osd) return; @@ -309,11 +308,17 @@ void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct sub_bitmaps *imgs) gl->EnableClientState(GL_TEXTURE_COORD_ARRAY); gl->EnableClientState(GL_COLOR_ARRAY); - mpgl_osd_gl_set_state(ctx, osd); + mpgl_osd_set_gl_state(ctx, osd); gl->DrawArrays(GL_TRIANGLES, 0, osd->num_vertices); - mpgl_osd_gl_unset_state(ctx, osd); + mpgl_osd_unset_gl_state(ctx, osd); gl->DisableClientState(GL_VERTEX_ARRAY); gl->DisableClientState(GL_TEXTURE_COORD_ARRAY); gl->DisableClientState(GL_COLOR_ARRAY); } + +void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct osd_state *osd, + struct mp_osd_res res) +{ + osd_draw(osd, res, osd->vo_pts, 0, ctx->formats, draw_legacy_cb, ctx); +} diff --git a/libvo/gl_osd.h b/libvo/gl_osd.h index 9bbf6ad785..cf3182ffb2 100644 --- a/libvo/gl_osd.h +++ b/libvo/gl_osd.h @@ -24,19 +24,20 @@ struct mpgl_osd { bool scaled; struct mpgl_osd_part *parts[MAX_OSD_PARTS]; const struct osd_fmt_entry *fmt_table; + bool formats[SUBBITMAP_COUNT]; void *scratch; }; struct mpgl_osd *mpgl_osd_init(GL *gl, bool legacy); void mpgl_osd_destroy(struct mpgl_osd *ctx); -bool mpgl_osd_query_format(struct mpgl_osd *ctx, int osd_format); - -void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, struct sub_bitmaps *b); struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx, struct sub_bitmaps *b); -void mpgl_osd_gl_set_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p); -void mpgl_osd_gl_unset_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_draw_legacy(struct mpgl_osd *ctx, struct osd_state *osd, + struct mp_osd_res res); #endif diff --git a/libvo/video_out.h b/libvo/video_out.h index 2689c244a8..ffb5c0c4f3 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -64,9 +64,6 @@ enum mp_voctrl { VOCTRL_ONTOP, VOCTRL_ROOTWIN, VOCTRL_BORDER, - VOCTRL_DRAW_EOSD, - VOCTRL_GET_EOSD_RES, // struct mp_eosd_res - VOCTRL_QUERY_EOSD_FORMAT, // int VOCTRL_SET_DEINTERLACE, VOCTRL_GET_DEINTERLACE, diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m index c3d832d589..0e841f7530 100644 --- a/libvo/vo_corevideo.m +++ b/libvo/vo_corevideo.m @@ -19,6 +19,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <assert.h> + #import "vo_corevideo.h" // mplayer includes @@ -50,6 +52,7 @@ struct priv { unsigned int image_width; unsigned int image_height; struct mp_csp_details colorspace; + int ass_border_x, ass_border_y; CVPixelBufferRef pixelBuffer; CVOpenGLTextureCacheRef textureCache; @@ -84,6 +87,8 @@ static void resize(struct vo *vo, int width, int height) scale_x = (GLdouble)new_w / (GLdouble)p->image_width; scale_y = (GLdouble)new_h / (GLdouble)p->image_height; gl->Scaled(scale_x, scale_y, 1); + p->ass_border_x = (vo->dwidth - new_w) / 2; + p->ass_border_y = (vo->dheight - new_h) / 2; } gl->Ortho(0, p->image_width, p->image_height, 0, -1.0, 1.0); @@ -249,7 +254,7 @@ static int query_format(struct vo *vo, uint32_t format) struct priv *p = vo->priv; const int flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | - VOCAP_NOSLICES | VFCAP_EOSD; + VOCAP_NOSLICES; switch (format) { case IMGFMT_YUY2: p->pixelFormat = kYUVSPixelFormat; @@ -293,6 +298,26 @@ static int preinit(struct vo *vo, const char *arg) return 0; } +static void draw_osd(struct vo *vo, struct osd_state *osd) +{ + struct priv *p = vo->priv; + GL *gl = p->mpglctx->gl; + assert(p->osd); + + struct mp_osd_res res = { + .w = vo->dwidth, + .h = vo->dheight, + .ml = p->ass_border_x, + .mr = p->ass_border_x, + .mt = p->ass_border_y, + .mb = p->ass_border_y, + .display_par = vo->monitor_par, + .video_par = vo->aspdat.par, + }; + + mpgl_osd_draw_legacy(p->osd, osd, res); +} + static CFStringRef get_cv_csp_matrix(struct vo *vo) { struct priv *p = vo->priv; @@ -324,19 +349,6 @@ static int control(struct vo *vo, uint32_t request, void *data) return draw_image(vo, data); case VOCTRL_QUERY_FORMAT: return query_format(vo, *(uint32_t*)data); - case VOCTRL_DRAW_EOSD: - mpgl_osd_draw_legacy(p->osd, data); - return VO_TRUE; - case VOCTRL_QUERY_EOSD_FORMAT: - return mpgl_osd_query_format(p->osd, *(int *)data) - ? VO_TRUE : VO_NOTIMPL; - case VOCTRL_GET_EOSD_RES: { - struct mp_eosd_res *r = data; - r->w = vo->dwidth; - r->h = vo->dheight; - r->mt = r->mb = r->ml = r->mr = 0; - return VO_TRUE; - } case VOCTRL_ONTOP: p->mpglctx->ontop(vo); return VO_TRUE; @@ -377,7 +389,7 @@ const struct vo_driver video_out_corevideo = { .preinit = preinit, .config = config, .control = control, - .draw_osd = draw_osd_with_eosd, + .draw_osd = draw_osd, .flip_page = flip_page, .check_events = check_events, .uninit = uninit, diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c index 2b8f3429e4..bbcce41ca1 100644 --- a/libvo/vo_direct3d.c +++ b/libvo/vo_direct3d.c @@ -59,13 +59,13 @@ #define DEVTYPE D3DDEVTYPE_HAL //#define DEVTYPE D3DDEVTYPE_REF -#define D3DFVF_EOSD_VERTEX (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE) +#define D3DFVF_OSD_VERTEX (D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_DIFFUSE) typedef struct { float x, y, z; D3DCOLOR color; float tu, tv; -} vertex_eosd; +} vertex_osd; #define D3DFVF_VIDEO_VERTEX (D3DFVF_XYZ | D3DFVF_TEX3) @@ -113,7 +113,7 @@ struct osdpart { int bitmap_id, bitmap_pos_id; struct d3dtex texture; int num_vertices; - vertex_eosd *vertices; + vertex_osd *vertices; struct bitmap_packer *packer; }; @@ -125,7 +125,7 @@ typedef struct d3d_priv { int opt_disable_stretchrect; int opt_disable_shaders; int opt_only_8bit; - int opt_disable_eosd; + int opt_disable_osd; int opt_disable_texture_align; // debugging int opt_force_power_of_2; @@ -232,6 +232,10 @@ static const D3DFORMAT osd_fmt_table[SUBBITMAP_COUNT] = { [SUBBITMAP_LIBASS] = D3DFMT_A8, [SUBBITMAP_RGBA] = D3DFMT_A8R8G8B8, }; +static const bool osd_fmt_supported[SUBBITMAP_COUNT] = { + [SUBBITMAP_LIBASS] = true, + [SUBBITMAP_RGBA] = true, +}; static void update_colorspace(d3d_priv *priv); @@ -241,7 +245,6 @@ static uint32_t d3d_draw_frame(d3d_priv *priv); static int draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y); static void uninit(struct vo *vo); -static void draw_osd(d3d_priv *priv, struct sub_bitmaps *imgs); static void flip_page(struct vo *vo); static mp_image_t *get_screenshot(d3d_priv *priv); static mp_image_t *get_window_screenshot(d3d_priv *priv); @@ -1224,11 +1227,11 @@ static int query_format(d3d_priv *priv, uint32_t movie_fmt) if (!init_rendering_mode(priv, movie_fmt, false)) return 0; - int eosd_caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW - | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; - if (!priv->opt_disable_eosd) - eosd_caps |= VFCAP_EOSD | VFCAP_EOSD_RGBA; - return eosd_caps; + int osd_caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW + | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; + if (!priv->opt_disable_osd) + osd_caps |= VFCAP_OSD; + return osd_caps; } /**************************************************************************** @@ -1296,7 +1299,7 @@ static void update_colorspace(d3d_priv *priv) } const char *options_help_text = "-vo direct3d command line help:\n" -"Example: -vo direct3d:disable-eosd:disable-textures\n" +"Example: -vo direct3d:disable-osd:disable-textures\n" "Options:\n" " prefer-stretchrect\n" " Use IDirect3DDevice9::StretchRect over other methods if possible.\n" @@ -1311,8 +1314,8 @@ const char *options_help_text = "-vo direct3d command line help:\n" " only-8bit\n" " Never render YUV video with more than 8 bits per component.\n" " (Using this flag will force software conversion to 8 bit.)\n" -" disable-eosd\n" -" Disable EOSD rendering for subtitles.\n" +" disable-osd\n" +" Disable OSD rendering.\n" " (Using this flag might force the insertion of the 'ass' video filter,\n" " which will render the subtitles in software.)\n" " disable-texture-align\n" @@ -1386,7 +1389,7 @@ static int preinit_internal(struct vo *vo, const char *arg, bool allow_shaders) {"disable-stretchrect", OPT_ARG_BOOL, &priv->opt_disable_stretchrect}, {"disable-shaders", OPT_ARG_BOOL, &priv->opt_disable_shaders}, {"only-8bit", OPT_ARG_BOOL, &priv->opt_only_8bit}, - {"disable-eosd", OPT_ARG_BOOL, &priv->opt_disable_eosd}, + {"disable-osd", OPT_ARG_BOOL, &priv->opt_disable_osd}, {"force-power-of-2", OPT_ARG_BOOL, &priv->opt_force_power_of_2}, {"disable-texture-align", OPT_ARG_BOOL, &priv->opt_disable_texture_align}, {"texture-memory", OPT_ARG_INT, &priv->opt_texture_memory}, @@ -1507,21 +1510,6 @@ static int control(struct vo *vo, uint32_t request, void *data) return VO_TRUE; case VOCTRL_GET_PANSCAN: return VO_TRUE; - case VOCTRL_DRAW_EOSD: - if (!data) - return VO_FALSE; - draw_osd(priv, data); - return VO_TRUE; - case VOCTRL_QUERY_EOSD_FORMAT: - return osd_fmt_table[*(int *)data] ? VO_TRUE : VO_NOTIMPL; - case VOCTRL_GET_EOSD_RES: { - struct mp_eosd_res *r = data; - r->w = vo->dwidth; - r->h = vo->dheight; - r->ml = r->mr = priv->border_x; - r->mt = r->mb = priv->border_y; - return VO_TRUE; - } case VOCTRL_SCREENSHOT: { struct voctrl_screenshot_args *args = data; if (args->full_window) @@ -1905,7 +1893,7 @@ static bool upload_osd(d3d_priv *priv, struct osdpart *osd, osd->packer->padding = imgs->scaled; // assume 2x2 filter on scaling int r = packer_pack_from_subbitmaps(osd->packer, imgs); if (r < 0) { - mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>EOSD bitmaps do not fit on " + mp_msg(MSGT_VO, MSGL_ERR, "<vo_direct3d>OSD bitmaps do not fit on " "a surface with the maximum supported size %dx%d.\n", osd->packer->w_max, osd->packer->h_max); return false; @@ -1939,7 +1927,7 @@ static bool upload_osd(d3d_priv *priv, struct osdpart *osd, if (FAILED(IDirect3DTexture9_LockRect(osd->texture.system, 0, &locked_rect, &dirty_rc, 0))) { - mp_msg(MSGT_VO,MSGL_ERR, "<vo_direct3d>EOSD texture lock failed.\n"); + mp_msg(MSGT_VO,MSGL_ERR, "<vo_direct3d>OSD texture lock failed.\n"); return false; } @@ -1948,7 +1936,7 @@ static bool upload_osd(d3d_priv *priv, struct osdpart *osd, locked_rect.Pitch); if (FAILED(IDirect3DTexture9_UnlockRect(osd->texture.system, 0))) { - mp_msg(MSGT_VO,MSGL_ERR, "<vo_direct3d>EOSD texture unlock failed.\n"); + mp_msg(MSGT_VO,MSGL_ERR, "<vo_direct3d>OSD texture unlock failed.\n"); return false; } @@ -1985,10 +1973,9 @@ static D3DCOLOR ass_to_d3d_color(uint32_t color) return D3DCOLOR_ARGB(a, r, g, b); } -static void draw_osd(d3d_priv *priv, struct sub_bitmaps *imgs) +static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs) { - if (!priv->d3d_device) - return; + d3d_priv *priv = ctx; struct osdpart *osd = generate_osd(priv, imgs); if (!osd) @@ -1999,7 +1986,7 @@ static void draw_osd(d3d_priv *priv, struct sub_bitmaps *imgs) // the number of vertices by using an indexed vertex array, but it's // probably not worth doing) osd->num_vertices = osd->packer->count * 6; - osd->vertices = talloc_realloc(osd, osd->vertices, vertex_eosd, + osd->vertices = talloc_realloc(osd, osd->vertices, vertex_osd, osd->num_vertices); float tex_w = osd->texture.tex_w; @@ -2022,11 +2009,11 @@ static void draw_osd(d3d_priv *priv, struct sub_bitmaps *imgs) float tx1 = (p.x + b->w) / tex_w; float ty1 = (p.y + b->h) / tex_h; - vertex_eosd *v = &osd->vertices[n * 6]; - v[0] = (vertex_eosd) { x0, y0, 0, color, tx0, ty0 }; - v[1] = (vertex_eosd) { x1, y0, 0, color, tx1, ty0 }; - v[2] = (vertex_eosd) { x0, y1, 0, color, tx0, ty1 }; - v[3] = (vertex_eosd) { x1, y1, 0, color, tx1, ty1 }; + vertex_osd *v = &osd->vertices[n * 6]; + v[0] = (vertex_osd) { x0, y0, 0, color, tx0, ty0 }; + v[1] = (vertex_osd) { x1, y0, 0, color, tx1, ty0 }; + v[2] = (vertex_osd) { x0, y1, 0, color, tx0, ty1 }; + v[3] = (vertex_osd) { x1, y1, 0, color, tx1, ty1 }; v[4] = v[2]; v[5] = v[1]; } @@ -2054,10 +2041,10 @@ static void draw_osd(d3d_priv *priv, struct sub_bitmaps *imgs) D3DBLEND_ONE); } - IDirect3DDevice9_SetFVF(priv->d3d_device, D3DFVF_EOSD_VERTEX); + IDirect3DDevice9_SetFVF(priv->d3d_device, D3DFVF_OSD_VERTEX); IDirect3DDevice9_DrawPrimitiveUP(priv->d3d_device, D3DPT_TRIANGLELIST, osd->num_vertices / 3, - osd->vertices, sizeof(vertex_eosd)); + osd->vertices, sizeof(vertex_osd)); IDirect3DDevice9_SetTextureStageState(priv->d3d_device,0, D3DTSS_COLORARG1, D3DTA_TEXTURE); @@ -2072,6 +2059,27 @@ static void draw_osd(d3d_priv *priv, struct sub_bitmaps *imgs) D3DRS_ALPHABLENDENABLE, FALSE); } + +static void draw_osd(struct vo *vo, struct osd_state *osd) +{ + d3d_priv *priv = vo->priv; + if (!priv->d3d_device) + return; + + struct mp_osd_res res = { + .w = vo->dwidth, + .h = vo->dheight, + .ml = priv->border_x, + .mr = priv->border_x, + .mt = priv->border_y, + .mb = priv->border_y, + .display_par = vo->monitor_par, + .video_par = vo->aspdat.par, + }; + + osd_draw(osd, res, osd->vo_pts, 0, osd_fmt_supported, draw_osd_cb, priv); +} + #define AUTHOR "Georgi Petrov (gogothebee) <gogothebee@gmail.com> and others" const struct vo_driver video_out_direct3d = { @@ -2086,7 +2094,7 @@ const struct vo_driver video_out_direct3d = { .config = config, .control = control, .draw_slice = draw_slice, - .draw_osd = draw_osd_with_eosd, + .draw_osd = draw_osd, .flip_page = flip_page, .check_events = check_events, .uninit = uninit, @@ -2104,7 +2112,7 @@ const struct vo_driver video_out_direct3d_shaders = { .config = config, .control = control, .draw_slice = draw_slice, - .draw_osd = draw_osd_with_eosd, + .draw_osd = draw_osd, .flip_page = flip_page, .check_events = check_events, .uninit = uninit, diff --git a/libvo/vo_lavc.c b/libvo/vo_lavc.c index caa3b4202c..5c90207256 100644 --- a/libvo/vo_lavc.c +++ b/libvo/vo_lavc.c @@ -198,8 +198,8 @@ static int query_format(struct vo *vo, uint32_t format) VFCAP_CSP_SUPPORTED | // we can do it VFCAP_CSP_SUPPORTED_BY_HW | - // we don't convert colorspaces here (TODO: if we add EOSD rendering, only set this flag if EOSD can be rendered without extra conversions) - VFCAP_OSD | VFCAP_EOSD | + // we don't convert colorspaces here + VFCAP_OSD | // we have OSD VOCAP_NOSLICES; // we don't use slices @@ -494,17 +494,15 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) double sar = (double)asp.orgw / asp.orgh; double dar = (double)asp.prew / asp.preh; - struct sub_render_params subparams = { - .pts = osd->vo_sub_pts, - .dim = { - .w = asp.orgw, - .h = asp.orgh, - .display_par = sar / dar, - .video_par = dar / sar, - }, + struct mp_osd_res dim = { + .w = asp.orgw, + .h = asp.orgh, + .display_par = sar / dar, + .video_par = dar / sar, }; - osd_draw_on_image(osd, &subparams, 0, vc->lastimg, &vc->colorspace); + osd_draw_on_image(osd, dim, osd->vo_pts, 0, vc->lastimg, + &vc->colorspace); } } diff --git a/libvo/vo_opengl.c b/libvo/vo_opengl.c index 413ca78710..df82a239d1 100644 --- a/libvo/vo_opengl.c +++ b/libvo/vo_opengl.c @@ -1420,12 +1420,11 @@ static mp_image_t *get_window_screenshot(struct gl_priv *p) return image; } -static void draw_eosd(struct gl_priv *p, struct sub_bitmaps *imgs) +static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs) { + struct gl_priv *p = ctx; GL *gl = p->gl; - assert(p->osd); - struct mpgl_osd_part *osd = mpgl_osd_generate(p->osd, imgs); if (!osd) return; @@ -1459,14 +1458,33 @@ static void draw_eosd(struct gl_priv *p, struct sub_bitmaps *imgs) debug_check_gl(p, "before drawing osd"); gl->UseProgram(p->osd_programs[osd->format]); - mpgl_osd_gl_set_state(p->osd, osd); + mpgl_osd_set_gl_state(p->osd, osd); draw_triangles(p, osd->vertices, osd->num_vertices); - mpgl_osd_gl_unset_state(p->osd, osd); + mpgl_osd_unset_gl_state(p->osd, osd); gl->UseProgram(0); debug_check_gl(p, "after drawing osd"); } +static void draw_osd(struct vo *vo, struct osd_state *osd) +{ + struct gl_priv *p = vo->priv; + assert(p->osd); + + struct mp_osd_res res = { + .w = vo->dwidth, + .h = vo->dheight, + .ml = p->border_x, + .mr = p->border_x, + .mt = p->border_y, + .mb = p->border_y, + .display_par = vo->monitor_par, + .video_par = vo->aspdat.par, + }; + + osd_draw(osd, res, osd->vo_pts, 0, p->osd->formats, draw_osd_cb, p); +} + // Disable features that are not supported with the current OpenGL version. static void check_gl_features(struct gl_priv *p) { @@ -1691,7 +1709,7 @@ static int query_format(uint32_t format) { int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIP | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE | - VFCAP_OSD | VFCAP_EOSD | VFCAP_EOSD_RGBA; + VFCAP_OSD; if (!init_format(format, NULL)) return 0; return caps; @@ -1767,24 +1785,6 @@ static int control(struct vo *vo, uint32_t request, void *data) return query_format(*(uint32_t *)data); case VOCTRL_DRAW_IMAGE: return draw_image(p, data); - case VOCTRL_DRAW_EOSD: - if (!data) - return VO_FALSE; - draw_eosd(p, data); - return VO_TRUE; - case VOCTRL_GET_EOSD_RES: { - struct mp_eosd_res *r = data; - r->w = vo->dwidth; - r->h = vo->dheight; - r->ml = r->mr = p->border_x; - r->mt = r->mb = p->border_y; - return VO_TRUE; - } - case VOCTRL_QUERY_EOSD_FORMAT: { - int f = *(int *)data; - return (mpgl_osd_query_format(p->osd, f) && osd_shaders[f]) - ? VO_TRUE : VO_NOTIMPL; - } case VOCTRL_ONTOP: if (!p->glctx->ontop) break; @@ -2304,7 +2304,7 @@ const struct vo_driver video_out_opengl = { .config = config, .control = control, .draw_slice = draw_slice, - .draw_osd = draw_osd_with_eosd, + .draw_osd = draw_osd, .flip_page = flip_page, .check_events = check_events, .uninit = uninit, @@ -2322,7 +2322,7 @@ const struct vo_driver video_out_opengl_hq = { .config = config, .control = control, .draw_slice = draw_slice, - .draw_osd = draw_osd_with_eosd, + .draw_osd = draw_osd, .flip_page = flip_page, .check_events = check_events, .uninit = uninit, diff --git a/libvo/vo_opengl_old.c b/libvo/vo_opengl_old.c index 98a111b454..ac104a3cde 100644 --- a/libvo/vo_opengl_old.c +++ b/libvo/vo_opengl_old.c @@ -26,6 +26,7 @@ #include <string.h> #include <math.h> #include <stdbool.h> +#include <assert.h> #include "config.h" #include "talloc.h" @@ -229,11 +230,14 @@ static void update_yuvconv(struct vo *vo) } } -// Note: relies on state being setup, like projection matrix and blending -static void render_osd(struct vo *vo, struct sub_bitmaps *imgs) +static void draw_osd(struct vo *vo, struct osd_state *osd) { struct gl_priv *p = vo->priv; GL *gl = p->gl; + assert(p->osd); + + if (!p->use_osd) + return; if (!p->scaled_osd) { gl->MatrixMode(GL_PROJECTION); @@ -241,9 +245,26 @@ static void render_osd(struct vo *vo, struct sub_bitmaps *imgs) gl->LoadIdentity(); gl->Ortho(0, vo->dwidth, vo->dheight, 0, -1, 1); } + gl->Color4ub((p->osd_color >> 16) & 0xff, (p->osd_color >> 8) & 0xff, p->osd_color & 0xff, 0xff - (p->osd_color >> 24)); - mpgl_osd_draw_legacy(p->osd, imgs); + + struct mp_osd_res res = { + .w = vo->dwidth, + .h = vo->dheight, + .display_par = vo->monitor_par, + .video_par = vo->aspdat.par, + }; + if (p->scaled_osd) { + res.w = p->image_width; + res.h = p->image_height; + } else if (aspect_scaling()) { + res.ml = res.mr = p->ass_border_x; + res.mt = res.mb = p->ass_border_y; + } + + mpgl_osd_draw_legacy(p->osd, osd, res); + if (!p->scaled_osd) gl->PopMatrix(); } @@ -843,7 +864,7 @@ static int query_format(struct vo *vo, uint32_t format) int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIP | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE; if (p->use_osd) - caps |= VFCAP_OSD | VFCAP_EOSD; + caps |= VFCAP_OSD; if (format == IMGFMT_RGB24 || format == IMGFMT_RGBA) return caps; if (p->use_yuv && mp_get_chroma_shift(format, NULL, NULL, &depth) && @@ -1077,25 +1098,6 @@ static int control(struct vo *vo, uint32_t request, void *data) return query_format(vo, *(uint32_t *)data); case VOCTRL_DRAW_IMAGE: return draw_image(vo, data); - case VOCTRL_DRAW_EOSD: - render_osd(vo, data); - return VO_TRUE; - case VOCTRL_QUERY_EOSD_FORMAT: - return mpgl_osd_query_format(p->osd, *(int *)data) ? VO_TRUE : VO_NOTIMPL; - case VOCTRL_GET_EOSD_RES: { - struct mp_eosd_res *r = data; - r->w = vo->dwidth; - r->h = vo->dheight; - r->mt = r->mb = r->ml = r->mr = 0; - if (p->scaled_osd) { - r->w = p->image_width; - r->h = p->image_height; - } else if (aspect_scaling()) { - r->ml = r->mr = p->ass_border_x; - r->mt = r->mb = p->ass_border_y; - } - return VO_TRUE; - } case VOCTRL_ONTOP: if (!p->glctx->ontop) break; @@ -1177,7 +1179,7 @@ const struct vo_driver video_out_opengl_old = { .config = config, .control = control, .draw_slice = draw_slice, - .draw_osd = draw_osd_with_eosd, + .draw_osd = draw_osd, .flip_page = flip_page, .check_events = check_events, .uninit = uninit, diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c index 94d37e3018..1d4bf8adf7 100644 --- a/libvo/vo_vdpau.c +++ b/libvo/vo_vdpau.c @@ -157,15 +157,15 @@ struct vdpctx { VdpChromaType vdp_chroma_type; VdpYCbCrFormat vdp_pixel_format; - // EOSD - struct eosd_bitmap_surface { + // OSD + struct osd_bitmap_surface { VdpRGBAFormat format; VdpBitmapSurface surface; uint32_t max_width; uint32_t max_height; struct bitmap_packer *packer; // List of surfaces to be rendered - struct eosd_target { + struct osd_target { VdpRect source; VdpRect dest; VdpColor color; @@ -174,7 +174,7 @@ struct vdpctx { int render_count; int bitmap_id; int bitmap_pos_id; - } eosd_surfaces[MAX_OSD_PARTS]; + } osd_surfaces[MAX_OSD_PARTS]; // Video equalizer struct mp_csp_equalizer video_eq; @@ -183,6 +183,8 @@ struct vdpctx { bool mode_switched; }; +static bool status_ok(struct vo *vo); + static int change_vdptime_sync(struct vdpctx *vc, unsigned int *t) { struct vdp_functions *vdp = vc->vdp; @@ -800,10 +802,10 @@ static void mark_vdpau_objects_uninitialized(struct vo *vo) vc->output_surfaces[i] = VDP_INVALID_HANDLE; vc->vdp_device = VDP_INVALID_HANDLE; for (int i = 0; i < MAX_OSD_PARTS; i++) { - struct eosd_bitmap_surface *sfc = &vc->eosd_surfaces[i]; + struct osd_bitmap_surface *sfc = &vc->osd_surfaces[i]; talloc_free(sfc->packer); sfc->bitmap_id = sfc->bitmap_pos_id = 0; - *sfc = (struct eosd_bitmap_surface){ + *sfc = (struct osd_bitmap_surface){ .surface = VDP_INVALID_HANDLE, }; } @@ -941,18 +943,18 @@ static struct bitmap_packer *make_packer(struct vo *vo, VdpRGBAFormat format) VdpStatus vdp_st = vdp-> bitmap_surface_query_capabilities(vc->vdp_device, format, &(VdpBool){0}, &w_max, &h_max); - CHECK_ST_WARNING("Query to get max EOSD surface size failed"); + CHECK_ST_WARNING("Query to get max OSD surface size failed"); packer->w_max = w_max; packer->h_max = h_max; return packer; } -static void draw_eosd(struct vo *vo, int index) +static void draw_osd_part(struct vo *vo, int index) { struct vdpctx *vc = vo->priv; struct vdp_functions *vdp = vc->vdp; VdpStatus vdp_st; - struct eosd_bitmap_surface *sfc = &vc->eosd_surfaces[index]; + struct osd_bitmap_surface *sfc = &vc->osd_surfaces[index]; VdpOutputSurface output_surface = vc->output_surfaces[vc->surface_num]; int i; @@ -986,16 +988,16 @@ static void draw_eosd(struct vo *vo, int index) &sfc->targets[i].color, blend, VDP_OUTPUT_SURFACE_RENDER_ROTATE_0); - CHECK_ST_WARNING("EOSD: Error when rendering"); + CHECK_ST_WARNING("OSD: Error when rendering"); } } -static void generate_eosd(struct vo *vo, struct sub_bitmaps *imgs) +static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs) { struct vdpctx *vc = vo->priv; struct vdp_functions *vdp = vc->vdp; VdpStatus vdp_st; - struct eosd_bitmap_surface *sfc = &vc->eosd_surfaces[imgs->render_index]; + struct osd_bitmap_surface *sfc = &vc->osd_surfaces[imgs->render_index]; bool need_upload = false; if (imgs->bitmap_pos_id == sfc->bitmap_pos_id) @@ -1007,7 +1009,7 @@ static void generate_eosd(struct vo *vo, struct sub_bitmaps *imgs) return; if (imgs->bitmap_id == sfc->bitmap_id) - goto eosd_skip_upload; + goto osd_skip_upload; need_upload = true; VdpRGBAFormat format; @@ -1034,7 +1036,7 @@ static void generate_eosd(struct vo *vo, struct sub_bitmaps *imgs) sfc->packer->padding = imgs->scaled; // assume 2x2 filter on scaling int r = packer_pack_from_subbitmaps(sfc->packer, imgs); if (r < 0) { - mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] EOSD bitmaps do not fit on " + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] OSD bitmaps do not fit on " "a surface with the maximum supported size\n"); return; } else if (r == 1) { @@ -1043,13 +1045,13 @@ static void generate_eosd(struct vo *vo, struct sub_bitmaps *imgs) CHECK_ST_WARNING("Error when calling vdp_bitmap_surface_destroy"); } mp_msg(MSGT_VO, MSGL_V, "[vdpau] Allocating a %dx%d surface for " - "EOSD bitmaps.\n", sfc->packer->w, sfc->packer->h); + "OSD bitmaps.\n", sfc->packer->w, sfc->packer->h); vdp_st = vdp->bitmap_surface_create(vc->vdp_device, format, sfc->packer->w, sfc->packer->h, true, &sfc->surface); if (vdp_st != VDP_STATUS_OK) sfc->surface = VDP_INVALID_HANDLE; - CHECK_ST_WARNING("EOSD: error when creating surface"); + CHECK_ST_WARNING("OSD: error when creating surface"); } if (imgs->scaled) { char zeros[sfc->packer->used_width * format_size]; @@ -1060,7 +1062,7 @@ static void generate_eosd(struct vo *vo, struct sub_bitmaps *imgs) sfc->packer->used_height}); } -eosd_skip_upload: +osd_skip_upload: if (sfc->surface == VDP_INVALID_HANDLE) return; if (sfc->packer->count > sfc->targets_size) { @@ -1072,7 +1074,7 @@ eosd_skip_upload: for (int i = 0 ;i < sfc->packer->count; i++) { struct sub_bitmap *b = &imgs->parts[i]; - struct eosd_target *target = sfc->targets + sfc->render_count; + struct osd_target *target = sfc->targets + sfc->render_count; int x = sfc->packer->result[i].x; int y = sfc->packer->result[i].y; target-&g |