summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/vf.rst6
-rw-r--r--DOCS/man/en/vo.rst4
-rw-r--r--libmpcodecs/vf.h1
-rw-r--r--libmpcodecs/vf_ass.c16
-rw-r--r--libmpcodecs/vf_vo.c5
-rw-r--r--libmpcodecs/vfcap.h4
-rw-r--r--libvo/gl_osd.c33
-rw-r--r--libvo/gl_osd.h11
-rw-r--r--libvo/video_out.h3
-rw-r--r--libvo/vo_corevideo.m42
-rw-r--r--libvo/vo_direct3d.c98
-rw-r--r--libvo/vo_lavc.c20
-rw-r--r--libvo/vo_opengl.c52
-rw-r--r--libvo/vo_opengl_old.c50
-rw-r--r--libvo/vo_vdpau.c103
-rw-r--r--libvo/vo_x11.c16
-rw-r--r--libvo/vo_xv.c18
-rw-r--r--mplayer.c29
-rw-r--r--sub/ass_mp.c6
-rw-r--r--sub/ass_mp.h6
-rw-r--r--sub/dec_sub.c4
-rw-r--r--sub/dec_sub.h11
-rw-r--r--sub/osd_libass.c6
-rw-r--r--sub/sd.h7
-rw-r--r--sub/sd_ass.c12
-rw-r--r--sub/sd_lavc.c15
-rw-r--r--sub/spudec.c2
-rw-r--r--sub/spudec.h4
-rw-r--r--sub/sub.c96
-rw-r--r--sub/sub.h26
30 files changed, 331 insertions, 375 deletions
diff --git a/DOCS/man/en/vf.rst b/DOCS/man/en/vf.rst
index d46bd5bc06..b5a672e236 100644
--- a/DOCS/man/en/vf.rst
+++ b/DOCS/man/en/vf.rst
@@ -664,14 +664,14 @@ screenshot
``Taking screenshots`` section for details.
ass
- Moves SSA/ASS subtitle rendering to an arbitrary point in the filter
+ Moves subtitle rendering to an arbitrary point in the filter
chain, or force subtitle rendering in the video filter as opposed to using
- video output EOSD support. See the ``--ass`` option.
+ video output OSD support.
*EXAMPLE*:
``--vf=ass,eq``
- Moves SSA/ASS rendering before the eq filter. This will put both
+ Moves sub rendering before the eq filter. This will put both
subtitle colors and video under the influence of the video equalizer
settings.
diff --git a/DOCS/man/en/vo.rst b/DOCS/man/en/vo.rst
index 6248073944..09d12e2994 100644
--- a/DOCS/man/en/vo.rst
+++ b/DOCS/man/en/vo.rst
@@ -171,8 +171,8 @@ direct3d_shaders (Windows only)
Never render YUV video with more than 8 bits per component.
(Using this flag will force software conversion to 8 bit.)
- disable-eosd
- Disable EOSD rendering for subtitles.
+ disable-osd
+ Disable OSD rendering for subtitles.
(Using this flag might force the insertion of the 'ass' video filter,
which will render the subtitles in software.)
diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h
index 8b18470e62..7db9bd5808 100644
--- a/libmpcodecs/vf.h
+++ b/libmpcodecs/vf.h
@@ -99,7 +99,6 @@ struct vf_ctrl_screenshot {
#define VFCTRL_SET_PP_LEVEL 5 // set postprocessing level
#define VFCTRL_SET_EQUALIZER 6 // set color options (brightness,contrast etc)
#define VFCTRL_GET_EQUALIZER 8 // get color options (brightness,contrast etc)
-#define VFCTRL_DRAW_OSD 7
#define VFCTRL_DUPLICATE_FRAME 11 // For encoding - encode zero-change frame
#define VFCTRL_SKIP_NEXT_FRAME 12 // For encoding - drop the next frame that passes thru
#define VFCTRL_FLUSH_FRAMES 13 // For encoding - flush delayed frames
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index 9695ecfdfc..1da0b03b44 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -49,12 +49,12 @@ static const struct vf_priv_s {
unsigned int outfmt;
struct mp_csp_details csp;
- // 1 = auto-added filter: insert only if chain does not support EOSD already
+ // 1 = auto-added filter: insert only if chain does not support OSD already
// 0 = insert always
int auto_insert;
struct osd_state *osd;
- struct mp_eosd_res dim;
+ struct mp_osd_res dim;
} vf_priv_dflt = {
.csp = MP_CSP_DETAILS_DEFAULTS,
};
@@ -78,7 +78,7 @@ static int config(struct vf_instance *vf,
double dar = (double)d_width / d_height;
double sar = (double)width / height;
- vf->priv->dim = (struct mp_eosd_res) {
+ vf->priv->dim = (struct mp_osd_res) {
.w = vf->priv->outw,
.h = vf->priv->outh,
.mt = opts->ass_top_margin,
@@ -227,11 +227,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
prepare_image(vf, mpi);
if (pts != MP_NOPTS_VALUE) {
- struct sub_render_params subparams = {
- .pts = pts,
- .dim = priv->dim,
- };
- osd_draw_on_image(osd, &subparams, OSD_DRAW_SUB_FILTER, vf->dmpi,
+ osd_draw_on_image(osd, priv->dim, pts, OSD_DRAW_SUB_FILTER, vf->dmpi,
&priv->csp);
}
@@ -287,7 +283,7 @@ static int vf_open(vf_instance_t *vf, char *args)
if (!vf->priv->outfmt) {
uninit(vf);
return 0;
- } else if (vf->priv->auto_insert && flags & VFCAP_EOSD) {
+ } else if (vf->priv->auto_insert && flags & VFCAP_OSD) {
uninit(vf);
return -1;
}
@@ -301,7 +297,7 @@ static int vf_open(vf_instance_t *vf, char *args)
vf->control = control;
vf->get_image = get_image;
vf->put_image = put_image;
- vf->default_caps = VFCAP_EOSD | VFCAP_EOSD_FILTER;
+ vf->default_caps = VFCAP_OSD;
return 1;
}
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c
index 998b4b6dfa..16d10f0cdc 100644
--- a/libmpcodecs/vf_vo.c
+++ b/libmpcodecs/vf_vo.c
@@ -91,11 +91,6 @@ static int control(struct vf_instance *vf, int request, void *data)
return vo_control(video_out, VOCTRL_GET_YUV_COLORSPACE, data) == true;
case VFCTRL_SET_YUV_COLORSPACE:
return vo_control(video_out, VOCTRL_SET_YUV_COLORSPACE, data) == true;
- case VFCTRL_DRAW_OSD:
- if (!video_out->config_ok)
- return CONTROL_FALSE; // vo not configured?
- vo_draw_osd(video_out, data);
- return CONTROL_TRUE;
case VFCTRL_SET_EQUALIZER: {
vf_equalizer_t *eq = data;
if (!video_out->config_ok)
diff --git a/libmpcodecs/vfcap.h b/libmpcodecs/vfcap.h
index 0fb73f5a51..acc7ce31c6 100644
--- a/libmpcodecs/vfcap.h
+++ b/libmpcodecs/vfcap.h
@@ -40,11 +40,7 @@
#define VFCAP_ACCEPT_STRIDE 0x400
// filter does postprocessing (so you shouldn't scale/filter image before it)
#define VFCAP_POSTPROC 0x800
-// filter can draw EOSD
-#define VFCAP_EOSD 0x2000
// used by libvo and vf_vo, indicates the VO does not support draw_slice for this format
#define VOCAP_NOSLICES 0x8000
-#define VFCAP_EOSD_FILTER 0x20000 // EOSD is drawn in filter chain
-#define VFCAP_EOSD_RGBA 0x40000
#endif /* MPLAYER_VFCAP_H */
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])
-