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.)
This commit is contained in:
wm4 2013-03-01 11:16:01 +01:00
parent 6b3d510165
commit d511ef79a0
21 changed files with 35 additions and 77 deletions

View File

@ -171,11 +171,6 @@ 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-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.)
disable-texture-align
Normally texture sizes are always aligned to 16. With this option
enabled, the video texture will always have exactly the same size as
@ -628,11 +623,6 @@ opengl-old
setting has no effect, the size of the slices as provided by the
decoder is used. If the decoder does not use slice rendering, the
default is 16.
(no-)osd
Enable or disable support for OSD rendering via OpenGL (default:
enabled). This option is for testing; to disable the OSD use
``--osd-level=0`` instead.
sw
Continue even if a software renderer is detected.

View File

@ -2634,7 +2634,6 @@ static void draw_osd(struct MPContext *mpctx)
mpctx->osd->vo_pts = mpctx->video_pts;
vo_draw_osd(vo, mpctx->osd);
mpctx->osd->want_redraw = false;
}
static bool redraw_osd(struct MPContext *mpctx)
@ -3458,8 +3457,8 @@ static void run_playloop(struct MPContext *mpctx)
}
sleeptime = FFMIN(sleeptime, audio_sleep);
if (sleeptime > 0 && mpctx->sh_video) {
bool want_redraw = mpctx->video_out->want_redraw;
if (mpctx->video_out->default_caps & VFCAP_OSD)
bool want_redraw = vo_get_want_redraw(mpctx->video_out);
if (mpctx->video_out->driver->draw_osd)
want_redraw |= mpctx->osd->want_redraw;
mpctx->osd->want_redraw = false;
if (want_redraw) {

View File

@ -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);
}
//============================================================================

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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},

View File

@ -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;
}

View File

@ -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)

View File

@ -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,

View File

@ -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;

View File

@ -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"

View File

@ -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)

View File

@ -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:

View File

@ -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;
}

View File

@ -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) {

View File

@ -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