From 0d929bc53211ed9bc8f8c3efe538698dd7b7b401 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 22 Oct 2011 23:44:27 +0200 Subject: vo_direct3d: minor cleanup The code assumed the last format passed to query_format will be the one that is used on playback. This is probably true and thus didn't cause any bugs, but make query_format side effect free just like the other VOs. --- libvo/vo_direct3d.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c index 2fb40d0398..02763734cd 100644 --- a/libvo/vo_direct3d.c +++ b/libvo/vo_direct3d.c @@ -609,12 +609,7 @@ skip_upload: return VO_TRUE; } - -/** @brief Query if movie colorspace is supported by the HW. - * @return 0 on failure, device capabilities (not probed - * currently) on success. - */ -static int query_format(uint32_t movie_fmt) +static const struct_fmt_table *check_format(uint32_t movie_fmt) { int i; for (i = 0; i < DISPLAY_FORMAT_TABLE_ENTRIES; i++) { @@ -628,21 +623,33 @@ static int query_format(uint32_t movie_fmt) priv->desktop_fmt))) { mp_msg(MSGT_VO, MSGL_V, "Rejected image format: %s\n", vo_format_name(fmt_table[i].mplayer_fmt)); - return 0; + return NULL; } - priv->movie_src_fmt = fmt_table[i].fourcc; mp_msg(MSGT_VO, MSGL_V, "Accepted image format: %s\n", vo_format_name(fmt_table[i].mplayer_fmt)); - return (VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW - | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN); + return &fmt_table[i]; } } return 0; } + +/** @brief Query if movie colorspace is supported by the HW. + * @return 0 on failure, device capabilities (not probed + * currently) on success. + */ +static int query_format(uint32_t movie_fmt) +{ + if (!check_format(movie_fmt)) + return 0; + + return (VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW + | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN); +} + /**************************************************************************** * * * * @@ -825,6 +832,12 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, priv->src_width = width; priv->src_height = height; + const struct_fmt_table *fmt_entry = check_format(format); + if (!fmt_entry) + return VO_ERROR; + + priv->movie_src_fmt = fmt_entry->fourcc; + /* w32_common framework call. Creates window on the screen with * the given coordinates. */ -- cgit v1.2.3