summaryrefslogtreecommitdiffstats
path: root/options/m_option.h
Commit message (Collapse)AuthorAgeFilesLines
* m_option: add a force_update booleanDudemanguy7 days1-0/+3
| | | | | | | | | | | | | | | | | | | | | | mpv's core does not propagate option notifications unless they actually change to the rest of the player. Most of the time, this makes perfect sense. If the user sets fullscreen multiple times, there's no reason to care about anything other than the change in state. However, there are certain options where it makes sense to always broadcast a notification even if the value doesn't change. For example, consider the window-scale case. A user may set window-scale to some value, resize the window further through some other means (such as mouse resizing) and then want to set the window-scale again to the same value as earlier. The window-scale value did not change from before so no notification is sent and nothing happens even though it is desirable and expected that it operates again. This was solved by making the current-window-scale property writable a few years ago, but actually the easier solution is to just always force the option to update on any write. For the big callback, the needed changes are trivial. Unfortunately, it requires a hot mess in order to have this work with the m_config_cache_update APIs. Spooky stuff in there, but it does send the notification now.
* m_property: add `>` for fixed precision floating-point expansionKacper Michajłow2024-03-211-3/+10
| | | | | | | | | | | | | | This enhancement makes it easier to create constant width property expansions, useful for the `--term-status-msg`. Additionally, it changes to `%f` printing with manual zero trimming, which is easier to control than `%g`. With this method, we can directly specify precision, not just significant numbers. This approach also avoids overly high precision for values less than 1, which is not necessary for a generic floating-point print function. A new print helper function is added, which can be used with adjusted precision for specific cases where a different default is needed. This also unifies the code slightly.
* various: avoid function pointer castsKacper Michajłow2024-02-281-10/+17
| | | | | | | | | | | | | The opt validator functions are casted to generic validator, which has erased type for value. Calling function by pointer of different definition is an UB. Avoid that by generating wrapper function that does proper argument type conversion and calls validator function. Type erased functions have mangled type in the name. Fixes UBSAN failures on Clang 17, which enabled fsanitize=function by default.
* player: ensure runtime updates of certain rendering optionsDudemanguy2024-02-051-1/+2
| | | | | | | | | | When adding things like brightness or gamma, the video obviously needs a redraw if paused. This happened to work in the normal case because the OSD notification triggered a redraw, but if you use no-osd the picture won't change. Fix this by adding another option flag, UPDATE_VIDEO, and simply signalling we want a redraw. This gets handled along with the normal osd redrawing check in the playloop so something like "no-osd add gamma 1" actually works.
* m_option: initialize m_option_value union properlyKacper Michajłow2023-10-231-0/+5
| | | | | | | | | C standard says that `= {0}` activates and initializes first member of union. We expect whole union to be zeroed, it is used as default value. Initialize union with one zeroed default instance to ensure proper init. Fixes: #12711
* m_option: make m_rect_apply center basedKacper Michajłow2023-09-081-1/+1
| | | | | | | | | This makes it easier to apply crops without need to manually calc the offset. I wanted for it to be top-left corner based, but maybe it was not that good idea in retrospect. Also rename scrw/scrh, since they don't refer to screen. It was copied form m_geometry apply.
* m_option: add OPT_RECTKacper Michajłow2023-08-311-0/+6
| | | | Parsed as WxH+X+Y to mp_rect. Allows also WxH without the offset.
* player: make all autoload extensions configurableDudemanguy2023-08-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | --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.
* m_option: change m_option_type_aspect to doubleDudemanguy2023-08-091-1/+1
| | | | | | | | | | | | | This specific option type is only used for the video aspect. The underlying type was a float to represent the inputted value, but it's actually not precise enough. When using something like 4:3, the values of the incorrect digits are actually significant enough to make av_d2q return a very funky numerator and denominator which is close to 4/3 but not quite. This leads to some "off by one pixel" errors. Weirdly, mpv's actual calculations for this were already being done as double, but then converted to floats for this specific type. Just drop the conversion step and leave it all as double which has the precision we need (i.e. AVRational is now 4/3 for the this case). Fixes #8190.
* client API: reintroduce CONF_TYPE_FLAG for type conversionChristoph Heinrich2023-02-271-0/+2
| | | | | | | | | | Changing the CONF_TYPE_FLAG was a bad idea because mpv_node.u.flag continues to be an int, leading to a mismatch in type sizes which can lead to problems with memcpy(). ref. #11373 This partially reverts commit 17d91b9d4d2d208f4a847395198cdbbcad18de93.
* various: fix warning -Wimplicit-const-int-float-conversionThomas Weißschuh2023-02-261-1/+1
|
* options: remove OPT_FLAGChristoph Heinrich2023-02-211-3/+0
|
* options: transition properties from flag to boolChristoph Heinrich2023-02-211-2/+1
|
* options: remove always true m_obj_list::allow_unknown_entriesEmil Velikov2021-11-151-3/+0
| | | | | | | Ever instance of m_obj_list is a constant and for all of them, the field is true. Just remove the field all together. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
* options: Add validation macro for int typePhilip Langdale2021-03-281-0/+8
| | | | As an illustrative example.
* options: Make validation and help possible for all option typesPhilip Langdale2021-03-281-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* options: simplify --android-surface-size handlingsfan52020-09-201-1/+0
|
* sd_ass: force full reinit if certain options change at runtimewm42020-08-121-1/+2
| | | | | | | | | | Options like --sub-ass-force-style and others could not be changed at runtime (the changes didn't take any effect). Fix this by using the brutal approach, and completely reinit the subtitle state when this happens. Maybe a bit clunky, but for now I'd rather not put more effort into this. Fixes: #7689
* x11: add option to make window appear on a specific workspacewm42020-07-121-0/+1
| | | | | | | | | Mess this into the --geometry option, because I like to be irresponsible. I considered adding a separate option, but at least this allows me to defer the question how the hell this should work as property (geometry simply and inherently does not). Tested on IceWM only. Option equality test and string output not tested.
* options: cleanup .min use for OPT_CHANNELSwm42020-04-091-3/+3
| | | | | | | | Replace use of .min==1 with a proper flag. This is a good idea, because it has nothing to do with numeric limits (also see commit 9d32d62b61547 for how this can go wrong). With this, m_option.min/max are strictly used for numeric limits.
* options: fix ab-loop-* propertieswm42020-04-091-1/+4
| | | | | | | | | | | These used ".min = MP_NOPTS_VALUE" to indicate certain exceptions. This broke with the recent change to how min/max are handled, which made setting min or max mean that a value range is used, thus setting max=0. Fix this by not using magic a value in .min; replace it with a proper flag. Fixes: #7596
* options: fix OPT_BYTE_SIZE upper limitswm42020-03-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* options: change option macros and all option declarationswm42020-03-181-133/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* options: introduce bool option type, use it for --fullscreenwm42020-03-141-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* options: change how option range min/max is handledwm42020-03-131-21/+14
| | | | | | | | | | | | | | | | | Before this commit, option declarations used M_OPT_MIN/M_OPT_MAX (and some other identifiers based on these) to signal whether an option had min/max values. Remove these flags, and make it use a range implicitly on the condition if min<max is true. This requires care in all cases when only M_OPT_MIN or M_OPT_MAX were set (instead of both). Generally, the commit replaces all these instances with using DBL_MAX/DBL_MIN for the "unset" part of the range. This also happens to fix some cases where you could pass over-large values to integer options, which were silently truncated, but now cause an error. This commit has some higher potential for regressions.
* options: remove intpair option typewm42020-03-131-6/+0
| | | | | | | | | | | This was mostly unused, and has certain problems. Just get rid of it. It was still used in CDDA (--cdda-span) and a debug option for OpenGL (--opengl-check-pattern). Replace both of these with 2 options, where each sets the start/end values of the former span. Both were undocumented somehow (normally we require all options to be documented), so I'm not caring about compatibility, and not bothering to add it to the API changelog.
* sub: make filter_sdh a "proper" filter, allow runtime changeswm42020-02-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* options: remove unused set_defaults callbackwm42020-02-011-4/+0
| | | | | Was only needed for an ancient version of af_lavfrresample, which is gone now.
* options: add mechanism to add sub-options from component listswm42020-01-041-0/+5
| | | | | | | | | | | | | There are a lot of ad-hoc component lists in mpv: for example the stream and demuxer lists. It doesn't seem to make sense to add any abstractions around it since they are completely trivial and have very specific probing mechanisms and so on, so they will remain ad-hoc. This commits add a way to let these add arbitrary per-component options, without giving up the ad-hoc way, and without having to dump them into options.c with lots of ifdeffery (like it was done until now). Also see next commit.
* options: fix filter list comparison (again)wm42019-12-181-0/+2
| | | | | | | | | | | This was completely broken: it compared the first item of the filter list only. Apparently I forgot that this is a list. This probably broke aspects of runtime filter changing probably since commit b16cea750f52. Fix this, and remove some redundant code from obj_settings_equals(). Which is not the same as m_obj_settings_equal(), so rename it to make confusing them harder. (obj_setting_match() has these very weird label semantics that should probably just be killed. Or not.)
* m_option: remove an outdated ancient commentwm42019-11-291-7/+1
| | | | | | | The exact type name (m_obj_list_t) was removed in 2013. I don't think this stub comment helps much with understanding this complicated thing anyway (this code is for the --vf/--af options, and makes up almost half of m_option.c).
* m_option: add option comparisonwm42019-11-291-0/+20
| | | | | | Looks like this will be needed for fine-grained option change notifications. There are some other parts in the player which implement parts of this.
* options: pre-check filter names when using vf/af libavfilter bridgewm42019-11-251-0/+3
| | | | | | | | | | | | | Until now, using a filter not in mpv's builtin filter list would assume it's a libavfilter filter. If it wasn't, the option value was still accepted, but creating the filter simply failed. But since this happens after option parsing, so the result is confusing. Improve this slightly by checking filter names. This will reject truly unknown filters at option parsing time. Unfortunately, this still does not check filter arguments. This would be much more complex, because you'd have to create a dummy filter graph and allocate the filter. Maybe another time.
* command: shuffle some crap aroundwm42019-11-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | This is preparation to get rid of the option-to-property bridge (mp_on_set_option). This is a pretty insane thing that redirects accesses to options to properties. It was needed in the ever ongoing transition from something to... something else. A good example for the need of this bridge is applying profiles at runtime. This obviously goes through the config parser, but should also make all changes effective, for which traditionally the property layer is used. There isn't much left that needs this bridge. This commit changes a bunch of options (which also have a property implementation) to use option change notifications instead. Many of the properties are still left, but perform unrelated functions like OSD formatting. This should be mostly compatible. There may be some subtle behavior changes. For example, "hwdec" and "record-file" do not check for changes anymore before applying them, so writing the current value to them suddenly does something, while it was ignored before. DVB changes untested, but should work.
* options: remove M_OPT_FIXEDwm42019-11-101-7/+1
| | | | | | | | | | | | | | | | | | | | | | | Options marked with this flag were changed to strictly read-only after initialization (mpv_initialize() in the client API, after option parsing and config file loading with the CLI player). This used to be necessary, because there was a single option struct that could be accessed by multiple threads. For example, --config-dir sets MPOpts.force_configdir, which was read whenever anything accessed the mpv config dir (which could be on different threads, e.g. font initialization tries to lookup fonts.conf from an arbitrary thread). This isn't needed anymore, because threads now access these in a thread safe way. In the case of --config-dir, the path is actually just copied on init. This M_OPT_FIXED mechanism is thus not strictly needed anymore. It still prevents writing to some options that cannot take effect at runtime, but even that can be dropped. In general, all mpv options can be changed any time at runtime, even if they never take effect, and there's no need to make an exception for a very low number of options. So just get rid of it.
* m_option: remove an unused functionwm42019-10-311-3/+0
| | | | I think the last real use of this went away in 2014 or so.
* vo_gpu, options: don't return NaN through APIwm42019-10-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Internally, vo_gpu uses NaN for some options to indicate a default value that is different depending on the context (e.g. different scalers). There are 2 problems with this: 1. you couldn't reset the options to their defaults 2. NaN is a damn mess and shouldn't be part of the API The option parser already rejected NaN explicitly, which is why 1. didn't work. Regarding 2., JSON might be a good example, and actually caused a bug report. Fix this by mapping NaN to the special value "default". I think I'd prefer other mechanisms (maybe just having every scaler expose separate options?), but for now this will do. See you in a future commit, which painfully deprecates this and replaces it with something else. I refrained from using "no" (my favorite magic value for "unset" etc.) because then I'd have e.g. make --no-scale-param1 work, which in addition to a lot of effort looks dumb and nobody will use it. Here's also an apology for the shitty added test script. Fixes: #6691
* m_option: remove an unused fieldwm42018-05-241-4/+0
|
* command: add a subprocess commandwm42018-05-241-0/+1
| | | | | | | This supports named arguments. It benefits from the infrastructure of async commands. The plan is to reimplement Lua's utils.subprocess() on top of it.
* m_option: fix duplicate flag valuePhilip Sequeira2018-05-131-2/+2
|
* encode: get rid of AVDictionary setter helperwm42018-04-291-0/+3
| | | | | | | | | | | | Removes a good hunk of weird code. This loses qscale "emulation", some logging, and the fact that duplicate keys for values starting with +/- were added with AV_DICT_APPEND. I don't assign those any importance, even if they are user-visible changes. The new M_OPT_ flag is just so that nothing weird happens for other key-value options, which do not interpret a "help" key specially.
* video: add an option to tune waiting for video timingwm42018-03-151-0/+3
| | | | Probably mostly useful for the libmpv render API.
* m_option: remove unneded compatibility featureswm42018-02-281-1/+1
| | | | | Aliases that set old options are not needed anymore. Also extend the total size of the aliases array for one of the following commits.
* options: minor cleanup to --no-... handlingwm42018-02-131-0/+5