From d511ef79a09fa9e42479e66f4837daaa68b7255b Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Mar 2013 11:16:01 +0100 Subject: core: simplify OSD capability handling, remove VFCAP_OSD VFCAP_OSD was used to determine at runtime whether the VO supports OSD rendering. This was mostly unused. vo_direct3d had an option to disable OSD (was supposed to allow to force auto-insertion of vf_ass, but we removed that anyway). vo_opengl_old could disable OSD rendering when a very old OpenGL version was detected, and had an option to explicitly disable it as well. Remove VFCAP_OSD from everything (and some associated logic). Now the vo_driver.draw_osd callback can be set to NULL to indicate missing OSD support (important so that vo_null etc. don't single-step on OSD redraw), and if OSD support depends on runtime support, the VO's draw_osd should just do nothing if OSD is not available. Also, do not access vo->want_redraw directly. Change the want_redraw reset logic for this purpose, too. (Probably unneeded, vo_flip_page resets it already.) --- video/filter/vf.c | 5 +---- video/filter/vf.h | 2 -- video/filter/vf_pp.c | 8 +++++--- video/filter/vf_sub.c | 1 - video/filter/vf_vo.c | 3 --- video/out/vo.c | 14 +++++++++----- video/out/vo.h | 2 +- video/out/vo_corevideo.m | 3 +-- video/out/vo_direct3d.c | 13 ++----------- video/out/vo_image.c | 2 +- video/out/vo_lavc.c | 4 +--- video/out/vo_null.c | 5 ----- video/out/vo_opengl.c | 3 +-- video/out/vo_opengl_old.c | 18 +++++------------- video/out/vo_sdl.c | 2 +- video/out/vo_vdpau.c | 2 +- video/out/vo_x11.c | 6 +++--- video/out/vo_xv.c | 2 +- video/vfcap.h | 2 -- 19 files changed, 33 insertions(+), 64 deletions(-) (limited to 'video') diff --git a/video/filter/vf.c b/video/filter/vf.c index 719ec395fb..aa1de0848b 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -463,10 +463,7 @@ int vf_next_control(struct vf_instance *vf, int request, void *data) int vf_next_query_format(struct vf_instance *vf, unsigned int fmt) { - int flags = vf->next->query_format(vf->next, fmt); - if (flags) - flags |= vf->default_caps; - return flags; + return vf->next->query_format(vf->next, fmt); } //============================================================================ diff --git a/video/filter/vf.h b/video/filter/vf.h index 1bc0d5121c..3ff4b5ea87 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -66,8 +66,6 @@ typedef struct vf_instance { void (*uninit)(struct vf_instance *vf); - // caps: - unsigned int default_caps; // used by default query_format() // data: struct vf_format fmt_in, fmt_out; struct vf_instance *next; diff --git a/video/filter/vf_pp.c b/video/filter/vf_pp.c index 157dc3e068..372fc81cad 100644 --- a/video/filter/vf_pp.c +++ b/video/filter/vf_pp.c @@ -75,8 +75,11 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){ case IMGFMT_444P: case IMGFMT_422P: case IMGFMT_420P: - case IMGFMT_411P: - return vf_next_query_format(vf,fmt); + case IMGFMT_411P: ; + int caps = vf_next_query_format(vf,fmt); + if (caps) + caps |= VFCAP_POSTPROC; + return caps; } return 0; } @@ -146,7 +149,6 @@ static int vf_open(vf_instance_t *vf, char *args){ vf->config=config; vf->filter=filter; vf->uninit=uninit; - vf->default_caps=VFCAP_POSTPROC; vf->priv=malloc(sizeof(struct vf_priv_s)); vf->priv->context=NULL; diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c index a1f25efd6d..ae1390b6e9 100644 --- a/video/filter/vf_sub.c +++ b/video/filter/vf_sub.c @@ -153,7 +153,6 @@ static int vf_open(vf_instance_t *vf, char *args) vf->uninit = uninit; vf->control = control; vf->filter = filter; - vf->default_caps = VFCAP_OSD; return 1; } diff --git a/video/filter/vf_vo.c b/video/filter/vf_vo.c index d8d00130d7..922229aa53 100644 --- a/video/filter/vf_vo.c +++ b/video/filter/vf_vo.c @@ -63,9 +63,6 @@ static int config(struct vf_instance *vf, if (vo_config(video_out, width, height, d_width, d_height, flags, outfmt)) return 0; - // save vo's stride capability for the wanted colorspace: - vf->default_caps = video_out->default_caps; - return 1; } diff --git a/video/out/vo.c b/video/out/vo.c index 76c71518e6..6fff185c6c 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -176,12 +176,20 @@ int vo_redraw_frame(struct vo *vo) if (!vo->config_ok || !vo->hasframe) return -1; if (vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) { + vo->want_redraw = false; vo->redrawing = true; return 0; } return -1; } +bool vo_get_want_redraw(struct vo *vo) +{ + if (!vo->config_ok || !vo->hasframe) + return false; + return vo->want_redraw; +} + int vo_get_buffered_frame(struct vo *vo, bool eof) { if (!vo->config_ok) @@ -216,7 +224,7 @@ void vo_new_frame_imminent(struct vo *vo) void vo_draw_osd(struct vo *vo, struct osd_state *osd) { - if (vo->config_ok && (vo->default_caps & VFCAP_OSD)) + if (vo->config_ok && vo->driver->draw_osd) vo->driver->draw_osd(vo, osd); } @@ -428,14 +436,10 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height, d_height = vo->dheight; } - vo->default_caps = vo->driver->query_format(vo, format); - int ret = vo->driver->config(vo, width, height, d_width, d_height, flags, format); vo->config_ok = (ret == 0); vo->config_count += vo->config_ok; - if (!vo->config_ok) - vo->default_caps = 0; if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) { mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback, NULL, vo); diff --git a/video/out/vo.h b/video/out/vo.h index 81cd61b9cc..ea0189dcee 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -227,7 +227,6 @@ struct vo_driver { struct vo { int config_ok; // Last config call was successful? int config_count; // Total number of successful config calls - int default_caps; // query_format() result for configured video format bool untimed; // non-interactive, don't do sleep calls in playloop @@ -291,6 +290,7 @@ void list_video_out(void); int vo_control(struct vo *vo, uint32_t request, void *data); int vo_draw_image(struct vo *vo, struct mp_image *mpi); int vo_redraw_frame(struct vo *vo); +bool vo_get_want_redraw(struct vo *vo); int vo_get_buffered_frame(struct vo *vo, bool eof); void vo_skip_frame(struct vo *vo); void vo_new_frame_imminent(struct vo *vo); diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.m index ab3bf4ac99..a1b5036dbf 100644 --- a/video/out/vo_corevideo.m +++ b/video/out/vo_corevideo.m @@ -245,8 +245,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) 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; + const int flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; switch (format) { case IMGFMT_YUYV: p->pixelFormat = kYUVSPixelFormat; diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c index 3886d67df0..8cb649be74 100644 --- a/video/out/vo_direct3d.c +++ b/video/out/vo_direct3d.c @@ -119,7 +119,6 @@ typedef struct d3d_priv { int opt_disable_stretchrect; int opt_disable_shaders; int opt_only_8bit; - int opt_disable_osd; int opt_disable_texture_align; // debugging int opt_force_power_of_2; @@ -1124,10 +1123,7 @@ static int query_format(struct vo *vo, uint32_t movie_fmt) if (!init_rendering_mode(priv, movie_fmt, false)) return 0; - int osd_caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; - if (!priv->opt_disable_osd) - osd_caps |= VFCAP_OSD; - return osd_caps; + return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; } /**************************************************************************** @@ -1160,7 +1156,7 @@ static void update_colorspace(d3d_priv *priv) } const char *options_help_text = "-vo direct3d command line help:\n" -"Example: -vo direct3d:disable-osd:disable-textures\n" +"Example: -vo direct3d:disable-textures\n" "Options:\n" " prefer-stretchrect\n" " Use IDirect3DDevice9::StretchRect over other methods if possible.\n" @@ -1175,10 +1171,6 @@ 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-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" " Normally texture sizes are always aligned to 16. With this option\n" " enabled, the video texture will always have exactly the same size as\n" @@ -1240,7 +1232,6 @@ 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-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}, diff --git a/video/out/vo_image.c b/video/out/vo_image.c index 95caf2611f..d39df5851c 100644 --- a/video/out/vo_image.c +++ b/video/out/vo_image.c @@ -145,7 +145,7 @@ static void flip_page(struct vo *vo) static int query_format(struct vo *vo, uint32_t fmt) { if (mp_sws_supported_format(fmt)) - return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD; + return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; return 0; } diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index 2a07a67b0b..f9534b02e7 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -187,10 +187,8 @@ static int query_format(struct vo *vo, uint32_t format) return VFCAP_CSP_SUPPORTED | // we can do it - VFCAP_CSP_SUPPORTED_BY_HW | + VFCAP_CSP_SUPPORTED_BY_HW; // we don't convert colorspaces here - VFCAP_OSD; - // we have OSD } static void write_packet(struct vo *vo, int size, AVPacket *packet) diff --git a/video/out/vo_null.c b/video/out/vo_null.c index c1e931f806..993fcb606c 100644 --- a/video/out/vo_null.c +++ b/video/out/vo_null.c @@ -34,10 +34,6 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) { } -static void draw_osd(struct vo *vo, struct osd_state *osd) -{ -} - static void flip_page(struct vo *vo) { } @@ -90,7 +86,6 @@ const struct vo_driver video_out_null = { .config = config, .control = control, .draw_image = draw_image, - .draw_osd = draw_osd, .flip_page = flip_page, .check_events = check_events, .uninit = uninit, diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 4a34d0f03a..aa3c3cea0a 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -1617,8 +1617,7 @@ static bool init_format(int fmt, struct gl_priv *init) static int query_format(struct vo *vo, uint32_t format) { - int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIP | - VFCAP_OSD; + int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIP; if (!init_format(format, NULL)) return 0; return caps; diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index 80175c516b..0f286dc72a 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -55,7 +55,6 @@ struct gl_priv { int allow_sw; - int use_osd; int scaled_osd; struct mpgl_osd *osd; int osd_color; @@ -1468,9 +1467,8 @@ 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) + if (!p->osd) return; if (!p->scaled_osd) { @@ -1572,8 +1570,6 @@ static void autodetectGlExtensions(struct vo *vo) && strstr(renderer, "Mesa DRI R200") ? 1 : 0; } } - if (p->use_osd == -1) - p->use_osd = gl->BindTexture != NULL; if (p->use_yuv == -1) p->use_yuv = glAutodetectYUVConversion(gl); @@ -1711,8 +1707,10 @@ static int initGl(struct vo *vo, uint32_t d_width, uint32_t d_height) update_yuvconv(vo); } - p->osd = mpgl_osd_init(gl, true); - p->osd->scaled = p->scaled_osd; + if (gl->BindTexture) { + p->osd = mpgl_osd_init(gl, true); + p->osd->scaled = p->scaled_osd; + } resize(vo, d_width, d_height); @@ -2068,8 +2066,6 @@ static int query_format(struct vo *vo, uint32_t format) int depth = desc.plane_bits; int caps = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_FLIP; - if (p->use_osd) - caps |= VFCAP_OSD; if (format == IMGFMT_RGB24 || format == IMGFMT_RGBA) return caps; if (p->use_yuv && (desc.flags & MP_IMGFLAG_YUV_P) && @@ -2115,7 +2111,6 @@ static int preinit(struct vo *vo, const char *arg) *p = (struct gl_priv) { .many_fmts = 1, - .use_osd = -1, .use_yuv = -1, .colorspace = MP_CSP_DETAILS_DEFAULTS, .filter_strength = 0.5, @@ -2138,7 +2133,6 @@ static int preinit(struct vo *vo, const char *arg) const opt_t subopts[] = { {"manyfmts", OPT_ARG_BOOL, &p->many_fmts, NULL}, - {"osd", OPT_ARG_BOOL, &p->use_osd, NULL}, {"scaled-osd", OPT_ARG_BOOL, &p->scaled_osd, NULL}, {"ycbcr", OPT_ARG_BOOL, &p->use_ycbcr, NULL}, {"slice-height", OPT_ARG_INT, &p->slice_height, int_non_neg}, @@ -2178,8 +2172,6 @@ static int preinit(struct vo *vo, const char *arg) " Disable extended color formats for OpenGL 1.2 and later\n" " slice-height=<0-...>\n" " Slice size for texture transfer, 0 for whole image\n" - " noosd\n" - " Do not use OpenGL OSD code\n" " scaled-osd\n" " Render OSD at movie resolution and scale it\n" " rectangle=<0,1,2>\n" diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 69ecf273c0..45486afbfd 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -804,7 +804,7 @@ static int query_format(struct vo *vo, uint32_t format) { struct priv *vc = vo->priv; int i, j; - int cap = VFCAP_CSP_SUPPORTED | VFCAP_FLIP | VFCAP_OSD; + int cap = VFCAP_CSP_SUPPORTED | VFCAP_FLIP; for (i = 0; i < vc->renderer_info.num_texture_formats; ++i) for (j = 0; j < sizeof(formats) / sizeof(formats[0]); ++j) if (vc->renderer_info.texture_formats[i] == formats[j].sdl) diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 9890db13ea..e46e4639b6 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -1380,7 +1380,7 @@ static struct mp_image *get_decoder_surface(struct vo *vo) static int query_format(struct vo *vo, uint32_t format) { int default_flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW - | VFCAP_OSD | VFCAP_FLIP; + | VFCAP_FLIP; switch (format) { case IMGFMT_420P: case IMGFMT_NV12: diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 0ab3c9ebcb..34c23523ef 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -610,9 +610,9 @@ static int query_format(struct vo *vo, uint32_t format) if (fmt2Xfmt[n].mpfmt == format) { if (IMGFMT_RGB_DEPTH(format) == p->ximage_depth) { return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | - VFCAP_OSD | VFCAP_FLIP; + VFCAP_FLIP; } else { - return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_FLIP; + return VFCAP_CSP_SUPPORTED | VFCAP_FLIP; } } } @@ -620,7 +620,7 @@ static int query_format(struct vo *vo, uint32_t format) switch (format) { case IMGFMT_420P: - return VFCAP_CSP_SUPPORTED | VFCAP_OSD; + return VFCAP_CSP_SUPPORTED; } return 0; } diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index cb22e960a1..bc0920c2eb 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -767,7 +767,7 @@ static int query_format(struct vo *vo, uint32_t format) { struct xvctx *ctx = vo->priv; uint32_t i; - int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD; + int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; int fourcc = find_xv_format(format); if (fourcc) { diff --git a/video/vfcap.h b/video/vfcap.h index 8758e30ada..f67fcd5496 100644 --- a/video/vfcap.h +++ b/video/vfcap.h @@ -24,8 +24,6 @@ #define VFCAP_CSP_SUPPORTED 0x1 // set, if the given colorspace is supported _without_ conversion #define VFCAP_CSP_SUPPORTED_BY_HW 0x2 -// set if the driver/filter can draw OSD -#define VFCAP_OSD 0x4 // driver/filter can do vertical flip (upside-down) #define VFCAP_FLIP 0x80 -- cgit v1.2.3