diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/cfg-mplayer.h | 2 | ||||
-rw-r--r-- | core/m_option.c | 35 | ||||
-rw-r--r-- | core/m_option.h | 3 | ||||
-rw-r--r-- | core/mp_common.h | 3 |
4 files changed, 42 insertions, 1 deletions
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index 9627a25140..0aef77ae70 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -107,7 +107,7 @@ const m_option_t tvopts_conf[]={ {"width", &stream_tv_defaults.width, CONF_TYPE_INT, 0, 0, 4096, NULL}, {"height", &stream_tv_defaults.height, CONF_TYPE_INT, 0, 0, 4096, NULL}, {"input", &stream_tv_defaults.input, CONF_TYPE_INT, 0, 0, 20, NULL}, - {"outfmt", &stream_tv_defaults.outfmt, CONF_TYPE_IMGFMT, 0, 0, 0, NULL}, + {"outfmt", &stream_tv_defaults.outfmt, CONF_TYPE_FOURCC, 0, 0, 0, NULL}, {"fps", &stream_tv_defaults.fps, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL}, {"channels", &stream_tv_defaults.channels, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, {"brightness", &stream_tv_defaults.brightness, CONF_TYPE_INT, CONF_RANGE, -100, 100, NULL}, diff --git a/core/m_option.c b/core/m_option.c index 7ea25c25b0..82f6265124 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -1203,6 +1203,41 @@ const m_option_type_t m_option_type_imgfmt = { .copy = copy_opt, }; +static int parse_fourcc(const m_option_t *opt, struct bstr name, + struct bstr param, void *dst) +{ + if (param.len == 0) + return M_OPT_MISSING_PARAM; + + unsigned int value; + + if (param.len == 4) { + uint8_t *s = param.start; + value = s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24); + } else { + bstr rest; + value = bstrtoll(param, &rest, 16); + if (rest.len != 0) { + mp_msg(MSGT_CFGPARSER, MSGL_ERR, + "Option %.*s: invalid FourCC: '%.*s'\n", + BSTR_P(name), BSTR_P(param)); + return M_OPT_INVALID; + } + } + + if (dst) + *((unsigned int *)dst) = value; + + return 1; +} + +const m_option_type_t m_option_type_fourcc = { + .name = "FourCC", + .size = sizeof(unsigned int), + .parse = parse_fourcc, + .copy = copy_opt, +}; + #include "audio/format.h" static int parse_afmt(const m_option_t *opt, struct bstr name, diff --git a/core/m_option.h b/core/m_option.h index 20bcfba1c2..f6c346521a 100644 --- a/core/m_option.h +++ b/core/m_option.h @@ -53,6 +53,7 @@ extern const m_option_type_t m_option_type_print_func_param; extern const m_option_type_t m_option_type_subconfig; extern const m_option_type_t m_option_type_subconfig_struct; extern const m_option_type_t m_option_type_imgfmt; +extern const m_option_type_t m_option_type_fourcc; extern const m_option_type_t m_option_type_afmt; extern const m_option_type_t m_option_type_color; @@ -177,6 +178,7 @@ struct m_sub_options { #define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig) #define CONF_TYPE_STRING_LIST (&m_option_type_string_list) #define CONF_TYPE_IMGFMT (&m_option_type_imgfmt) +#define CONF_TYPE_FOURCC (&m_option_type_fourcc) #define CONF_TYPE_AFMT (&m_option_type_afmt) #define CONF_TYPE_SPAN (&m_option_type_span) #define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list) @@ -198,6 +200,7 @@ union m_option_value { char *string; char **string_list; int imgfmt; + unsigned int fourcc; int afmt; m_span_t span; m_obj_settings_t *obj_settings_list; diff --git a/core/mp_common.h b/core/mp_common.h index 184cea2a32..0ee14ab484 100644 --- a/core/mp_common.h +++ b/core/mp_common.h @@ -28,6 +28,9 @@ // both int64_t and double should be able to represent this exactly #define MP_NOPTS_VALUE (-1LL<<63) +#define MP_CONCAT_(a, b) a ## b +#define MP_CONCAT(a, b) MP_CONCAT_(a, b) + #define ROUND(x) ((int)((x) < 0 ? (x) - 0.5 : (x) + 0.5)) extern const char *mplayer_version; |