2010-01-30 23:24:23 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
options: change license of most files to LGPL (except options.c/.h)
All authors of the current code have agreed (as far as this commit
requires).
options.c/options.h will take more effort, because it contains all the
option declarations, and thus is touched extremely often.
m_option.c is technically still GPL, because of commit 2c82d5a1d85378dd0
(michael has agreed to LGPL, but only once the core of mpv is LGPL).
The geometry parsing code in m_option.c was originally by someone who
could not be reached. However, it was heavily rewritten anyway, and only
the syntax remains (i.e. not copyright-relevant).
parse_commandline.c contains a change by "adland" (commit 1d0ac71ae8ba),
who could not be reached - this this specific part is GPL only.
Fortunately, it matters only for DVD (and even then is more like a hack,
but whatever).
There are some other relevant changes, but they have all been reverted,
moved somewhere else, deleted, or replaced.
2017-06-12 18:55:17 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 23:24:23 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
options: change license of most files to LGPL (except options.c/.h)
All authors of the current code have agreed (as far as this commit
requires).
options.c/options.h will take more effort, because it contains all the
option declarations, and thus is touched extremely often.
m_option.c is technically still GPL, because of commit 2c82d5a1d85378dd0
(michael has agreed to LGPL, but only once the core of mpv is LGPL).
The geometry parsing code in m_option.c was originally by someone who
could not be reached. However, it was heavily rewritten anyway, and only
the syntax remains (i.e. not copyright-relevant).
parse_commandline.c contains a change by "adland" (commit 1d0ac71ae8ba),
who could not be reached - this this specific part is GPL only.
Fortunately, it matters only for DVD (and even then is more like a hack,
but whatever).
There are some other relevant changes, but they have all been reverted,
moved somewhere else, deleted, or replaced.
2017-06-12 18:55:17 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
options: change license of most files to LGPL (except options.c/.h)
All authors of the current code have agreed (as far as this commit
requires).
options.c/options.h will take more effort, because it contains all the
option declarations, and thus is touched extremely often.
m_option.c is technically still GPL, because of commit 2c82d5a1d85378dd0
(michael has agreed to LGPL, but only once the core of mpv is LGPL).
The geometry parsing code in m_option.c was originally by someone who
could not be reached. However, it was heavily rewritten anyway, and only
the syntax remains (i.e. not copyright-relevant).
parse_commandline.c contains a change by "adland" (commit 1d0ac71ae8ba),
who could not be reached - this this specific part is GPL only.
Fortunately, it matters only for DVD (and even then is more like a hack,
but whatever).
There are some other relevant changes, but they have all been reverted,
moved somewhere else, deleted, or replaced.
2017-06-12 18:55:17 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 23:24:23 +00:00
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2020-03-13 15:49:39 +00:00
|
|
|
#include <float.h>
|
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
|
|
|
|
2014-08-29 10:09:04 +00:00
|
|
|
#include "misc/bstr.h"
|
2013-04-06 20:43:12 +00:00
|
|
|
#include "audio/chmap.h"
|
2023-08-25 17:00:31 +00:00
|
|
|
#include "common/common.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;
|
2013-12-21 18:45:42 +00:00
|
|
|
struct mp_log;
|
2014-02-24 19:07:41 +00:00
|
|
|
struct mpv_node;
|
2018-01-12 03:02:55 +00:00
|
|
|
struct mpv_global;
|
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
|
options: introduce bool option type, use it for --fullscreen
The option code is very old and was added to MPlayer in the early 2000s,
when C99 was still new. MPlayer did not use the "bool" type anywhere,l
and the logical option equivalent to bool, the "flag" option type, used
int, with the convention that only the values 0 and 1 are allowed.
mpv may have hammered many, many additional tentacles to the option
code, but some of the basics never changed, and m_option_type_flag still
uses int. This seems a bit weird, since mpv uses bool for booleans. So
finally introduce an m_option_type_bool. To avoid duplicating too much
code, change the flag code to bool, and "reimplement" m_option_type_flag
on top of m_option_type_bool.
As a "demonstration", change the --fullscreen option to this new type.
Ideally, all options would be changed too bool, and m_option_type_flag
would be removed. But that is a lot of monotonous thankless work, so I'm
not doing it, and making it a painful years long transition.
At the same time, I'm introducing a new concept for option declarations.
Instead of OPT_BOOL(), which define the full m_option struct contents,
there's OPTF_BOOL(), which only takes the option field name itself. The
name is provided via a normal struct field initializer. Other fields
(such as flags) can be provided via designated initializers.
The advantage of this is that we don't need tons of nested vararg
macros. We also don't need to deal with 0-sized varargs being a pain
(and in fact they are not a thing in standard C99 and probably C11).
There is no need to provide a mandatory flags argument either, which is
the reason why so many OPT_ macros are used with a "0" argument. (The
flag argument seems to confuse other developers; they either don't
immediately recognize what it is, and sometimes it's supposed to be the
option's default value.)
Not having to mess with the flag argument in such option macros is also
a reason for the removal of M_OPT_RANGE etc., for the better or worse.
The only place that special-cased the _flag option type was in
command.c; change it to use something effectively very similar that
automatically includes the new _bool option type. Everything else should
be transparent to the change. The fullscreen option change should be
transparent too, as C99 bool is basically an integer type that is
clamped to 0/1 (except in Swift, Swift sucks).
2020-03-14 01:07:35 +00:00
|
|
|
extern const m_option_type_t m_option_type_bool;
|
2007-11-09 06:50:53 +00:00
|
|
|
extern const m_option_type_t m_option_type_flag;
|
2017-06-23 18:51:12 +00:00
|
|
|
extern const m_option_type_t m_option_type_dummy_flag;
|
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;
|
2018-01-24 00:32:56 +00:00
|
|
|
extern const m_option_type_t m_option_type_byte_size;
|
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;
|
2014-06-07 21:41:47 +00:00
|
|
|
extern const m_option_type_t m_option_type_string_append_list;
|
2014-01-16 22:03:40 +00:00
|
|
|
extern const m_option_type_t m_option_type_keyvalue_list;
|
2007-11-09 06:50:53 +00:00
|
|
|
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;
|
2015-03-04 16:20:47 +00:00
|
|
|
extern const m_option_type_t m_option_type_flags;
|
2013-12-18 18:04:30 +00:00
|
|
|
extern const m_option_type_t m_option_type_msglevels;
|
2013-12-26 18:22:40 +00:00
|
|
|
extern const m_option_type_t m_option_type_print_fn;
|
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;
|
2016-08-04 18:49:20 +00:00
|
|
|
extern const m_option_type_t m_option_type_channels;
|
2016-08-31 16:10:11 +00:00
|
|
|
extern const m_option_type_t m_option_type_aspect;
|
2019-11-28 17:08:25 +00:00
|
|
|
extern const m_option_type_t m_option_type_obj_settings_list;
|
2014-02-24 19:07:41 +00:00
|
|
|
extern const m_option_type_t m_option_type_node;
|
2023-08-25 17:00:31 +00:00
|
|
|
extern const m_option_type_t m_option_type_rect;
|
2024-07-01 05:01:57 +00:00
|
|
|
extern const m_option_type_t m_option_type_cycle_dir;
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2014-12-11 00:04:15 +00:00
|
|
|
// Used internally by m_config.c
|
|
|
|
extern const m_option_type_t m_option_type_alias;
|
2017-07-02 14:26:41 +00:00
|
|
|
extern const m_option_type_t m_option_type_cli_alias;
|
2014-12-11 00:04:15 +00:00
|
|
|
extern const m_option_type_t m_option_type_removed;
|
2016-11-29 14:18:40 +00:00
|
|
|
extern const m_option_type_t m_option_type_subconfig;
|
2014-12-11 00:04:15 +00:00
|
|
|
|
2013-12-26 18:22:40 +00:00
|
|
|
// Callback used by m_option_type_print_fn options.
|
|
|
|
typedef void (*m_opt_print_fn)(struct mp_log *log);
|
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,
|
2014-06-29 17:44:32 +00:00
|
|
|
REL_TIME_RELATIVE,
|
2012-11-15 17:49:17 +00:00
|
|
|
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;
|
2020-07-11 22:12:55 +00:00
|
|
|
int ws; // workspace; valid if !=0
|
2013-01-23 09:56:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,
|
|
|
|
int scrw, int scrh, struct m_geometry *gm);
|
2023-08-31 20:39:04 +00:00
|
|
|
void m_rect_apply(struct mp_rect *rc, int w, int h, struct m_geometry *gm);
|
2013-01-23 09:56:11 +00:00
|
|
|
|
2016-08-04 18:49:20 +00:00
|
|
|
struct m_channels {
|
|
|
|
bool set : 1;
|
|
|
|
bool auto_safe : 1;
|
|
|
|
struct mp_chmap *chmaps;
|
|
|
|
int num_chmaps;
|
|
|
|
};
|
|
|
|
|
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;
|
2016-11-25 20:00:39 +00:00
|
|
|
// Prefix for each of the above options (none if NULL).
|
|
|
|
const char *options_prefix;
|
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
|
|
|
// For free use by the implementer of m_obj_list.get_desc
|
|
|
|
const void *p;
|
2013-11-23 20:29:05 +00:00
|
|
|
// Don't list entry with "help"
|
2013-07-21 20:03:53 +00:00
|
|
|
bool hidden;
|
2018-01-31 05:50:21 +00:00
|
|
|
// Callback to print custom help if "vf=entry=help" is passed
|
2013-12-21 19:04:49 +00:00
|
|
|
void (*print_help)(struct mp_log *log);
|
2013-12-21 18:45:42 +00:00
|
|
|
// Set by m_obj_list_find(). If the requested name is an old alias, this
|
|
|
|
// is set to the old name (while the name field uses the new name).
|
|
|
|
const char *replaced_name;
|
2016-09-05 19:04:17 +00:00
|
|
|
// For convenience: these are added as global command-line options.
|
|
|
|
const struct m_sub_options *global_opts;
|
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
|
2018-02-21 11:43:15 +00:00
|
|
|
const char *aliases[5][2];
|
2013-07-21 19:17:25 +00:00
|
|
|
// Allow a trailing ",", which adds an entry with name=""
|
|
|
|
bool allow_trailer;
|
2019-11-25 18:07:55 +00:00
|
|
|
// Callback to test whether an unknown entry should be allowed. (This can
|
|
|
|
// be useful if adding them as explicit entries is too much work.)
|
|
|
|
bool (*check_unknown_entry)(const char *name);
|
2017-03-25 16:07:40 +00:00
|
|
|
// Allow syntax for disabling entries.
|
|
|
|
bool allow_disable_entries;
|
2016-09-01 12:21:32 +00:00
|
|
|
// This helps with confusing error messages if unknown flag options are used.
|
|
|
|
bool disallow_positional_parameters;
|
2016-11-25 20:00:39 +00:00
|
|
|
// Each sub-item is backed by global options (for AOs and VOs).
|
|
|
|
bool use_global_options;
|
2018-01-31 05:50:21 +00:00
|
|
|
// Callback to print additional custom help if "vf=help" is passed
|
|
|
|
void (*print_help_list)(struct mp_log *log);
|
|
|
|
// Callback to print help for _unknown_ entries with "vf=entry=help"
|
|
|
|
void (*print_unknown_entry_help)(struct mp_log *log, const char *name);
|
2024-05-04 07:01:18 +00:00
|
|
|
// Get lavfi filters for option-info/[av]f/choices.
|
|
|
|
const char **(*get_lavfi_filters)(void *talloc_ctx);
|
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;
|
2017-03-25 16:07:40 +00:00
|
|
|
// User enable flag.
|
|
|
|
bool enabled;
|
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;
|
|
|
|
|
2019-12-18 05:49:48 +00:00
|
|
|
bool m_obj_settings_equal(struct m_obj_settings *a, struct m_obj_settings *b);
|
|
|
|
|
2010-12-17 23:00:28 +00:00
|
|
|
struct m_opt_choice_alternatives {
|
|
|
|
char *name;
|
|
|
|
int value;
|
|
|
|
};
|
|
|
|
|
2015-03-30 21:52:28 +00:00
|
|
|
const char *m_opt_choice_str(const struct m_opt_choice_alternatives *choices,
|
|
|
|
int value);
|
|
|
|
|
options: Make validation and help possible for all option types
Today, validation is only possible for string type options. But there's
no particular reason why it needs to be restricted in this way, and
there are potential uses, to allow other options to be validated
without forcing the option to have to reimplement parsing from
scratch.
The first part, simply making the validation function an explicit
field instead of overloading priv is simple enough. But if we only do
that, then the validation function still needs to deal with the raw
pre-parsed string. Instead, we want to allow the value to be parsed
before it is validated. That in turn leads to us having validator
functions that should be type aware. Unfortunately, that means we need
to keep the explicit macro like OPT_STRING_VALIDATE() as a way to
enforce the correct typing of the function. Otherwise, we'd have to
have the validator take a void * and hope the implementation can cast
it correctly.
For help, we don't have this problem, as help doesn't look at the
value.
Then, we turn validators that are really help generators into explicit
help functions and where a validator is help + validation, we split
them into two parts.
I have, however, left functions that need to query information for both
help and validation as single functions to avoid code duplication.
In this change, I have not added an other OPT_FOO_VALIDATE() macros as
they are not needed, but I will add some in a separate change to
illustrate the pattern.
2021-02-21 00:41:44 +00:00
|
|
|
typedef int (*m_opt_generic_validate_fn)(struct mp_log *log, const m_option_t *opt,
|
|
|
|
struct bstr name, void *value);
|
|
|
|
|
2024-02-26 03:55:00 +00:00
|
|
|
#define OPT_FUNC(name) name
|
|
|
|
#define OPT_FUNC_IN(name, suffix) name ## _ ## suffix
|
|
|
|
#define OPT_VALIDATE_FUNC(func, value_type, suffix) \
|
|
|
|
int OPT_FUNC(func)(struct mp_log *log, const m_option_t *opt, \
|
|
|
|
struct bstr name, value_type value); \
|
|
|
|
static inline int OPT_FUNC_IN(func, suffix)(struct mp_log *log, const m_option_t *opt, \
|
|
|
|
struct bstr name, void *value) { \
|
|
|
|
return OPT_FUNC(func)(log, opt, name, value); \
|
|
|
|
} \
|
|
|
|
int OPT_FUNC(func)(struct mp_log *log, const m_option_t *opt, \
|
|
|
|
struct bstr name, value_type value)
|
2013-03-01 20:19:20 +00:00
|
|
|
|
2014-06-13 00:17:31 +00:00
|
|
|
// m_option.priv points to this if OPT_SUBSTRUCT is used
|
2012-08-06 15:45:17 +00:00
|
|
|
struct m_sub_options {
|
2016-11-25 20:00:39 +00:00
|
|
|
const char *prefix;
|
2012-08-06 15:45:17 +00:00
|
|
|
const struct m_option *opts;
|
|
|
|
size_t size;
|
|
|
|
const void *defaults;
|
2016-09-19 17:51:26 +00:00
|
|
|
// Change flags passed to mp_option_change_callback() if any option that is
|
|
|
|
// directly or indirectly part of this group is changed.
|
|
|
|
int change_flags;
|
2020-01-04 18:45:50 +00:00
|
|
|
// Return further sub-options, for example for optional components. If set,
|
|
|
|
// this is called with increasing index (starting from 0), as long as true
|
|
|
|
// is returned. If true is returned and *sub is set in any of these calls,
|
|
|
|
// they are added as options.
|
|
|
|
bool (*get_sub_options)(int index, const struct m_sub_options **sub);
|
2012-08-06 15:45:17 +00:00
|
|
|
};
|
2003-04-02 16:11:15 +00:00
|
|
|
|
2023-02-20 05:53:09 +00:00
|
|
|
#define CONF_TYPE_BOOL (&m_option_type_bool)
|
2023-02-26 16:28:50 +00:00
|
|
|
#define CONF_TYPE_FLAG (&m_option_type_flag)
|
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_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)
|
2014-02-24 19:07:41 +00:00
|
|
|
#define CONF_TYPE_NODE (&m_option_type_node)
|
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 {
|
options: introduce bool option type, use it for --fullscreen
The option code is very old and was added to MPlayer in the early 2000s,
when C99 was still new. MPlayer did not use the "bool" type anywhere,l
and the logical option equivalent to bool, the "flag" option type, used
int, with the convention that only the values 0 and 1 are allowed.
mpv may have hammered many, many additional tentacles to the option
code, but some of the basics never changed, and m_option_type_flag still
uses int. This seems a bit weird, since mpv uses bool for booleans. So
finally introduce an m_option_type_bool. To avoid duplicating too much
code, change the flag code to bool, and "reimplement" m_option_type_flag
on top of m_option_type_bool.
As a "demonstration", change the --fullscreen option to this new type.
Ideally, all options would be changed too bool, and m_option_type_flag
would be removed. But that is a lot of monotonous thankless work, so I'm
not doing it, and making it a painful years long transition.
At the same time, I'm introducing a new concept for option declarations.
Instead of OPT_BOOL(), which define the full m_option struct contents,
there's OPTF_BOOL(), which only takes the option field name itself. The
name is provided via a normal struct field initializer. Other fields
(such as flags) can be provided via designated initializers.
The advantage of this is that we don't need tons of nested vararg
macros. We also don't need to deal with 0-sized varargs being a pain
(and in fact they are not a thing in standard C99 and probably C11).
There is no need to provide a mandatory flags argument either, which is
the reason why so many OPT_ macros are used with a "0" argument. (The
flag argument seems to confuse other developers; they either don't
immediately recognize what it is, and sometimes it's supposed to be the
option's default value.)
Not having to mess with the flag argument in such option macros is also
a reason for the removal of M_OPT_RANGE etc., for the better or worse.
The only place that special-cased the _flag option type was in
command.c; change it to use something effectively very similar that
automatically includes the new _bool option type. Everything else should
be transparent to the change. The fullscreen option change should be
transparent too, as C99 bool is basically an integer type that is
clamped to 0/1 (except in Swift, Swift sucks).
2020-03-14 01:07:35 +00:00
|
|
|
bool bool_;
|
2023-02-26 16:28:50 +00:00
|
|
|
int flag; // not the C type "bool"!
|
2012-09-18 14:08:17 +00:00
|
|
|
int int_;
|
|
|
|
int64_t int64;
|
|
|
|
float float_;
|
|
|
|
double double_;
|
|
|
|
char *string;
|
|
|
|
char **string_list;
|
2014-01-16 22:03:40 +00:00
|
|
|
char **keyvalue_list;
|
2012-09-18 14:08:17 +00:00
|
|
|
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;
|
2016-08-04 18:49:20 +00:00
|
|
|
struct m_channels channels;
|
2012-09-18 14:08:17 +00:00
|
|
|
};
|
|
|
|
|
2023-10-22 17:38:58 +00:00
|
|
|
// Keep fully zeroed instance of m_option_value to use as a default value, before
|
|
|
|
// any specific union member is used. C standard says that `= {0}` activates and
|
|
|
|
// initializes only the first member of the union, leaving padding bits undefined.
|
|
|
|
static const union m_option_value m_option_value_default;
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2017-06-26 19:07:00 +00:00
|
|
|
struct m_option_action {
|
|
|
|
// The name of the suffix, e.g. "add" for a list. If the option is named
|
|
|
|
// "foo", this will be available as "--foo-add". Note that no suffix (i.e.
|
|
|
|
// "--foo" is implicitly always available.
|
|
|
|
const char *name;
|
|
|
|
// One of M_OPT_TYPE*.
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
|
|
|
|
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.
|
options: Make validation and help possible for all option types
Today, validation is only possible for string type options. But there's
no particular reason why it needs to be restricted in this way, and
there are potential uses, to allow other options to be validated
without forcing the option to have to reimplement parsing from
scratch.
The first part, simply making the validation function an explicit
field instead of overloading priv is simple enough. But if we only do
that, then the validation function still needs to deal with the raw
pre-parsed string. Instead, we want to allow the value to be parsed
before it is validated. That in turn leads to us having validator
functions that should be type aware. Unfortunately, that means we need
to keep the explicit macro like OPT_STRING_VALIDATE() as a way to
enforce the correct typing of the function. Otherwise, we'd have to
have the validator take a void * and hope the implementation can cast
it correctly.
For help, we don't have this problem, as help doesn't look at the
value.
Then, we turn validators that are really help generators into explicit
help functions and where a validator is help + validation, we split
them into two parts.
I have, however, left functions that need to query information for both
help and validation as single functions to avoid code duplication.
In this change, I have not added an other OPT_FOO_VALIDATE() macros as
they are not needed, but I will add some in a separate change to
illustrate the pattern.
2021-02-21 00:41:44 +00:00
|
|
|
* Generally should not be called directly outside of the options module,
|
|
|
|
* but instead through \ref m_option_parse which calls additional option
|
|
|
|
* specific callbacks during the process.
|
2011-07-03 12:42:04 +00:00
|
|
|
*
|
2013-12-21 18:45:42 +00:00
|
|
|
* \param log for outputting parser error or help messages
|
2011-07-03 12:42:04 +00:00
|
|
|
* \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
|
|
|
*/
|
2013-12-21 18:45:42 +00:00
|
|
|
int (*parse)(struct mp_log *log, const m_option_t *opt,
|
|
|
|
struct bstr name, struct bstr param, 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.
|
2014-02-24 19:07:41 +00:00
|
|
|
// The implementation must free *dst if memory allocation is involved.
|
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
|
|
|
|
2013-10-31 22:23:38 +00:00
|
|
|
// Multiply the value with the factor f. The callback must clip the result
|
|
|
|
// to the valid value range of the option.
|
|
|
|
void (*multiply)(const m_option_t *opt, void *val, double f);
|
|
|
|
|
2014-02-24 19:07:41 +00:00
|
|
|
// Set the option value in dst to the contents of src.
|
|
|
|
// (If the option is dynamic, the old value in *dst has to be freed.)
|
|
|
|
// Return values:
|
|
|
|
// M_OPT_UNKNOWN: src is in an unknown format
|
|
|
|
// M_OPT_INVALID: src is incorrectly formatted
|
|
|
|
// >= 0: success
|
|
|
|
// other error code: some other error, essentially M_OPT_INVALID refined
|
|
|
|
int (*set)(const m_option_t *opt, void *dst, struct mpv_node *src);
|
|
|
|
|
|
|
|
// Copy the option value in src to dst. Use ta_parent for any dynamic
|
|
|
|
// memory allocations. It's explicitly allowed to have mpv_node reference
|
|
|
|
// static strings (and even mpv_node_list.keys), though.
|
|
|
|
int (*get)(const m_option_t *opt, void *ta_parent, struct mpv_node *dst,
|
|
|
|
void *src);
|
2017-06-26 19:07:00 +00:00
|
|
|
|
2019-11-28 15:52:46 +00:00
|
|
|
// Return whether the values are the same. (There are no "unordered"
|
|
|
|
// results; for example, two floats with the value NaN compare equal. Other
|
|
|
|
// ambiguous floats, such as +0 and -0 compare equal. Some option types may
|
|
|
|
// incorrectly report unequal for values that are equal, such as sets (if
|
|
|
|
// the element order is different, which incorrectly matters), but values
|
|
|
|
// duplicated with m_option_copy() always return as equal. Empty strings
|
|
|
|
// and NULL strings are equal. Ambiguous unicode representations compare
|
|
|
|
// unequal.)
|
|
|
|
// If not set, values are always considered equal (=> not really optional).
|
|
|
|
bool (*equal)(const m_option_t *opt, void *a, void *b);
|
|
|
|
|
2017-06-26 19:07:00 +00:00
|
|
|
// Optional: list of suffixes, terminated with a {0} entry. An empty list
|
|
|
|
// behaves like the list being NULL.
|
|
|
|
const struct m_option_action *actions;
|
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.
|
options: introduce bool option type, use it for --fullscreen
The option code is very old and was added to MPlayer in the early 2000s,
when C99 was still new. MPlayer did not use the "bool" type anywhere,l
and the logical option equivalent to bool, the "flag" option type, used
int, with the convention that only the values 0 and 1 are allowed.
mpv may have hammered many, many additional tentacles to the option
code, but some of the basics never changed, and m_option_type_flag still
uses int. This seems a bit weird, since mpv uses bool for booleans. So
finally introduce an m_option_type_bool. To avoid duplicating too much
code, change the flag code to bool, and "reimplement" m_option_type_flag
on top of m_option_type_bool.
As a "demonstration", change the --fullscreen option to this new type.
Ideally, all options would be changed too bool, and m_option_type_flag
would be removed. But that is a lot of monotonous thankless work, so I'm
not doing it, and making it a painful years long transition.
At the same time, I'm introducing a new concept for option declarations.
Instead of OPT_BOOL(), which define the full m_option struct contents,
there's OPTF_BOOL(), which only takes the option field name itself. The
name is provided via a normal struct field initializer. Other fields
(such as flags) can be provided via designated initializers.
The advantage of this is that we don't need tons of nested vararg
macros. We also don't need to deal with 0-sized varargs being a pain
(and in fact they are not a thing in standard C99 and probably C11).
There is no need to provide a mandatory flags argument either, which is
the reason why so many OPT_ macros are used with a "0" argument. (The
flag argument seems to confuse other developers; they either don't
immediately recognize what it is, and sometimes it's supposed to be the
option's default value.)
Not having to mess with the flag argument in such option macros is also
a reason for the removal of M_OPT_RANGE etc., for the better or worse.
The only place that special-cased the _flag option type was in
command.c; change it to use something effectively very similar that
automatically includes the new _bool option type. Everything else should
be transparent to the change. The fullscreen option change should be
transparent too, as C99 bool is basically an integer type that is
clamped to 0/1 (except in Swift, Swift sucks).
2020-03-14 01:07:35 +00:00
|
|
|
// Option declarations can use this as positional field.
|
2011-07-03 12:42:04 +00:00
|
|
|
const char *name;
|
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
|
|
|
|
2024-02-25 19:10:52 +00:00
|
|
|
// Always force an option update even if the written value does not change.
|
|
|
|
bool force_update;
|
|
|
|
|
2024-06-23 05:58:16 +00:00
|
|
|
// If the option is an alias, use the prefix of sub option.
|
|
|
|
bool alias_use_prefix;
|
|
|
|
|
2014-06-13 00:16:47 +00:00
|
|
|
int offset;
|
|
|
|
|
2020-03-13 15:49:39 +00:00
|
|
|
// Most numeric types restrict the range to [min, max] if min<max (this
|
|
|
|
// implies that if min/max are not set, the full range is used). In all
|
|
|
|
// cases, the actual range is clamped to the type's native range.
|
|
|
|
// Float types use [DBL_MIN, DBL_MAX], though by setting min or max to
|
|
|
|
// -/+INFINITY, the range can be extended to INFINITY. (This part is buggy
|
|
|
|
// for "float".)
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
// Preferably use M_RANGE() to set these fields.
|
2020-03-13 15:49:39 +00:00
|
|
|
double min, 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).
|
|
|
|
void *priv;
|
2008-03-31 03:19:29 +00:00
|
|
|
|
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;
|
2016-06-29 16:09:30 +00:00
|
|
|
|
|
|
|
// Print a warning when this option is used (for options with no direct
|
|
|
|
// replacement.)
|
|
|
|
const char *deprecation_message;
|
options: Make validation and help possible for all option types
Today, validation is only possible for string type options. But there's
no particular reason why it needs to be restricted in this way, and
there are potential uses, to allow other options to be validated
without forcing the option to have to reimplement parsing from
scratch.
The first part, simply making the validation function an explicit
field instead of overloading priv is simple enough. But if we only do
that, then the validation function still needs to deal with the raw
pre-parsed string. Instead, we want to allow the value to be parsed
before it is validated. That in turn leads to us having validator
functions that should be type aware. Unfortunately, that means we need
to keep the explicit macro like OPT_STRING_VALIDATE() as a way to
enforce the correct typing of the function. Otherwise, we'd have to
have the validator take a void * and hope the implementation can cast
it correctly.
For help, we don't have this problem, as help doesn't look at the
value.
Then, we turn validators that are really help generators into explicit
help functions and where a validator is help + validation, we split
them into two parts.
I have, however, left functions that need to query information for both
help and validation as single functions to avoid code duplication.
In this change, I have not added an other OPT_FOO_VALIDATE() macros as
they are not needed, but I will add some in a separate change to
illustrate the pattern.
2021-02-21 00:41:44 +00:00
|
|
|
|
|
|
|
// Optional function that validates a param value for this option.
|
|
|
|
m_opt_generic_validate_fn validate;
|
|
|
|
|
|
|
|
// Optional function that displays help. Will replace type-specific help.
|
|
|
|
int (*help)(struct mp_log *log, const m_option_t *opt, struct bstr name);
|
2002-11-12 01:56:42 +00:00
|
|
|
};
|
|
|
|
|
2018-01-24 00:32:56 +00:00
|
|
|
char *format_file_size(int64_t size);
|
2002-11-12 01:56:42 +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
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// The option should be set during command line pre-parsing
|
2016-09-19 23:17:29 +00:00
|
|
|
#define M_OPT_PRE_PARSE (1 << 4)
|
2011-07-03 12:42:04 +00:00
|
|
|
|
2014-08-13 21:24:46 +00:00
|
|
|
// The option expects a file name (or a list of file names)
|
2016-09-19 23:17:29 +00:00
|
|
|
#define M_OPT_FILE (1 << 5)
|
2014-08-13 21:24:46 +00:00
|
|
|
|
2016-09-01 18:00:43 +00:00
|
|
|
// Do not add as property.
|
2016-09-19 23:17:29 +00:00
|
|
|
#define M_OPT_NOPROP (1 << 6)
|
2016-09-01 18:00:43 +00:00
|
|
|
|
2018-04-21 18:33:58 +00:00
|
|
|
// Enable special semantics for some options when parsing the string "help".
|
|
|
|
#define M_OPT_HAVE_HELP (1 << 7)
|
|
|
|
|
2016-09-19 17:51:26 +00:00
|
|
|
// The following are also part of the M_OPT_* flags, and are used to update
|
|
|
|
// certain groups of options.
|
2018-05-12 15:29:27 +00:00
|
|
|
#define UPDATE_OPT_FIRST (1 << 8)
|
|
|
|
#define UPDATE_TERM (1 << 8) // terminal options
|
sub: make filter_sdh a "proper" filter, allow runtime changes
Until now, filter_sdh was simply a function that was called by sd_ass
directly (if enabled).
I want to add another filter, so it's time to turn this into a somewhat
more general subtitle filtering infrastructure.
I pondered whether to reuse the audio/video filtering stuff - but better
not. Also, since subtitles are horrible and tend to refuse proper
abstraction, it's still messed into sd_ass, instead of working on the
dec_sub.c level. Actually mpv used to have subtitle "filters" and even
made subtitle converters part of it, but it was fairly horrible, so
don't do that again.
In addition, make runtime changes possible. Since this was supposed to
be a quick hack, I just decided to put all subtitle filter options into
a separate option group (=> simpler change notification), to manually
push the change through the playloop (like it was sort of before for OSD
options), and to recreate the sub filter chain completely in every
change. Should be good enough.
One strangeness is that due to prefetching and such, most subtitle
packets (or those some time ahead) are actually done filtering when we
change, so the user still needs to manually seek to actually refresh
everything. And since subtitle data is usually cached in ASS_Track (for
other terrible but user-friendly reasons), we also must clear the
subtitle data, but of course only on seek, since otherwise all subtitles
would just disappear. What a fucking mess, but such is life. We could
trigger a "refresh seek" to make this more automatic, but I don't feel
like it currently.
This is slightly inefficient (lots of allocations and copying), but I
decided that it doesn't matter. Could matter slightly for crazy ASS
subtitles that render with thousands of events.
Not very well tested. Still seems to work, but I didn't have many test
cases.
2020-02-16 00:02:17 +00:00
|
|
|
#define UPDATE_SUB_FILT (1 << 9) // subtitle filter options
|
2016-09-19 23:17:29 +00:00
|
|
|
#define UPDATE_OSD (1 << 10) // related to OSD rendering
|
2017-09-26 23:17:47 +00:00
|
|
|
#define UPDATE_BUILTIN_SCRIPTS (1 << 11) // osc/ytdl/stats
|
2016-09-20 13:34:31 +00:00
|
|
|
#define UPDATE_IMGPAR (1 << 12) // video image params overrides
|
2016-09-21 13:56:54 +00:00
|
|
|
#define UPDATE_INPUT (1 << 13) // mostly --input-* options
|
2016-09-22 18:56:34 +00:00
|
|
|
#define UPDATE_AUDIO (1 << 14) // --audio-channels etc.
|
2016-09-28 11:47:30 +00:00
|
|
|
#define UPDATE_PRIORITY (1 << 15) // --priority (Windows-only)
|
2016-10-02 10:33:34 +00:00
|
|
|
#define UPDATE_SCREENSAVER (1 << 16) // --stop-screensaver
|
2017-04-26 19:45:50 +00:00
|
|
|
#define UPDATE_VOL (1 << 17) // softvol related options
|
2017-08-12 21:08:48 +00:00
|
|
|
#define UPDATE_LAVFI_COMPLEX (1 << 18) // --lavfi-complex
|
2019-11-24 23:26:36 +00:00
|
|
|
#define UPDATE_HWDEC (1 << 20) // --hwdec
|
|
|
|
#define UPDATE_DVB_PROG (1 << 21) // some --dvbin-...
|
2020-08-12 15:28:08 +00:00
|
|
|
#define UPDATE_SUB_HARD (1 << 22) // subtitle opts. that need full reinit
|
player: make all autoload extensions configurable
--audio-file-auto, --cover-art-auto, and --sub-auto all work by using an
internally hardcoded list that determine what file extensions get
recognized. This is fine and people periodically update it, but we can
actually expose this as a stringlist option instead. This way users can
add or remove any file extension for any type. For the most part, this
is pretty pretty easy and involves making sub_exts, etc. the defaults
for the new options (--audio-file-auto-exts, --cover-art-auto-exts, and
--sub-auto-exts). There's actually one slight complication however. The
input code uses mp_might_be_subtitle_file which guesses if the file drag
and dropped file is a subtitle. The input ctx has no access to mpctx so
we have to be clever here.
For this, the trick is to recognize that we can leverage the
m_option_change_callback. We add a new flag, UPDATE_SUB_EXTS, which
fires when the player starts up. Then in the callback, we can set the
value of sub_exts in external_files to opts->sub_auto_exts. Whenever the
option updates, the callback is fired again and sub_exts updates. That
way mp_might_be_subtitle_file can just operate off of this global
variable instead of trying to mess with the core mpv state directly.
Fixes #12000.
2023-08-10 22:36:22 +00:00
|
|
|
#define UPDATE_SUB_EXTS (1 << 23) // update internal list of sub exts
|
2024-02-01 22:41:43 +00:00
|
|
|
#define UPDATE_VIDEO (1 << 24) // force redraw if needed
|
2024-07-04 07:41:41 +00:00
|
|
|
#define UPDATE_VO (1 << 25) // reinit the VO
|
|
|
|
#define UPDATE_OPT_LAST (1 << 25)
|
2016-09-19 17:51:26 +00:00
|
|
|
|
|
|
|
// All bits between _FIRST and _LAST (inclusive)
|
|
|
|
#define UPDATE_OPTS_MASK \
|
|
|
|
(((UPDATE_OPT_LAST << 1) - 1) & ~(unsigned)(UPDATE_OPT_FIRST - 1))
|
|
|
|
|
2019-10-24 22:25:05 +00:00
|
|
|
// type_float/type_double: string "default" is parsed as NaN (and reverse)
|
2024-07-04 07:41:41 +00:00
|
|
|
#define M_OPT_DEFAULT_NAN (1 << 26)
|
2020-04-09 09:08:03 +00:00
|
|
|
|
|
|
|
// type time: string "no" maps to MP_NOPTS_VALUE (if unset, NOPTS is rejected)
|
2024-07-04 07:41:41 +00:00
|
|
|
#define M_OPT_ALLOW_NO (1 << 27)
|
2019-10-24 22:25:05 +00:00
|
|
|
|
2020-04-09 09:27:38 +00:00
|
|
|
// type channels: disallow "auto" (still accept ""), limit list to at most 1 item.
|
2024-07-04 07:41:41 +00:00
|
|
|
#define M_OPT_CHANNELS_LIMITED (1 << 28)
|
2020-04-09 09:27:38 +00:00
|
|
|
|
2023-11-19 20:22:24 +00:00
|
|
|
// type_float/type_double: controls if pretty print should trim trailing zeros
|
2024-07-04 07:41:41 +00:00
|
|
|
#define M_OPT_FIXED_LEN_PRINT (1 << 29)
|
2023-11-19 20:22:24 +00:00
|
|
|
|
2017-06-23 18:23:51 +00:00
|
|
|
// Like M_OPT_TYPE_OPTIONAL_PARAM.
|
|
|
|
#define M_OPT_OPTIONAL_PARAM (1 << 30)
|
|
|
|
|
2011-07-03 12:42:04 +00:00
|
|
|
// These are kept for compatibility with older code.
|
|
|
|
#define CONF_NOCFG M_OPT_NOCFG
|
|
|
|
#define CONF_PRE_PARSE M_OPT_PRE_PARSE
|
|
|
|
|
|
|
|
// These flags are used to describe special parser capabilities or behavior.
|
|
|
|
|
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.
|
2017-06-26 19:07:00 +00:00
|
|
|
#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 0)
|
2012-08-05 21:34:28 +00:00
|
|
|
|
2018-02-13 02:16:29 +00:00
|
|
|
// Behaves fundamentally like a choice or a superset of it (all allowed string
|
|
|
|
// values are from a fixed set, although other types of values like numbers
|
|
|
|
// might be allowed too). E.g. m_option_type_choice and m_option_type_flag.
|
|
|
|
#define M_OPT_TYPE_CHOICE (1 << 1)
|
|
|
|
|
2020-03-13 15:49:39 +00:00
|
|
|
// When m_option.min/max are set, they denote a value range.
|
|
|
|
#define M_OPT_TYPE_USES_RANGE (1 << 2)
|
|
|
|
|
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,
|
2016-09-17 16:07:40 +00:00
|
|
|
// parsers return M_OPT_EXIT.
|
2011-07-03 12:42:04 +00:00
|
|
|
//
|
|
|
|
// 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 when MPlayer should exit. Used by various help stuff.
|
2017-07-02 11:52:36 +00:00
|
|
|
#define M_OPT_EXIT -6
|
2002-11-12 01:56:42 +00:00
|
|
|
|
2011-07-29 04:52:29 +00:00
|
|
|
char *m_option_strerror(int code);
|
|
|
|
|
options: Make validation and help possible for all option types
Today, validation is only possible for string type options. But there's
no particular reason why it needs to be restricted in this way, and
there are potential uses, to allow other options to be validated
without forcing the option to have to reimplement parsing from
scratch.
The first part, simply making the validation function an explicit
field instead of overloading priv is simple enough. But if we only do
that, then the validation function still needs to deal with the raw
pre-parsed string. Instead, we want to allow the value to be parsed
before it is validated. That in turn leads to us having validator
functions that should be type aware. Unfortunately, that means we need
to keep the explicit macro like OPT_STRING_VALIDATE() as a way to
enforce the correct typing of the function. Otherwise, we'd have to
have the validator take a void * and hope the implementation can cast
it correctly.
For help, we don't have this problem, as help doesn't look at the
value.
Then, we turn validators that are really help generators into explicit
help functions and where a validator is help + validation, we split
them into two parts.
I have, however, left functions that need to query information for both
help and validation as single functions to avoid code duplication.
In this change, I have not added an other OPT_FOO_VALIDATE() macros as
they are not needed, but I will add some in a separate change to
illustrate the pattern.
2021-02-21 00:41:44 +00:00
|
|
|
// Base function to parse options. Includes calling help and validation
|
|
|
|
// callbacks. Only when this functionality is for some reason required to not
|
|
|
|
// happen should the parse function pointer be utilized by itself.
|
|
|
|
//
|
|
|
|
// See \ref m_option_type::parse.
|
|
|
|
int m_option_parse(struct mp_log *log, const m_option_t *opt,
|
|
|
|
struct bstr name, struct bstr param, void *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,
|
2023-11-19 20:22:24 +00:00
|
|
|
const void *val_ptr,
|
|
|
|
bool fixed_len)
|
2012-09-18 13:31:46 +00:00
|
|
|
{
|
2023-11-19 20:22:24 +00:00
|
|
|
m_option_t o = *opt;
|
|
|
|
if (fixed_len)
|
|
|
|
o.flags |= M_OPT_FIXED_LEN_PRINT;
|
2012-09-18 13:31:46 +00:00
|
|
|
if (opt->type->pretty_print)
|
2023-11-19 20:22:24 +00:00
|
|
|
return opt->type->pretty_print(&o, val_ptr);
|
2012-09-18 13:31:46 +00:00
|
|
|
else
|
2023-11-19 20:22:24 +00:00
|
|
|
return m_option_print(&o, val_ptr);
|
2012-09-18 13:31:46 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-02-24 19:07:41 +00:00
|
|
|
// see m_option_type.set
|
|
|
|
static inline int m_option_set_node(const m_option_t *opt, void *dst,
|
|
|
|
struct mpv_node *src)
|
|
|
|
{
|
|
|
|
if (opt->type->set)
|
|
|
|
return opt->type->set(opt, dst, src);
|
|
|
|
return M_OPT_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2016-04-15 09:31:24 +00:00
|
|
|
// Call m_option_parse for strings, m_option_set_node otherwise.
|
|
|
|
int m_option_set_node_or_string(struct mp_log *log, const m_option_t *opt,
|
|
|
|
const char *name, void *dst, struct mpv_node *src);
|
|
|
|
|
2014-02-24 19:07:41 +00:00
|
|
|
// see m_option_type.get
|
|
|
|
static inline int m_option_get_node(const m_option_t *opt, void *ta_parent,
|
|
|
|
struct mpv_node *dst, void *src)
|
|
|
|
{
|
|
|
|
if (opt->type->get)
|
|
|
|
return opt->type->get(opt, ta_parent, dst, src);
|
|
|
|
return M_OPT_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2019-11-28 15:52:46 +00:00
|
|
|
static inline bool m_option_equal(const m_option_t *opt, void *a, void *b)
|
|
|
|
{
|
|
|
|
// Handle trivial equivalence.
|
|
|
|
// If not implemented, assume this type has no actual values => always equal.
|
|
|
|
if (a == b || !opt->type->equal)
|
|
|
|
return true;
|
|
|
|
return opt->type->equal(opt, a, b);
|
|
|
|
}
|
|
|
|
|
2013-04-21 01:18:32 +00:00
|
|
|
int m_option_required_params(const m_option_t *opt);
|
|
|
|
|
2013-12-18 16:12:27 +00:00
|
|
|
extern const char m_option_path_separator;
|
|
|
|
|
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)))
|
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_TYPED_FIELD(type_, c_type, field) \
|
|
|
|
.type = &type_, \
|
|
|
|
.offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, field, c_type)
|
2006-04-24 19:20:04 +00:00
|
|
|
|
2011-04-19 01:11:52 +00:00
|
|
|
#define OPTION_LIST_SEPARATOR ','
|
|
|
|
|
2013-11-28 18:04:16 +00:00
|
|
|
#define OPTDEF_STR(s) .defval = (void *)&(char * const){s}
|
|
|
|
#define OPTDEF_INT(i) .defval = (void *)&(const int){i}
|
2018-05-12 13:14:07 +00:00
|
|
|
#define OPTDEF_INT64(i) .defval = (void *)&(const int64_t){i}
|
2013-11-28 18:04:16 +00:00
|
|
|
#define OPTDEF_FLOAT(f) .defval = (void *)&(const float){f}
|
|
|
|
#define OPTDEF_DOUBLE(d) .defval = (void *)&(const double){d}
|
2012-05-17 00:31:11 +00:00
|
|
|
|
2023-02-25 04:54:26 +00:00
|
|
|
#define M_RANGE(a, b) .min = (double) (a), .max = (double) (b)
|
2013-03-01 10:21:13 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_BOOL(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_bool, bool, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_INT(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_int, int, field)
|
options: introduce bool option type, use it for --fullscreen
The option code is very old and was added to MPlayer in the early 2000s,
when C99 was still new. MPlayer did not use the "bool" type anywhere,l
and the logical option equivalent to bool, the "flag" option type, used
int, with the convention that only the values 0 and 1 are allowed.
mpv may have hammered many, many additional tentacles to the option
code, but some of the basics never changed, and m_option_type_flag still
uses int. This seems a bit weird, since mpv uses bool for booleans. So
finally introduce an m_option_type_bool. To avoid duplicating too much
code, change the flag code to bool, and "reimplement" m_option_type_flag
on top of m_option_type_bool.
As a "demonstration", change the --fullscreen option to this new type.
Ideally, all options would be changed too bool, and m_option_type_flag
would be removed. But that is a lot of monotonous thankless work, so I'm
not doing it, and making it a painful years long transition.
At the same time, I'm introducing a new concept for option declarations.
Instead of OPT_BOOL(), which define the full m_option struct contents,
there's OPTF_BOOL(), which only takes the option field name itself. The
name is provided via a normal struct field initializer. Other fields
(such as flags) can be provided via designated initializers.
The advantage of this is that we don't need tons of nested vararg
macros. We also don't need to deal with 0-sized varargs being a pain
(and in fact they are not a thing in standard C99 and probably C11).
There is no need to provide a mandatory flags argument either, which is
the reason why so many OPT_ macros are used with a "0" argument. (The
flag argument seems to confuse other developers; they either don't
immediately recognize what it is, and sometimes it's supposed to be the
option's default value.)
Not having to mess with the flag argument in such option macros is also
a reason for the removal of M_OPT_RANGE etc., for the better or worse.
The only place that special-cased the _flag option type was in
command.c; change it to use something effectively very similar that
automatically includes the new _bool option type. Everything else should
be transparent to the change. The fullscreen option change should be
transparent too, as C99 bool is basically an integer type that is
clamped to 0/1 (except in Swift, Swift sucks).
2020-03-14 01:07:35 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_INT64(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_int64, int64_t, field)
|
|
|
|
|
|
|
|
#define OPT_FLOAT(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_float, float, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_DOUBLE(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_double, double, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_STRING(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_string, char*, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_STRINGLIST(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_string_list, char**, field)
|
2014-01-16 22:03:40 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_KEYVALUELIST(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_keyvalue_list, char**, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_PATHLIST(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_string_list, char**, field), \
|
|
|
|
.priv = (void *)&m_option_path_separator
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_TIME(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_time, double, field)
|
2013-03-04 16:40:21 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_REL_TIME(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_rel_time, struct m_rel_time, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_COLOR(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_color, struct m_color, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_BYTE_SIZE(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_byte_size, int64_t, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: fix OPT_BYTE_SIZE upper limits
As an unfortunate disaster, min/max values use the type double, which
causes tons of issues with int64_t types. Anyway, OPT_BYTE_SIZE is often
used as maximum for size_t quantities, which can have a size different
from (u)int64_t.
OPT_BYTE_SIZE still uses in64_t, because in theory, you could use it for
file sizes. (demux.c would for example be capable of caching more than
2GB on 32 bit platforms if a file cache is used. Though for some reason
the accounting code still uses size_t, so that use case is broken. But
still insist that it _could_ be used this way.)
There were various inconsistent attempts to set m_option.max to a value
such that the size_t/int64_t upper limit is not exceeded. Due to the
double max field, this didn't really work correctly. Try to fix this
with the M_MAX_MEM_BYTES constant. It's a good approximation, because on
32 bit it should allow 2GB (untested, also would probably exhaust
address space in practice but whatever), and something "high enough" in
64 bit.
For some reason, clang 11 still warns. But I think this might be a clang
bug, or I'm crazy. The result is correct anyway.
2020-03-18 19:51:38 +00:00
|
|
|
// (Approximation of x<=SIZE_MAX/2 for m_option.max, which is double.)
|
|
|
|
#define M_MAX_MEM_BYTES MPMIN((1ULL << 62), (size_t)-1 / 2)
|
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_GEOMETRY(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_geometry, struct m_geometry, field)
|
2018-03-13 10:23:23 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_SIZE_BOX(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_size_box, struct m_geometry, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
2023-08-25 17:00:31 +00:00
|
|
|
#define OPT_RECT(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_rect, struct m_geometry, field)
|
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_TRACKCHOICE(field) \
|
|
|
|
OPT_CHOICE(field, {"no", -2}, {"auto", -1}), \
|
|
|
|
M_RANGE(0, 8190)
|
2013-03-08 01:08:02 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_MSGLEVELS(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_msglevels, char **, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_ASPECT(field) \
|
2023-08-08 22:24:28 +00:00
|
|
|
OPT_TYPED_FIELD(m_option_type_aspect, double, field)
|
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
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_IMAGEFORMAT(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_imgfmt, int, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_AUDIOFORMAT(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_afmt, int, field)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_CHANNELS(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_channels, struct m_channels, field)
|
2015-03-04 16:20:47 +00:00
|
|
|
|
2024-02-26 03:55:00 +00:00
|
|
|
#define OPT_INT_VALIDATE_FUNC(func) OPT_VALIDATE_FUNC(func, const int *, int)
|
|
|
|
|
2021-03-20 18:50:22 +00:00
|
|
|
#define OPT_INT_VALIDATE(field, validate_fn) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_int, int, field), \
|
2024-02-26 03:55:00 +00:00
|
|
|
.validate = OPT_FUNC_IN(validate_fn, int)
|
|
|
|
|
|
|
|
#define OPT_STRING_VALIDATE_FUNC(func) OPT_VALIDATE_FUNC(func, const char **, str)
|
2021-03-20 18:50:22 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_STRING_VALIDATE(field, validate_fn) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_string, char*, field), \
|
2024-02-26 03:55:00 +00:00
|
|
|
.validate = OPT_FUNC_IN(validate_fn, str)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define M_CHOICES(...) \
|
|
|
|
.priv = (void *)&(const struct m_opt_choice_alternatives[]){ __VA_ARGS__, {0}}
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
// Variant which takes a pointer to struct m_opt_choice_alternatives directly
|
|
|
|
#define OPT_CHOICE_C(field, choices) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_choice, int, field), \
|
|
|
|
.priv = (void *)MP_EXPECT_TYPE(const struct m_opt_choice_alternatives*, choices)
|
2013-03-01 10:27:49 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
// Variant where you pass a struct m_opt_choice_alternatives initializer
|
|
|
|
#define OPT_CHOICE(field, ...) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_choice, int, field), \
|
|
|
|
M_CHOICES(__VA_ARGS__)
|
2012-05-17 00:31:11 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_FLAGS(field, ...) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_flags, int, field), \
|
|
|
|
M_CHOICES(__VA_ARGS__)
|
2012-09-05 00:39:12 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_SETTINGSLIST(field, objlist) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_obj_settings_list, m_obj_settings_t*, field), \
|
|
|
|
.priv = (void*)MP_EXPECT_TYPE(const struct m_obj_list*, objlist)
|
2016-08-31 16:10:11 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_FOURCC(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_fourcc, int, field)
|
2013-03-01 20:19:20 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_CYCLEDIR(field) \
|
|
|
|
OPT_TYPED_FIELD(m_option_type_cycle_dir, double, field)
|
2013-12-26 18:22:40 +00:00
|
|
|
|
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.
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
// "field" refers to the field, that must be a pointer to a field described by
|
2012-08-06 15:45:17 +00:00
|
|
|
// the subconf struct.
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_SUBSTRUCT(field, subconf) \
|
|
|
|
.offset = offsetof(OPT_BASE_STRUCT, field), \
|
|
|
|
.type = &m_option_type_subconfig, .priv = (void*)&subconf
|
|
|
|
|
|
|
|
// Non-fields
|
2012-08-06 15:45:17 +00:00
|
|
|
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_ALIAS(newname) \
|
|
|
|
.type = &m_option_type_alias, .priv = newname, .offset = -1
|
2016-08-31 15:09:10 +00:00
|
|
|
|
|
|
|
// If "--optname" was removed, but "--newname" has the same semantics.
|
2014-12-11 00:04:15 +00:00
|
|
|
// It will be redirected, and a warning will be printed on first use.
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_REPLACED_MSG(newname, msg) \
|
|
|
|
.type = &m_option_type_alias, .priv = newname, \
|
|
|
|
.deprecation_message = (msg), .offset = -1
|
2017-04-10 19:19:13 +00:00
|
|
|
|
|
|
|
// Same, with a generic deprecation message.
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_REPLACED(newname) OPT_REPLACED_MSG(newname, "")
|
2014-12-11 00:04:15 +00:00
|
|
|
|
2017-07-02 14:26:41 +00:00
|
|
|
// Alias, resolved on the CLI/config file/profile parser level only.
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_CLI_ALIAS(newname) \
|
|
|
|
.type = &m_option_type_cli_alias, .priv = newname, \
|
|
|
|
.flags = M_OPT_NOPROP, .offset = -1
|
2017-07-02 14:26:41 +00:00
|
|
|
|
2016-08-31 15:09:10 +00:00
|
|
|
// "--optname" doesn't exist, but inform the user about a replacement with msg.
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
#define OPT_REMOVED(msg) \
|
|
|
|
.type = &m_option_type_removed, .priv = msg, \
|
|
|
|
.deprecation_message = "", .flags = M_OPT_NOPROP, .offset = -1
|
|
|
|
|
|
|
|
#define OPT_PRINT(fn) \
|
|
|
|
.flags = M_OPT_NOCFG | M_OPT_PRE_PARSE | M_OPT_NOPROP, \
|
|
|
|
.type = &m_option_type_print_fn, \
|
|
|
|
.priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \
|
|
|
|
.offset = -1
|
2014-12-11 00:04:15 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_M_OPTION_H */
|