options: cleanup hwdec name mappings

Now there's a "canonical" table for mapping the names, that other code
can use, without having to rely too much on option code magic.

Also, use the central HWDEC constants, instead of magic values. (There
used to be semi-ok reasons to do this, but now it makes no sense
anymore.)
This commit is contained in:
wm4 2015-07-07 14:25:37 +02:00
parent dc33eb56f4
commit 1d29177c5c
2 changed files with 20 additions and 10 deletions

View File

@ -38,6 +38,7 @@
#include "common/common.h" #include "common/common.h"
#include "stream/stream.h" #include "stream/stream.h"
#include "video/csputils.h" #include "video/csputils.h"
#include "video/hwdec.h"
#include "sub/osd.h" #include "sub/osd.h"
#include "audio/mixer.h" #include "audio/mixer.h"
#include "audio/filter/af.h" #include "audio/filter/af.h"
@ -79,6 +80,18 @@ extern const struct m_obj_list af_obj_list;
extern const struct m_obj_list vo_obj_list; extern const struct m_obj_list vo_obj_list;
extern const struct m_obj_list ao_obj_list; extern const struct m_obj_list ao_obj_list;
const struct m_opt_choice_alternatives mp_hwdec_names[] = {
{"no", HWDEC_NONE},
{"auto", HWDEC_AUTO},
{"vdpau", HWDEC_VDPAU},
{"vda", HWDEC_VDA},
{"vaapi", HWDEC_VAAPI},
{"vaapi-copy", HWDEC_VAAPI_COPY},
{"dxva2-copy", HWDEC_DXVA2_COPY},
{"rpi", HWDEC_RPI},
{0}
};
#define OPT_BASE_STRUCT struct MPOpts #define OPT_BASE_STRUCT struct MPOpts
const m_option_t mp_opts[] = { const m_option_t mp_opts[] = {
@ -283,15 +296,7 @@ const m_option_t mp_opts[] = {
OPT_FLAG("ad-spdif-dtshd", dtshd, 0), OPT_FLAG("ad-spdif-dtshd", dtshd, 0),
OPT_CHOICE("hwdec", hwdec_api, 0, OPT_CHOICE_C("hwdec", hwdec_api, 0, mp_hwdec_names),
({"no", 0},
{"auto", -1},
{"vdpau", 1},
{"vda", 2},
{"vaapi", 4},
{"vaapi-copy", 5},
{"dxva2-copy", 6},
{"rpi", 7})),
OPT_STRING("hwdec-codecs", hwdec_codecs, 0), OPT_STRING("hwdec-codecs", hwdec_codecs, 0),
OPT_SUBSTRUCT("sws", vo.sws_opts, sws_conf, 0), OPT_SUBSTRUCT("sws", vo.sws_opts, sws_conf, 0),

View File

@ -1,9 +1,11 @@
#ifndef MP_HWDEC_H_ #ifndef MP_HWDEC_H_
#define MP_HWDEC_H_ #define MP_HWDEC_H_
#include "options/m_option.h"
struct mp_image_pool; struct mp_image_pool;
// keep in sync with --hwdec option // keep in sync with --hwdec option (see mp_hwdec_names)
enum hwdec_type { enum hwdec_type {
HWDEC_AUTO = -1, HWDEC_AUTO = -1,
HWDEC_NONE = 0, HWDEC_NONE = 0,
@ -15,6 +17,9 @@ enum hwdec_type {
HWDEC_RPI = 7, HWDEC_RPI = 7,
}; };
// hwdec_type names (options.c)
extern const struct m_opt_choice_alternatives mp_hwdec_names[];
struct mp_hwdec_ctx { struct mp_hwdec_ctx {
enum hwdec_type type; enum hwdec_type type;