summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
Commit message (Collapse)AuthorAgeFilesLines
* m_option: fix runtime changing of --audio-channelswm42019-12-271-3/+14
| | | | | | | | This option type, used by --audio-channels, had a completely broken m_option_type.equal implementation, and thus reacted incorrectly to runtime option changes. Broken since commit b16cea750f527088be7977.
* options: fix incorrect deprecation messagewm42019-12-191-2/+4
| | | | | Passing multiple items to a key/value option is OK, only for -add suffixed options it's deprecated.
* options: fix UB/crash in key/values parserwm42019-12-181-2/+2
| | | | | | | | keyvalue_list_find_key() was called on a "partially" constructed list, because the terminating NULL was added only later. Didn't I say this code is cursed? Fixes: #7273
* options: deprecate -del for list optionswm42019-12-181-0/+6
| | | | | | I never liked that these used integer indexes. -remove should have existed from the start. This deprecation is yet another empty threat, though.
* options: fix filter list comparison (again)wm42019-12-181-17/+15
| | | | | | | | | | | 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.)
* options: add -remove action to list optionswm42019-12-181-7/+36
| | | | | | Actually I wanted this for key/value lists only, but add it to the others for consistency too. (For vf/af it barely makes even sense, but anyway.)
* options: make keys in key/value lists uniquewm42019-12-181-0/+27
| | | | | | | | | | | | | | I don't even know anymore whether this was intended or not. Certain use cases for the "-o" options might require this. These options are for passing general FFmpeg options. These are translated to av_opt_set() calls, which may or may not accumulate the option values on multiple calls with the same option name (how should I know?). Anyway, it seems crazy to allow non-unique keys, so make them unique. The ad-hoc nature of the option code makes this wonderfully complicated (when I wrote that this code is cursed, I meant it). In combination with lazy testing, it probably means there are lots of bugs here.
* options: increase consistency between list options and document themwm42019-12-181-3/+16
| | | | | | | | | | | | | | | | | | | | Whenever I deal with this, I have to look at the code to make sense of this. And beyond that, there are some strange inconsistencies. (I think this code is cursed. It always was, and maybe always will be.) Although the manpage claimed that using multiple items for -add etc. is deprecated, string list options didn't warn against it. So add the warning, and add something in the changelog (even though nobody will ever read this). The manpage mentioned --vf-append, but this didn't even exist. So add it, I guess. We encourage using -append for the other option types, so for consistency, it should work on filter options. (And I already tricked me into believing it existed when I mentioned it in the manpage.) Make the "operations" table separate for all option types, and mention the option type on every single of the top-level list options.
* m_option: clamp integer before adding a valuewm42019-12-161-0/+2
| | | | | | | | | | | | | | This is for the previous commit, and should affect behavior with the special M_PROPERTY_GET_CONSTRICTED_TYPE mechanism only. The effect is that cycling the "edition" property, if the option is set to "auto", will change to the second edition instead of the first. Normally, option values must always be within their range, so this should not affect anything else. M_PROPERTY_GET_CONSTRICTED_TYPE is sort-of fine with this kind of behavior. If this affects any other M_PROPERTY_GET_CONSTRICTED_TYPE users neqatively, I will revert the change.
* m_option: add option comparisonwm42019-11-291-1/+136
| | | | | | 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-1/+5
| | | | | | | | | | | | | 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.
* m_option: remove an unused functionwm42019-10-311-9/+0
| | | | I think the last real use of this went away in 2014 or so.
* Replace uses of FFMIN/MAX with MPMIN/MAXwm42019-10-311-5/+4
| | | | And remove libavutil includes where possible.
* vo_gpu, options: don't return NaN through APIwm42019-10-251-9/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | 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: add "B" suffix to human-readable byte numberswm42019-09-191-3/+5
| | | | | | | | | | The conversion to string as the pretty printer returns it is sometimes used on OSD. I think it's pretty odd that quantities below 1 KB are shown as number without suffix. So use "B" for them. For orthogonality, allow the same for parsing. (Although strictly speaking, this is not a requirement of the option API. Option parsers don't need to accept pretty-printed strings.)
* m_option: remove an unused fieldwm42018-05-311-9/+0
|
* 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.
* m_option: remove unneded compatibility featureswm42018-02-281-8/+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-2/+4
| | | | | | | | Most options starting with --no-<name> are automatically translated to --<name>=no. Make the code slightly nicer by using a flag instead of explicitly comparing option types. Also fix an issue that made the option parser print nonsense error messages for if --no-... was used for options which don't support it.
* options: slightly improve filter help output for lavfi bridgewm42018-02-031-1/+9
| | | | | | | | | | | | | | --vf=help will now list libavfilter filters, and e.g. --vf=yadif=help will list libavfilter filter options. The latter is rather bare, because the AVOption API is really awful (holy shit how is it so bad), and would require us to handle _every_ option type manually. Alternatively we could call av_opt_show2(), which ffmpeg uses for help output in its CLI tools and which is much more detailed. But it's rather foreign and forces output through av_log(), so I don't really want to use it.
* options: add string list -toggle actionwm42018-01-251-0/+24
|
* m_option: remove string list -append action code duplicationwm42018-01-251-15/+6
| | | | | | | | Instead of duplicating the append code, reimplement it using the existing code. The difference between -add and -append is that -append does not take multiple items (thus removing the need for escaping), but -append can reuse all code for -add by pretending the separator is never found.
* options: add an option type for byte sizeswm42018-01-251-0/+95
| | | | | | And use it for 2 demuxer options. It could be used for more options later. (Though the --cache options can not use this, because they use KB as base unit.)
* m_option: add missing print callbackswm42018-01-251-5/+35
| | | | | | | | | | | Add the print callback to all option types (except pseudo option types which don't represent values). This makes it less confusing for client API users (no strange properties that can't be read), and also lists the default properly with --list-options. Fix the option type for audio formats - they use int, not uint32_t. Fix some identation cosmetic issues.
* m_option: add print callback to color typeOlivier Perret2018-01-221-0/+7
| | | | This lets scripts query the value of 'background' and similar properties
* m_option: add print callback to start/end/lengthRicardo Constantino2018-01-031-0/+18
|
* options: add -add/-append actions to key/value listswm42017-12-261-4/+30
| | | | Requested.
* options: rename 'error' labels to 'exit' where appropriatepavelxdd2017-12-161-13/+13
|
* options: don't report errors on help value for OPT_SIZE_BOXpavelxdd2017-12-161-4/+10
| | | | | | The same idea as in 3723e61 but for OPT_SIZE_BOX now. Affects options `autofit`, `autofit-larger` and `autofit-smaller`.
* options: don't report errors on help value for OPT_GEOMETRYpavelxdd2017-12-111-4/+11
| | | | The same idea as in 3723e61 but for OPT_GEOMETRY now.
* options: don't report errors on help value for OPT_COLORpavelxdd2017-12-111-6/+12
| | | | | The same idea as in 3723e61 but for OPT_COLOR now. Added missing closing bracket in the help message.
* options: don't report errors on help value for OPT_FLAGpavelxdd2017-12-111-4/+9
| | | | The same idea as in 3723e61 but for OPT_FLAG now.
* options: don't report errors on help value for OPT_CHOICEpavelxdd2017-12-081-4/+15
| | | | | | | 'help' is a valid value for a lot of mpv options, such as `hwdec` or `vo` for printing available values, so this change makes the output of OPT_CHOICE options like `--video-sync=help` more consistent by not reporting an error about invalid value 'help'.
* options: add --start=none to reset previously set start timeAman Gupta2017-12-061-0/+5
| | | | | | | | | | | | | Previously when using a libmpv instance to play multiple videos, once --start was set there was no clear way to unset it. You could use --start=0, but 0 does not always mean the beginning of the file (especially when using --rebase-start-time=no). Looking up the start timestamp and passing that in also does not always work, particularly when the first timestamp is negative (since negative values to --start have a special meaning). This commit adds a new "none" value which maps to the internal REL_TIME_NONE, matching the default value of the play_start option.
* options: rename empty string special case for option valueswm42017-12-011-3/+0
| | | | | "--bla" behaved differently from "--bla=". Change this, in line with how options have been changed in general over the last few years.
* m_option: pretty print mpv_node for OSDwm42017-10-301-0/+11
| | | | | | Somewhat useful for debugging. Unfortunately libass (or something else) strips leading whitespace, making it look slightly more ugly than necessary. Still an improvement.
* build: add preliminary LGPL modewm42017-09-211-9/+7
| | | | | | | See "Copyright" file for caveats. This changes the remaining "almost LGPL" files to LGPL, because we think that the conditions the author set for these was finally fulfilled.
* m_option: deprecate multiple items for -add etc.wm42017-07-021-2/+10
| | | | | | | | This is more confusing than it helps, and forces escaping more stuff. For example, for string lists we could remove all need for escaling with -add and -pre. The user can simply use multiple of those options.
* options: change everything againwm42017-07-021-28/+5
| | | | Fucking bullshit.
* m_option: remove unused error codewm42017-07-021-5/+0
| | | | | The situation in the str_list_* functions can never happen, and they were the only users of this error code.
* m_option: remove redundant indirectionswm42017-07-021-2/+2
| | | | | | Remove the various redundant m_config_set_option* calls, rename the remaining one to m_config_set_option_cli(), and merge the m_config_parse_option() function.
* options: change path list options, and document list optionswm42017-06-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | The changes to path list options is basically getting rid of the need to pass multiple paths to a single option. Instead, you can use the option multiple times. The old behavior can be used by using the -set suffix with the option. Change some options to path lists. For example --script is now append by default, and if you use --script-set, you need to use ":"/";" as separator instead of ",". --sub-paths/--audio-file-paths is a deprecated alias now, and will break if the user tries to pass multiple paths to it. I'm assuming that if these are used, most users will pass only 1 path anyway. --opengl-shaders has more compatibility handling, since it's probably rather common that users pass multiple options to it. Also document all that in the manpage. I'll probably regret this later, as it somewhat increases the complexity of the option parser, rather than increasing it.
* options: sort action list alphabeticallywm42017-06-271-11/+11
| | | | | | There is no technical need for this, but it's nicer if --list-options appears to output them sorted (it only actually sorts the actual option list, while actions are output in the order they are defined).
* options: expose string list actions for --sub-file optionwm42017-06-271-23/+38
| | | | | | | | | | | | This means you can use --sub-file-set=a,b,c to set a string list separated by ',', while --sub-file=filename,with,commas.srt still works (the original motivation for changing the --sub-file option this way). You can also use it to append strings to string list options without the need for escale, e.g.: --opengl-shaders-add-str=unescapesdfilename.glsl (The normal -add for some reason expects a ',' separated list as argument.)
* options: handle suffixes like -add in a more generic waywm42017-06-261-79/+65
| | | | | | | | | | | | | | | | This affects options like --vf or --display-tags. These used a "*" suffix to match all options starting with a specific name, and handled the rest in the option parser. Change this to remove the "*" special case, and require every option parser to declare a list of allowed suffixes via m_option_type.actions. The new way is conceptually simpler, because we don't have to account for the "*" in a bunch of places anymore, and instead everything is centrally handled in the CLI part of the option parser, where it's actually needed. It automatically enables suffixes like -add for a bunch of other stringlist options.
* Revert "parse_commandline: fail gracefully on bad args"wm42017-06-241-1/+1
| | | | | | This reverts commit 38b05daf7d16898f4a63e4ccf48479d8964e6e19. There was actually no LGPL relicensing agreement with wd0.
* options: simplify and rename m_option_type_storewm42017-06-231-38/+18
| | | | | | | | | | This was an annoying option type. And still is. But at least it's on the same level as m_option_type_print_fn now, and can probably cleaned up further like it. Both types are for options that are only on the command line, always have special handling (i.e. do something with them in parse_commandline.c before passing them to the generic m_config.c/m_option.c layers), and are m_options only for --list-options and (oddly) the split_opt_silent() function.
* options: unbreak -hwm42017-06-231-0/+2
| | | | Sure is a simple thing to break.
* Revert "m_option: make geometry code GPL-only"wm42017-06-221-32/+0
| | | | | | | | | | | | | | | | | | This reverts commit e30fe38a212d52bca4693941a7cfa9e44b675a66. The original author as well as the author from d568eaa2 agreed to LGPL now. The only one missing is 0842caf6 (Henk could not be reached, and that will probably stay this way). When I discussed this with someone else who knows a lot about copyright (j-b), the conclusion was that the rewrite was actually enough to remove all past copyright. Only the syntax and the option name remained the same, but code, code structure, and architecture all changed radically. So I'm content with dropping the GPL part. (m_option.c is still formally GPL due to the special agreement with michael, but once this is fullfilled, we will change the license to LGPL without further checks.)
* m_option: make geometry code GPL-onlywm42017-06-211-0/+32
| | | | | | | | | | | In commit eb22569ff082b, I claimed that the geometry parsing code was rewritten. But I'm not sure if it's rewritten enough, or if copyright claims could still be made. Given that the original code was self-contained, and could be considered a separate work, it's probably safer (and more up to the standards applied to this relicensing) to leave this as GPL code. The rewrite/code move can be seen with: git diff f2dcdca...ccaed5e
* img_format: minor simplificationwm42017-06-181-1/+1
|
* options: change license of most files to LGPL (except options.c/.h)wm42017-06-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | 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.
* m_option: revert commit 2793a70e0fb3wm42017-06-121-3/+2
|
* m_option: fix leaks with OPT_KEYVALUELIST optionswm42017-06-081-0/+3
| | | | | For example, specifying --script-opts multiple times could leak some data.
* video: support positional arguments for automatic lavfi option bridgewm42017-04-031-5/+22
| | | | | | Now e.g. --vf=pad=1000:1000 works. All in all pretty ugly and hacky. Just look away.
* command: change and simplify filter toggle syntaxwm42017-03-261-5/+23
| | | | | | | | | | | "@name:!" becomes simply "@name". This is actually slightly more complex to parse, but makes for a much simpler syntax and will be less weird to the user. Suggested by haasn. The old syntax is now rejected with an error. Also add some more explicit error checks, instead of e.g. allowing empty filter names and erroring only when it's not found.
* m_option: consistent af/vf filter entry "enabled" flag default valuewm42017-03-251-0/+1
| | | | | | | It should default to true, but setting the filter list via mpv_node (relevant for client API and Lua scripting) left it to false. Also "document" the flag.
* command: add better runtime filter toggling methodwm42017-03-251-7/+38
| | | | | | | | | | Basically, see the example in input.rst. This is better than the "old" vf-toggle method, because it doesn't require the user to duplicate the filter string in mpv.conf and input.conf. Some aspects of this changes are untested, so enjoy your alpha testing.
* m_option: optionally allow passing "no" to imgfmt option typeswm42017-03-021-4/+7
| | | | | | Needed for the following commit. Also, fix that uint32_t type