2010-01-30 23:24:23 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_M_OPTION_H
|
|
|
|
#define MPLAYER_M_OPTION_H
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2008-03-04 23:35:24 +00:00
|
|
|
#include <string.h>
|
2008-04-28 03:19:53 +00:00
|
|
|
#include <stddef.h>
|
2011-07-27 17:59:44 +00:00
|
|
|
#include <stdbool.h>
|
2008-03-04 23:35:24 +00:00
|
|
|
|
2011-04-19 01:11:52 +00:00
|
|
|
#include "config.h"
|
2013-08-06 20:41:30 +00:00
|
|
|
#include "mpvcore/bstr.h"
|
2013-04-06 20:43:12 +00:00
|
|
|
#include "audio/chmap.h"
|
2011-04-19 01:11:52 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// m_option allows to parse, print and copy data of various types.
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2002-11-12 01:56:42 +00:00
|
|
|
typedef struct m_option_type m_option_type_t;
|
|
|
|
typedef struct m_option m_option_t;
|
2013-07-31 18:45:06 +00:00
|
|
|
struct m_config;
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
///////////////////////////// Options types declarations ////////////////////
|
2002-11-12 01:56:42 +00:00
|
|
|
|
|
|
|
// Simple types
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_flag;
|
2012-09-20 01:32:01 +00:00
|
|
|
extern const m_option_type_t m_option_type_store;
|
2013-03-01 10:21:13 +00:00
|
|
|
extern const m_option_type_t m_option_type_float_store;
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_int;
|
2009-03-02 11:17:50 +00:00
|
|
|
extern const m_option_type_t m_option_type_int64;
|
2010-04-24 17:09:31 +00:00
|
|
|
extern const m_option_type_t m_option_type_intpair;
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_float;
|
|
|
|
extern const m_option_type_t m_option_type_double;
|
|
|
|
extern const m_option_type_t m_option_type_string;
|
|
|
|
extern const m_option_type_t m_option_type_string_list;
|
|
|
|
extern const m_option_type_t m_option_type_time;
|
2012-11-15 17:49:17 +00:00
|
|
|
extern const m_option_type_t m_option_type_rel_time;
|
2010-12-17 23:00:28 +00:00
|
|
|
extern const m_option_type_t m_option_type_choice;
|
2007-11-09 06:50:53 +00:00
|
|
|
|
|
|
|
extern const m_option_type_t m_option_type_print;
|
|
|
|
extern const m_option_type_t m_option_type_print_func;
|
2012-08-05 21:34:28 +00:00
|
|
|
extern const m_option_type_t m_option_type_print_func_param;
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_subconfig;
|
2012-08-06 15:45:17 +00:00
|
|
|
extern const m_option_type_t m_option_type_subconfig_struct;
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_imgfmt;
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
extern const m_option_type_t m_option_type_fourcc;
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_afmt;
|
2012-11-17 18:58:57 +00:00
|
|
|
extern const m_option_type_t m_option_type_color;
|
2013-01-23 09:56:11 +00:00
|
|
|
extern const m_option_type_t m_option_type_geometry;
|
2013-01-23 09:56:36 +00:00
|
|
|
extern const m_option_type_t m_option_type_size_box;
|
2013-04-05 13:25:09 +00:00
|
|
|
extern const m_option_type_t m_option_type_chmap;
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2012-05-07 23:10:39 +00:00
|
|
|
// Callback used by m_option_type_print_func options.
|
2010-02-25 22:32:28 +00:00
|
|
|
typedef int (*m_opt_func_full_t)(const m_option_t *, const char *, const char *);
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2012-11-15 17:49:17 +00:00
|
|
|
enum m_rel_time_type {
|
|
|
|
REL_TIME_NONE,
|
|
|
|
REL_TIME_ABSOLUTE,
|
|
|
|
REL_TIME_NEGATIVE,
|
|
|
|
REL_TIME_PERCENT,
|
2012-11-18 17:02:14 +00:00
|
|
|
REL_TIME_CHAPTER,
|
2012-11-15 17:49:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct m_rel_time {
|
2011-07-03 12:42:04 +00:00
|
|
|
double pos;
|
2012-11-15 17:49:17 +00:00
|
|
|
enum m_rel_time_type type;
|
|
|
|
};
|
2006-09-25 16:47:56 +00:00
|
|
|
|
2012-11-17 18:58:57 +00:00
|
|
|
struct m_color {
|
|
|
|
uint8_t r, g, b, a;
|
|
|
|
};
|
|
|
|
|
2013-01-23 09:56:11 +00:00
|
|
|
struct m_geometry {
|
|
|
|
int x, y, w, h;
|
|
|
|
bool xy_valid : 1, wh_valid : 1;
|
2013-01-23 09:56:27 +00:00
|
|
|
bool w_per : 1, h_per : 1;
|
2013-01-23 09:56:11 +00:00
|
|
|
bool x_sign : 1, y_sign : 1, x_per : 1, y_per : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,
|
|
|
|
int scrw, int scrh, struct m_geometry *gm);
|
|
|
|
|
options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except
that m_config is much more powerful. m_config is used for VOs and some
other things, so to unify them. We plan to kick out m_struct and use
m_config for everything. (Unfortunately, m_config is also a bit more
bloated, so this commit isn't all that great, but it will allow to
reduce the option parser mess somewhat.)
This commit also switches all video filters to use the option macros.
One reason is that m_struct and m_config, even though they both use
m_option, store the offsets of the option fields differently (sigh...),
meaning the options defined for either are incompatible. It's easier to
switch everything in one go.
This commit will allow using the -vf option parser for other things,
like VOs and AOs.
2013-07-21 17:33:08 +00:00
|
|
|
struct m_obj_desc {
|
|
|
|
// Name which will be used in the option string
|
|
|
|
const char *name;
|
|
|
|
// Will be printed when "help" is passed
|
|
|
|
const char *description;
|
|
|
|
// Size of the private struct
|
|
|
|
int priv_size;
|
|
|
|
// If not NULL, default values for private struct
|
|
|
|
const void *priv_defaults;
|
|
|
|
// Options which refer to members in the private struct
|
|
|
|
const struct m_option *options;
|
|
|
|
// For free use by the implementer of m_obj_list.get_desc
|
|
|
|
const void *p;
|
2013-07-21 19:17:25 +00:00
|
|
|
// If not NULL, options which should be set before applying other options.
|
|
|
|
// This member is usually set my m_obj_list_find() only.
|
|
|
|
// Only works if options is not NULL.
|
|
|
|
const char *init_options;
|
2013-07-21 20:03:53 +00:00
|
|
|
// Don't list entries with "help"
|
|
|
|
bool hidden;
|
options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except
that m_config is much more powerful. m_config is used for VOs and some
other things, so to unify them. We plan to kick out m_struct and use
m_config for everything. (Unfortunately, m_config is also a bit more
bloated, so this commit isn't all that great, but it will allow to
reduce the option parser mess somewhat.)
This commit also switches all video filters to use the option macros.
One reason is that m_struct and m_config, even though they both use
m_option, store the offsets of the option fields differently (sigh...),
meaning the options defined for either are incompatible. It's easier to
switch everything in one go.
This commit will allow using the -vf option parser for other things,
like VOs and AOs.
2013-07-21 17:33:08 +00:00
|
|
|
};
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Extra definition needed for \ref m_option_type_obj_settings_list options.
|
options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except
that m_config is much more powerful. m_config is used for VOs and some
other things, so to unify them. We plan to kick out m_struct and use
m_config for everything. (Unfortunately, m_config is also a bit more
bloated, so this commit isn't all that great, but it will allow to
reduce the option parser mess somewhat.)
This commit also switches all video filters to use the option macros.
One reason is that m_struct and m_config, even though they both use
m_option, store the offsets of the option fields differently (sigh...),
meaning the options defined for either are incompatible. It's easier to
switch everything in one go.
This commit will allow using the -vf option parser for other things,
like VOs and AOs.
2013-07-21 17:33:08 +00:00
|
|
|
struct m_obj_list {
|
|
|
|
bool (*get_desc)(struct m_obj_desc *dst, int index);
|
|
|
|
const char *description;
|
2013-07-21 19:17:25 +00:00
|
|
|
// Can be set to a NULL terminated array of aliases
|
|
|
|
const char *aliases[4][5];
|
|
|
|
// Allow a trailing ",", which adds an entry with name=""
|
|
|
|
bool allow_trailer;
|
|
|
|
// Allow unknown entries, for which a dummy entry is inserted, and whose
|
|
|
|
// options are skipped and ignored.
|
|
|
|
bool allow_unknown_entries;
|
2013-07-22 21:06:22 +00:00
|
|
|
// If object has no options set, assume it parses options on its own.
|
|
|
|
bool legacy_hacks;
|
options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except
that m_config is much more powerful. m_config is used for VOs and some
other things, so to unify them. We plan to kick out m_struct and use
m_config for everything. (Unfortunately, m_config is also a bit more
bloated, so this commit isn't all that great, but it will allow to
reduce the option parser mess somewhat.)
This commit also switches all video filters to use the option macros.
One reason is that m_struct and m_config, even though they both use
m_option, store the offsets of the option fields differently (sigh...),
meaning the options defined for either are incompatible. It's easier to
switch everything in one go.
This commit will allow using the -vf option parser for other things,
like VOs and AOs.
2013-07-21 17:33:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Find entry by name
|
|
|
|
bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *list,
|
|
|
|
bstr name);
|
2003-03-15 18:01:02 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// The data type used by \ref m_option_type_obj_settings_list.
|
2006-04-24 19:20:04 +00:00
|
|
|
typedef struct m_obj_settings {
|
2011-07-03 12:42:04 +00:00
|
|
|
// Type of the object.
|
|
|
|
char *name;
|
2013-05-22 21:19:57 +00:00
|
|
|
// Optional user-defined name.
|
|
|
|
char *label;
|
2011-07-03 12:42:04 +00:00
|
|
|
// NULL terminated array of parameter/value pairs.
|
|
|
|
char **attribs;
|
2003-03-15 18:01:02 +00:00
|
|
|
} m_obj_settings_t;
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// A parser to set up a list of objects.
|
2006-04-25 18:48:53 +00:00
|
|
|
/** It creates a NULL terminated array \ref m_obj_settings. The option priv
|
2006-04-24 19:20:04 +00:00
|
|
|
* field (\ref m_option::priv) must point to a \ref m_obj_list_t describing
|
|
|
|
* the available object types.
|
|
|
|
*/
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_obj_settings_list;
|
2003-03-15 18:01:02 +00:00
|
|
|
|
2013-07-31 18:45:06 +00:00
|
|
|
int m_obj_parse_sub_config(struct bstr opt_name, struct bstr name,
|
|
|
|
struct bstr *pstr, struct m_config *config,
|
|
|
|
int flags, char ***ret);
|
|
|
|
|
2010-12-17 23:00:28 +00:00
|
|
|
struct m_opt_choice_alternatives {
|
|
|
|
char *name;
|
|
|
|
int value;
|
|
|
|
};
|
|
|
|
|
2013-03-01 20:19:20 +00:00
|
|
|
// For OPT_STRING_VALIDATE(). Behaves like m_option_type.parse().
|
|
|
|
typedef int (*m_opt_string_validate_fn)(const m_option_t *opt, struct bstr name,
|
|
|
|
struct bstr param);
|
|
|
|
|
2012-08-06 15:45:17 +00:00
|
|
|
// m_option.priv points to this if M_OPT_TYPE_USE_SUBSTRUCT is used
|
|
|
|
struct m_sub_options {
|
|
|
|
const struct m_option *opts;
|
|
|
|
size_t size;
|
|
|
|
const void *defaults;
|
|
|
|
};
|
2003-04-02 16:11:15 +00:00
|
|
|
|
2003-08-13 16:29:32 +00:00
|
|
|
// FIXME: backward compatibility
|
2011-07-03 12:42:04 +00:00
|
|
|
#define CONF_TYPE_FLAG (&m_option_type_flag)
|
2012-09-20 01:32:01 +00:00
|
|
|
#define CONF_TYPE_STORE (&m_option_type_store)
|
2011-07-03 12:42:04 +00:00
|
|
|
#define CONF_TYPE_INT (&m_option_type_int)
|
|
|
|
#define CONF_TYPE_INT64 (&m_option_type_int64)
|
|
|
|
#define CONF_TYPE_FLOAT (&m_option_type_float)
|
|
|
|
#define CONF_TYPE_DOUBLE (&m_option_type_double)
|
|
|
|
#define CONF_TYPE_STRING (&m_option_type_string)
|
|
|
|
#define CONF_TYPE_PRINT (&m_option_type_print)
|
|
|
|
#define CONF_TYPE_PRINT_FUNC (&m_option_type_print_func)
|
|
|
|
#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)
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
#define CONF_TYPE_FOURCC (&m_option_type_fourcc)
|
2011-07-03 12:42:04 +00:00
|
|
|
#define CONF_TYPE_AFMT (&m_option_type_afmt)
|
2003-03-15 18:01:02 +00:00
|
|
|
#define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list)
|
2011-07-03 12:42:04 +00:00
|
|
|
#define CONF_TYPE_TIME (&m_option_type_time)
|
2012-11-15 14:32:55 +00:00
|
|
|
#define CONF_TYPE_CHOICE (&m_option_type_choice)
|
2013-04-20 23:43:09 +00:00
|
|
|
#define CONF_TYPE_INT_PAIR (&m_option_type_intpair)
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2012-09-18 14:08:17 +00:00
|
|
|
// Possible option values. Code is allowed to access option data without going
|
|
|
|
// through this union. It serves for self-documentation and to get minimal
|
|
|
|
// size/alignment requirements for option values in general.
|
|
|
|
union m_option_value {
|
|
|
|
int flag; // not the C type "bool"!
|
2012-09-20 01:32:01 +00:00
|
|
|
int store;
|
2013-03-01 10:21:13 +00:00
|
|
|
float float_store;
|
2012-09-18 14:08:17 +00:00
|
|
|
int int_;
|
|
|
|
int64_t int64;
|
2013-03-01 10:21:13 +00:00
|
|
|
int intpair[2];
|
2012-09-18 14:08:17 +00:00
|
|
|
float float_;
|
|
|
|
double double_;
|
|
|
|
char *string;
|
|
|
|
char **string_list;
|
|
|
|
int imgfmt;
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
unsigned int fourcc;
|
2012-09-18 14:08:17 +00:00
|
|
|
int afmt;
|
|
|
|
m_obj_settings_t *obj_settings_list;
|
|
|
|
double time;
|
2012-11-15 17:49:17 +00:00
|
|
|
struct m_rel_time rel_time;
|
2012-11-17 18:58:57 +00:00
|
|
|
struct m_color color;
|
2013-01-23 09:56:11 +00:00
|
|
|
struct m_geometry geometry;
|
2013-01-23 09:56:36 +00:00
|
|
|
struct m_geometry size_box;
|
2013-04-06 20:43:12 +00:00
|
|
|
struct mp_chmap chmap;
|
2012-09-18 14:08:17 +00:00
|
|
|
};
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Option type description
|
2002-11-12 01:56:42 +00:00
|
|
|
struct m_option_type {
|
2011-07-03 12:42:04 +00:00
|
|
|
const char *name;
|
|
|
|
// Size needed for the data.
|
|
|
|
unsigned int size;
|
2012-08-05 21:34:28 +00:00
|
|
|
// One of M_OPT_TYPE*.
|
2011-07-03 12:42:04 +00:00
|
|
|
unsigned int flags;
|
|
|
|
|
|
|
|
// Parse the data from a string.
|
|
|
|
/** It is the only required function, all others can be NULL.
|
|
|
|
*
|
|
|
|
* \param opt The option that is parsed.
|
|
|
|
* \param name The full option name.
|
|
|
|
* \param param The parameter to parse.
|
2011-07-27 17:59:44 +00:00
|
|
|
* may not be an argument meant for this option
|
2011-07-03 12:42:04 +00:00
|
|
|
* \param dst Pointer to the memory where the data should be written.
|
|
|
|
* If NULL the parameter validity should still be checked.
|
2011-07-27 17:59:44 +00:00
|
|
|
* \return On error a negative value is returned, on success the number
|
|
|
|
* of arguments consumed. For details see \ref OptionParserReturn.
|
2011-07-03 12:42:04 +00:00
|
|
|
*/
|
2011-07-28 08:07:47 +00:00
|
|
|
int (*parse)(const m_option_t *opt, struct bstr name, struct bstr param,
|
2012-08-05 21:34:28 +00:00
|
|
|
void *dst);
|
2011-07-03 12:42:04 +00:00
|
|
|
|
|
|
|
// Print back a value in string form.
|
|
|
|
/** \param opt The option to print.
|
|
|
|
* \param val Pointer to the memory holding the data to be printed.
|
|
|
|
* \return An allocated string containing the text value or (void*)-1
|
|
|
|
* on error.
|
|
|
|
*/
|
|
|
|
char *(*print)(const m_option_t *opt, const void *val);
|
|
|
|
|
2012-09-18 13:31:46 +00:00
|
|
|
// Print the value in a human readable form. Unlike print(), it doesn't
|
|
|
|
// necessarily return the exact value, and is generally not parseable with
|
|
|
|
// parse().
|
|
|
|
char *(*pretty_print)(const m_option_t *opt, const void *val);
|
|
|
|
|
2012-05-07 23:10:39 +00:00
|
|
|
// Copy data between two locations. Deep copy if the data has pointers.
|
2011-07-03 12:42:04 +00:00
|
|
|
/** \param opt The option to copy.
|
|
|
|
* \param dst Pointer to the destination memory.
|
|
|
|
* \param src Pointer to the source memory.
|
|
|
|
*/
|
2012-08-04 09:14:38 +00:00
|
|
|
void (*copy)(const m_option_t *opt, void *dst, const void *src);
|
2011-07-03 12:42:04 +00:00
|
|
|
|
|
|
|
// Free the data allocated for a save slot.
|
|
|
|
/** This is only needed for dynamic types like strings.
|
|
|
|
* \param dst Pointer to the data, usually a pointer that should be freed and
|
|
|
|
* set to NULL.
|
|
|
|
*/
|
|
|
|
void (*free)(void *dst);
|
2012-09-18 12:00:08 +00:00
|
|
|
|
|
|
|
// Add the value add to the value in val. For types that are not numeric,
|
|
|
|
// add gives merely the direction. The wrap parameter determines whether
|
|
|
|
// the value is clipped, or wraps around to the opposite max/min.
|
|
|
|
void (*add)(const m_option_t *opt, void *val, double add, bool wrap);
|
2012-09-18 15:05:11 +00:00
|
|
|
|
|
|
|
// Clamp the value in val to the option's valid value range.
|
|
|
|
// Return values:
|
|
|
|
// M_OPT_OUT_OF_RANGE: val was invalid, and modified (clamped) to be valid
|
|
|
|
// M_OPT_INVALID: val was invalid, and can't be made valid
|
|
|
|
// 0: val was already valid and is unchanged
|
|
|
|
int (*clamp)(const m_option_t *opt, void *val);
|
2002-11-12 01:56:42 +00:00
|
|
|
};
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Option description
|
2002-11-12 01:56:42 +00:00
|
|
|
struct m_option {
|
2011-07-03 12:42:04 +00:00
|
|
|
// Option name.
|
|
|
|
const char *name;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Reserved for higher level APIs, it shouldn't be used by parsers.
|
|
|
|
/** The suboption parser and func types do use it. They should instead
|
|
|
|
* use the priv field but this was inherited from older versions of the
|
|
|
|
* config code.
|
|
|
|
*/
|
|
|
|
void *p;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Option type.
|
|
|
|
const m_option_type_t *type;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// See \ref OptionFlags.
|
|
|
|
unsigned int flags;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// \brief Mostly useful for numeric types, the \ref M_OPT_MIN flags must
|
|
|
|
// also be set.
|
|
|
|
double min;
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// \brief Mostly useful for numeric types, the \ref M_OPT_MAX flags must
|
|
|
|
// also be set.
|
|
|
|
double max;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Type dependent data (for all kinds of extended settings).
|
|
|
|
/** This used to be a function pointer to hold a 'reverse to defaults' func.
|
|
|
|
* Now it can be used to pass any type of extra args needed by the parser.
|
|
|
|
*/
|
|
|
|
void *priv;
|
2008-03-31 03:19:29 +00:00
|
|
|
|
2013-08-19 10:55:34 +00:00
|
|
|
int is_new_option;
|
2008-03-31 03:19:29 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
int offset;
|
2012-05-17 00:31:11 +00:00
|
|
|
|
|
|
|
// Initialize variable to given default before parsing options
|
2013-08-17 17:50:45 +00:00
|
|
|
const void *defval;
|
2002-11-12 01:56:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// The option has a minimum set in \ref m_option::min.
|
|
|
|
#define M_OPT_MIN (1 << 0)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// The option has a maximum set in \ref m_option::max.
|
|
|
|
#define M_OPT_MAX (1 << 1)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// The option has a minimum and maximum in m_option::min and m_option::max.
|
|
|
|
#define M_OPT_RANGE (M_OPT_MIN | M_OPT_MAX)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// The option is forbidden in config files.
|
|
|
|
#define M_OPT_NOCFG (1 << 2)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2012-09-18 12:29:22 +00:00
|
|
|
// This option can't be set per-file when used with struct m_config.
|
2011-07-03 12:42:04 +00:00
|
|
|
#define M_OPT_GLOBAL (1 << 4)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// The option should be set during command line pre-parsing
|
|
|
|
#define M_OPT_PRE_PARSE (1 << 6)
|
|
|
|
|
2012-09-21 07:22:25 +00:00
|
|
|
// See M_OPT_TYPE_OPTIONAL_PARAM.
|
|
|
|
#define M_OPT_OPTIONAL_PARAM (1 << 10)
|
|
|
|
|
2013-02-16 22:24:10 +00:00
|
|
|
// Parse C-style escapes like "\n" (for CONF_TYPE_STRING only)
|
|
|
|
#define M_OPT_PARSE_ESCAPES (1 << 11)
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// These are kept for compatibility with older code.
|
|
|
|
#define CONF_MIN M_OPT_MIN
|
|
|
|
#define CONF_MAX M_OPT_MAX
|
|
|
|
#define CONF_RANGE M_OPT_RANGE
|
|
|
|
#define CONF_NOCFG M_OPT_NOCFG
|
|
|
|
#define CONF_GLOBAL M_OPT_GLOBAL
|
|
|
|
#define CONF_PRE_PARSE M_OPT_PRE_PARSE
|
|
|
|
|
|
|
|
// These flags are used to describe special parser capabilities or behavior.
|
|
|
|
|
|
|
|
// Suboption parser flag.
|
2006-04-24 19:20:04 +00:00
|
|
|
/** When this flag is set, m_option::p should point to another m_option
|
|
|
|
* array. Only the parse function will be called. If dst is set, it should
|
|
|
|
* create/update an array of char* containg opt/val pairs. The options in
|
|
|
|
* the child array will then be set automatically by the \ref Config.
|
2006-04-25 18:48:53 +00:00
|
|
|
* Also note that suboptions may be directly accessed by using
|
2006-04-24 19:20:04 +00:00
|
|
|
* -option:subopt blah.
|
|
|
|
*/
|
2011-07-03 12:42:04 +00:00
|
|
|
#define M_OPT_TYPE_HAS_CHILD (1 << 0)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Wildcard matching flag.
|
2006-04-27 13:22:23 +00:00
|
|
|
/** If set the option type has a use for option names ending with a *
|
2006-04-25 18:48:53 +00:00
|
|
|
* (used for -aa*), this only affects the option name matching.
|
2006-04-24 19:20:04 +00:00
|
|
|
*/
|
2011-07-03 12:42:04 +00:00
|
|
|
#define M_OPT_TYPE_ALLOW_WILDCARD (1 << 1)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Dynamic data type.
|
2006-04-27 13:22:23 +00:00
|
|
|
/** This flag indicates that the data is dynamically allocated (m_option::p
|
|
|
|
* points to a pointer). It enables a little hack in the \ref Config wich
|
|
|
|
* replaces the initial value of such variables with a dynamic copy in case
|
|
|
|
* the initial value is statically allocated (pretty common with strings).
|
2006-04-24 19:20:04 +00:00
|
|
|
*/
|
2011-07-03 12:42:04 +00:00
|
|
|
#define M_OPT_TYPE_DYNAMIC (1 << 2)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2012-09-21 07:22:25 +00:00
|
|
|
// The parameter is optional and by default no parameter is preferred. If
|
|
|
|
// ambiguous syntax is used ("--opt value"), the command line parser will
|
|
|
|
// assume that the argument takes no parameter. In config files, these
|
|
|
|
// options can be used without "=" and value.
|
|
|
|
#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 3)
|
2012-08-05 21:34:28 +00:00
|
|
|
|
2012-08-06 15:45:17 +00:00
|
|
|
// modify M_OPT_TYPE_HAS_CHILD so that m_option::p points to
|
|
|
|
// struct m_sub_options, instead of a direct m_option array.
|
|
|
|
#define M_OPT_TYPE_USE_SUBSTRUCT (1 << 4)
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
///////////////////////////// Parser flags /////////////////////////////////
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2012-09-21 07:22:25 +00:00
|
|
|
// OptionParserReturn
|
|
|
|
//
|
|
|
|
// On success parsers return a number >= 0.
|
2011-07-03 12:42:04 +00:00
|
|
|
//
|
|
|
|
// To indicate that MPlayer should exit without playing anything,
|
|
|
|
// parsers return M_OPT_EXIT minus the number of parameters they
|
|
|
|
// consumed: \ref M_OPT_EXIT or \ref M_OPT_EXIT-1.
|
|
|
|
//
|
|
|
|
// On error one of the following (negative) error codes is returned:
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// For use by higher level APIs when the option name is invalid.
|
|
|
|
#define M_OPT_UNKNOWN -1
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Returned when a parameter is needed but wasn't provided.
|
|
|
|
#define M_OPT_MISSING_PARAM -2
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Returned when the given parameter couldn't be parsed.
|
|
|
|
#define M_OPT_INVALID -3
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Returned if the value is "out of range". The exact meaning may
|
|
|
|
// vary from type to type.
|
|
|
|
#define M_OPT_OUT_OF_RANGE -4
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2012-09-21 07:22:25 +00:00
|
|
|
// The option doesn't take a parameter.
|
|
|
|
#define M_OPT_DISALLOW_PARAM -5
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Returned if the parser failed for any other reason than a bad parameter.
|
2012-09-21 07:22:25 +00:00
|
|
|
#define M_OPT_PARSER_ERR -6
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Returned when MPlayer should exit. Used by various help stuff.
|
2006-04-24 19:20:04 +00:00
|
|
|
/** M_OPT_EXIT must be the lowest number on this list.
|
|
|
|
*/
|
2012-09-21 07:22:25 +00:00
|
|
|
#define M_OPT_EXIT -7
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2011-07-29 04:52:29 +00:00
|
|
|
char *m_option_strerror(int code);
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Find the option matching the given name in the list.
|
2006-04-24 19:20:04 +00:00
|
|
|
/** \ingroup Options
|
2006-04-25 18:48:53 +00:00
|
|
|
* This function takes the possible wildcards into account (see
|
2006-04-24 19:20:04 +00:00
|
|
|
* \ref M_OPT_TYPE_ALLOW_WILDCARD).
|
2009-07-06 23:26:13 +00:00
|
|
|
*
|
2006-04-24 19:20:04 +00:00
|
|
|
* \param list Pointer to an array of \ref m_option.
|
|
|
|
* \param name Name of the option.
|
|
|
|
* \return The matching option or NULL.
|
|
|
|
*/
|
2011-07-03 12:42:04 +00:00
|
|
|
const m_option_t *m_option_list_find(const m_option_t *list, const char *name);
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Helper to parse options, see \ref m_option_type::parse.
|
2011-07-28 08:07:47 +00:00
|
|
|
static inline int m_option_parse(const m_option_t *opt, struct bstr name,
|
2012-08-05 21:34:28 +00:00
|
|
|
struct bstr param, void *dst)
|
2011-07-03 12:42:04 +00:00
|
|
|
{
|
2012-08-05 21:34:28 +00:00
|
|
|
return opt->type->parse(opt, name, param, dst);
|
2002-11-12 01:56:42 +00:00
|
|
|
}
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Helper to print options, see \ref m_option_type::print.
|
|
|
|
static inline char *m_option_print(const m_option_t *opt, const void *val_ptr)
|
|
|
|
{
|
|
|
|
if (opt->type->print)
|
|
|
|
return opt->type->print(opt, val_ptr);
|
|
|
|
else
|
2011-07-03 17:04:21 +00:00
|
|
|
return NULL;
|
2002-11-12 01:56:42 +00:00
|
|
|
}
|
|
|
|
|
2012-09-18 13:31:46 +00:00
|
|
|
static inline char *m_option_pretty_print(const m_option_t *opt,
|
|
|
|
const void *val_ptr)
|
|
|
|
{
|
|
|
|
if (opt->type->pretty_print)
|
|
|
|
return opt->type->pretty_print(opt, val_ptr);
|
|
|
|
else
|
|
|
|
return m_option_print(opt, val_ptr);
|
|
|
|
}
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Helper around \ref m_option_type::copy.
|
|
|
|
static inline void m_option_copy(const m_option_t *opt, void *dst,
|
|
|
|
const void *src)
|
|
|
|
{
|
|
|
|
if (opt->type->copy)
|
2012-08-04 09:14:38 +00:00
|
|
|
opt->type->copy(opt, dst, src);
|
2002-11-12 01:56:42 +00:00
|
|
|
}
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// Helper around \ref m_option_type::free.
|
|
|
|
static inline void m_option_free(const m_option_t *opt, void *dst)
|
|
|
|
{
|
|
|
|
if (opt->type->free)
|
|
|
|
opt->type->free(dst);
|
2002-11-12 01:56:42 +00:00
|
|
|
}
|
|
|
|
|
2013-04-21 01:18:32 +00:00
|
|
|
int m_option_required_params(const m_option_t *opt);
|
|
|
|
|
2013-03-01 10:21:13 +00:00
|
|
|
// Cause a compilation warning if typeof(expr) != type.
|
|
|
|
// Should be used with pointer types only.
|
|
|
|
#define MP_EXPECT_TYPE(type, expr) (0 ? (type)0 : (expr))
|
|
|
|
|
|
|
|
// This behaves like offsetof(type, member), but will cause a compilation
|
|
|
|
// warning if typeof(member) != expected_member_type.
|
|
|
|
// It uses some trickery to make it compile as expression.
|
|
|
|
#define MP_CHECKED_OFFSETOF(type, member, expected_member_type) \
|
|
|
|
(offsetof(type, member) + (0 && MP_EXPECT_TYPE(expected_member_type*, \
|
|
|
|
&((type*)0)->member)))
|
|
|
|
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-04-19 01:11:52 +00:00
|
|
|
#define OPTION_LIST_SEPARATOR ','
|
|
|
|
|
|
|
|
#if HAVE_DOS_PATHS
|
|
|
|
#define OPTION_PATH_SEPARATOR ';'
|
|
|
|
#else
|
|
|
|
#define OPTION_PATH_SEPARATOR ':'
|
|
|
|
#endif
|
|
|
|
|
2012-05-17 00:31:11 +00:00
|
|
|
#define OPTDEF_STR(s) .defval = (void *)&(char * const){s}
|
|
|
|
#define OPTDEF_INT(i) .defval = (void *)&(const int){i}
|
|
|
|
|
2013-03-01 10:27:49 +00:00
|
|
|
#define OPT_GENERAL(ctype, optname, varname, flagv, ...) \
|
2013-08-19 10:55:34 +00:00
|
|
|
{.name = optname, .flags = flagv, .is_new_option = 1, \
|
2013-03-01 10:27:49 +00:00
|
|
|
.offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, varname, ctype), \
|
|
|
|
__VA_ARGS__}
|
2013-03-01 10:21:13 +00:00
|
|
|
|
2013-03-01 10:27:49 +00:00
|
|
|
#define OPT_GENERAL_NOTYPE(optname, varname, flagv, ...) \
|
2013-08-19 10:55:34 +00:00
|
|
|
{.name = optname, .flags = flagv, .is_new_option = 1, \
|
2013-03-01 10:27:49 +00:00
|
|
|
.offset = offsetof(OPT_BASE_STRUCT, varname), \
|
|
|
|
__VA_ARGS__}
|
|
|
|
|
|
|
|
#define OPT_HELPER_REMOVEPAREN(...) __VA_ARGS__
|
2012-05-17 00:31:11 +00:00
|
|
|
|
|
|
|
/* The OPT_FLAG_CONSTANTS->OPT_FLAG_CONSTANTS_ kind of redirection exists to
|
|
|
|
* make the code fully standard-conforming: the C standard requires that
|
|
|
|
* __VA_ARGS__ has at least one argument (though GCC for example would accept
|
|
|
|
* 0). Thus the first OPT_FLAG_CONSTANTS is a wrapper which just adds one
|
|
|
|
* argument to ensure __VA_ARGS__ is not empty when calling the next macro.
|
|
|
|
*/
|
2013-03-01 10:27:49 +00:00
|
|
|
|
|
|
|
#define OPT_FLAG(...) \
|
|
|
|
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_flag, .max = 1)
|
|
|
|
|
|
|
|
#define OPT_FLAG_CONSTANTS_(optname, varname, flags, offvalue, value, ...) \
|
|
|
|
OPT_GENERAL(int, optname, varname, flags, \
|
|
|
|
.min = offvalue, .max = value, __VA_ARGS__)
|
|
|
|
#define OPT_FLAG_CONSTANTS(...) \
|
|
|
|
OPT_FLAG_CONSTANTS_(__VA_ARGS__, .type = &m_option_type_flag)
|
|
|
|
|
|
|
|
#define OPT_FLAG_STORE(optname, varname, flags, value) \
|
|
|
|
OPT_GENERAL(int, optname, varname, flags, .max = value, \
|
|
|
|
.type = &m_option_type_store)
|
|
|
|
|
|
|
|
#define OPT_FLOAT_STORE(optname, varname, flags, value) \
|
|
|
|
OPT_GENERAL(float, optname, varname, flags, .max = value, \
|
|
|
|
.type = &m_option_type_float_store)
|
|
|
|
|
|
|
|
#define OPT_STRINGLIST(...) \
|
|
|
|
OPT_GENERAL(char**, __VA_ARGS__, .type = &m_option_type_string_list)
|
|
|
|
|
|
|
|
#define OPT_PATHLIST(...) \
|
|
|
|
OPT_GENERAL(char**, __VA_ARGS__, .type = &m_option_type_string_list, \
|
|
|
|
.priv = (void *)&(const char){OPTION_PATH_SEPARATOR})
|
|
|
|
|
|
|
|
#define OPT_INT(...) \
|
|
|
|
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_int)
|
|
|
|
|
2013-03-04 16:40:21 +00:00
|
|
|
#define OPT_INT64(...) \
|
|
|
|
OPT_GENERAL(int64_t, __VA_ARGS__, .type = &m_option_type_int64)
|
|
|
|
|
2013-03-01 10:27:49 +00:00
|
|
|
#define OPT_RANGE_(ctype, optname, varname, flags, minval, maxval, ...) \
|
|
|
|
OPT_GENERAL(ctype, optname, varname, (flags) | CONF_RANGE, \
|
|
|
|
.min = minval, .max = maxval, __VA_ARGS__)
|
|
|
|
|
|
|
|
#define OPT_INTRANGE(...) \
|
|
|
|
OPT_RANGE_(int, __VA_ARGS__, .type = &m_option_type_int)
|
|
|
|
|
|
|
|
#define OPT_FLOATRANGE(...) \
|
|
|
|
OPT_RANGE_(float, __VA_ARGS__, .type = &m_option_type_float)
|
|
|
|
|
|
|
|
#define OPT_INTPAIR(...) \
|
|
|
|
OPT_GENERAL_NOTYPE(__VA_ARGS__, .type = &m_option_type_intpair)
|
|
|
|
|
|
|
|
#define OPT_FLOAT(...) \
|
|
|
|
OPT_GENERAL(float, __VA_ARGS__, .type = &m_option_type_float)
|
|
|
|
|
2013-03-08 01:08:02 +00:00
|
|
|
#define OPT_DOUBLE(...) \
|
|
|
|
OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_double)
|
|
|
|
|
2013-03-01 10:27:49 +00:00
|
|
|
#define OPT_STRING(...) \
|
|
|
|
OPT_GENERAL(char*, __VA_ARGS__, .type = &m_option_type_string)
|
|
|
|
|
|
|
|
#define OPT_SETTINGSLIST(optname, varname, flags, objlist) \
|
|
|
|
OPT_GENERAL(m_obj_settings_t*, optname, varname, flags, \
|
|
|
|
.type = &m_option_type_obj_settings_list, \
|
options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except
that m_config is much more powerful. m_config is used for VOs and some
other things, so to unify them. We plan to kick out m_struct and use
m_config for everything. (Unfortunately, m_config is also a bit more
bloated, so this commit isn't all that great, but it will allow to
reduce the option parser mess somewhat.)
This commit also switches all video filters to use the option macros.
One reason is that m_struct and m_config, even though they both use
m_option, store the offsets of the option fields differently (sigh...),
meaning the options defined for either are incompatible. It's easier to
switch everything in one go.
This commit will allow using the -vf option parser for other things,
like VOs and AOs.
2013-07-21 17:33:08 +00:00
|
|
|
.priv = (void*)MP_EXPECT_TYPE(const struct m_obj_list*, objlist))
|
|
|
|
|
|
|
|
#define OPT_IMAGEFORMAT(...) \
|
|
|
|
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_imgfmt)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
|
|
|
#define OPT_AUDIOFORMAT(...) \
|
|
|
|
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_afmt)
|
|
|
|
|
2013-04-05 13:25:09 +00:00
|
|
|
#define OPT_CHMAP(...) \
|
|
|
|
OPT_GENERAL(struct mp_chmap, __VA_ARGS__, .type = &m_option_type_chmap)
|
|
|
|
|
2013-03-01 10:27:49 +00:00
|
|
|
|
|
|
|
#define M_CHOICES(choices) \
|
|
|
|
.priv = (void *)&(const struct m_opt_choice_alternatives[]){ \
|
|
|
|
OPT_HELPER_REMOVEPAREN choices, {NULL}}
|
|
|
|
|
|
|
|
#define OPT_CHOICE(...) \
|
|
|
|
OPT_CHOICE_(__VA_ARGS__, .type = &m_option_type_choice)
|
|
|
|
#define OPT_CHOICE_(optname, varname, flags, choices, ...) \
|
|
|
|
OPT_GENERAL(int, optname, varname, flags, M_CHOICES(choices), __VA_ARGS__)
|
|
|
|
|
2012-09-05 00:17:13 +00:00
|
|
|
// Union of choices and an int range. The choice values can be included in the
|
|
|
|
// int range, or be completely separate - both works.
|
2013-03-01 10:27:49 +00:00
|
|
|
#define OPT_CHOICE_OR_INT_(optname, varname, flags, minval, maxval, choices, ...) \
|
|
|
|
OPT_GENERAL(int, optname, varname, (flags) | CONF_RANGE, \
|
|
|
|
.min = minval, .max = maxval, \
|
|
|
|
M_CHOICES(choices), __VA_ARGS__)
|
|
|
|
#define OPT_CHOICE_OR_INT(...) \
|
|
|
|
OPT_CHOICE_OR_INT_(__VA_ARGS__, .type = &m_option_type_choice)
|
|
|
|
|
|
|
|
#define OPT_TIME(...) \
|
|
|
|
OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_time)
|
|
|
|
|
|
|
|
#define OPT_REL_TIME(...) \
|
|
|
|
OPT_GENERAL(struct m_rel_time, __VA_ARGS__, .type = &m_option_type_rel_time)
|
|
|
|
|
|
|
|
#define OPT_COLOR(...) \
|
|
|
|
OPT_GENERAL(struct m_color, __VA_ARGS__, .type = &m_option_type_color)
|
|
|
|
|
|
|
|
#define OPT_GEOMETRY(...) \
|
|
|
|
OPT_GENERAL(struct m_geometry, __VA_ARGS__, .type = &m_option_type_geometry)
|
|
|
|
|
|
|
|
#define OPT_SIZE_BOX(...) \
|
|
|
|
OPT_GENERAL(struct m_geometry, __VA_ARGS__, .type = &m_option_type_size_box)
|
2012-05-17 00:31:11 +00:00
|
|
|
|
2013-03-01 10:27:49 +00:00
|
|
|
#define OPT_TRACKCHOICE(name, var) \
|
2013-08-21 16:24:56 +00:00
|
|
|
OPT_CHOICE_OR_INT(name, var, 0, 1, 8190, ({"no", -2}, {"auto", -1}))
|
2012-09-05 00:39:12 +00:00
|
|
|
|
2013-03-01 20:19:20 +00:00
|
|
|
#define OPT_STRING_VALIDATE_(optname, varname, flags, validate_fn, ...) \
|
|
|
|
OPT_GENERAL(char*, optname, varname, flags, __VA_ARGS__, \
|
|
|
|
.priv = MP_EXPECT_TYPE(m_opt_string_validate_fn, validate_fn))
|
|
|
|
#define OPT_STRING_VALIDATE(...) \
|
|
|
|
OPT_STRING_VALIDATE_(__VA_ARGS__, .type = &m_option_type_string)
|
|
|
|
|
2012-08-06 15:45:17 +00:00
|
|
|
// subconf must have the type struct m_sub_options.
|
options: drop --opt:subopt option names
For all suboptions, "flat" options were available by separating the
parent option and the sub option with ":", e.g. "--rawvideo:w=123". Drop
this syntax and use "-" as separator. This means even suboptions are
available as normal options now, e.g. "--rawvideo-w=123". The old syntax
doesn't work anymore.
Note that this is completely separate from actual suboptions. For
example, "-rawvideo w=123:h=123" still works. (Not that this syntax is
worth supporting, but it's needed anyway, for for other things like vf
and vo suboptions.)
As a consequence of this change, we also have to add new "no-" prefixed
options for flag suboptions, so that "--no-input-default-bindings"
works. ("--input-no-default-bindings" also works as a consequence of
allowing "-input no-default-bindings" - they are handled by the same
underlying option.)
For --input, always use the full syntax in the manpage. There exist
suboptions other than --input (like --tv, --rawvideo, etc.), but since
they might be handled differently in the future, don't touch these yet.
M_OPT_PREFIXED becomes the default, so remove it. As a minor unrelated
cleanup, get rid of M_OPT_MERGE too and use the OPT_SUBSTRUCT() macro in
some places.
Unrelated: remove the duplicated --tv:buffersize option, fix a typo in
changes.rst.
2013-02-21 21:10:21 +00:00
|
|
|
// All sub-options are prefixed with "name-" and are added to the current
|
|
|
|
// (containing) option list.
|
|
|
|
// If name is "", add the sub-options directly instead.
|
2012-08-06 15:45:17 +00:00
|
|
|
// varname refers to the field, that must be a pointer to a field described by
|
|
|
|
// the subconf struct.
|
2013-03-01 10:27:49 +00:00
|
|
|
#define OPT_SUBSTRUCT(name, varname, subconf, flagv) \
|
|
|
|
OPT_GENERAL_NOTYPE(name, varname, flagv, \
|
|
|
|
.type = &m_option_type_subconfig_struct, \
|
|
|
|
.priv = (void*)&subconf)
|
2012-08-06 15:45:17 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_M_OPTION_H */
|