Commit Graph

188 Commits

Author SHA1 Message Date
wm4 8bdedf9062 options: make keys in key/value lists unique
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.
2019-12-18 06:03:39 +01:00
wm4 d3e3bd4307 options: increase consistency between list options and document them
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.
2019-12-18 05:32:02 +01:00
wm4 de0f9b9f2d m_option: clamp integer before adding a value
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.
2019-12-16 01:52:52 +01:00
wm4 63270ff898 m_option: add option comparison
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.
2019-11-29 12:14:43 +01:00
wm4 37ac43847e options: pre-check filter names when using vf/af libavfilter bridge
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.
2019-11-25 20:29:42 +01:00
wm4 821320252e m_option: remove an unused function
I think the last real use of this went away in 2014 or so.
2019-10-31 17:42:41 +01:00
wm4 6d92e55502 Replace uses of FFMIN/MAX with MPMIN/MAX
And remove libavutil includes where possible.
2019-10-31 11:24:20 +01:00
wm4 77f309c94f vo_gpu, options: don't return NaN through API
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
2019-10-25 00:25:05 +02:00
wm4 b45c17e5a9 m_option: add "B" suffix to human-readable byte numbers
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.)
2019-09-19 20:37:05 +02:00
wm4 f022bf61a9 m_option: remove an unused field 2018-05-31 01:24:51 +03:00
wm4 bfc33da250 encode: get rid of AVDictionary setter helper
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.
2018-04-29 02:21:32 +03:00
wm4 e76fda8594 m_option: remove unneded compatibility features
Aliases that set old options are not needed anymore. Also extend the
total size of the aliases array for one of the following commits.
2018-02-28 00:55:06 -08:00
wm4 223821d91c options: minor cleanup to --no-... handling
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.
2018-02-13 17:45:29 -08:00
wm4 afb167cfd2
options: slightly improve filter help output for lavfi bridge
--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.
2018-02-03 05:00:52 -08:00
wm4 3deef308c8 options: add string list -toggle action 2018-01-25 20:18:32 -08:00
wm4 415fc6e327 m_option: remove string list -append action code duplication
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.
2018-01-25 20:18:32 -08:00
wm4 11f5713e3b options: add an option type for byte sizes
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.)
2018-01-25 20:18:32 -08:00
wm4 cabfbc34b5 m_option: add missing print callbacks
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.
2018-01-25 20:18:32 -08:00
Olivier Perret 70b2be3cf7 m_option: add print callback to color type
This lets scripts query the value of 'background' and similar properties
2018-01-22 23:17:26 -08:00
Ricardo Constantino 877775f84e m_option: add print callback to start/end/length 2018-01-03 15:10:25 -08:00
wm4 e530783cdb options: add -add/-append actions to key/value lists
Requested.
2017-12-26 00:54:05 -07:00
pavelxdd e1ac0c1eb6 options: rename 'error' labels to 'exit' where appropriate 2017-12-16 02:20:44 +03:00
pavelxdd 7fc9ff54d3 options: don't report errors on help value for OPT_SIZE_BOX
The same idea as in 3723e61 but for OPT_SIZE_BOX now.

Affects options `autofit`, `autofit-larger` and `autofit-smaller`.
2017-12-16 01:29:05 +03:00
pavelxdd 6c8e7daebb options: don't report errors on help value for OPT_GEOMETRY
The same idea as in 3723e61 but for OPT_GEOMETRY now.
2017-12-11 21:56:20 +02:00
pavelxdd cdb6cb55e0 options: don't report errors on help value for OPT_COLOR
The same idea as in 3723e61 but for OPT_COLOR now.
Added missing closing bracket in the help message.
2017-12-11 21:56:20 +02:00
pavelxdd 3f127448e8 options: don't report errors on help value for OPT_FLAG
The same idea as in 3723e61 but for OPT_FLAG now.
2017-12-11 21:56:20 +02:00
pavelxdd 3723e611fc options: don't report errors on help value for OPT_CHOICE
'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'.
2017-12-08 20:47:14 +02:00
Aman Gupta 0c6a488ef9 options: add --start=none to reset previously set start time
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.
2017-12-06 20:50:31 +02:00
wm4 43af055a70 options: rename empty string special case for option values
"--bla" behaved differently from "--bla=". Change this, in line with how
options have been changed in general over the last few years.
2017-12-01 21:01:40 +01:00
wm4 694157e024 m_option: pretty print mpv_node for OSD
Somewhat useful for debugging. Unfortunately libass (or something else)
strips leading whitespace, making it look slightly more ugly than
necessary. Still an improvement.
2017-10-30 15:32:24 +01:00
wm4 bfa9b62858 build: add preliminary LGPL mode
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.
2017-09-21 13:56:27 +02:00
wm4 4a084c0df8 m_option: deprecate multiple items for -add etc.
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.
2017-07-02 16:47:27 +02:00
wm4 e4bc563fd2 options: change everything again
Fucking bullshit.
2017-07-02 16:29:45 +02:00
wm4 d24f4587a7 m_option: remove unused error code
The situation in the str_list_* functions can never happen, and they
were the only users of this error code.
2017-07-02 13:52:36 +02:00
wm4 3d31807198 m_option: remove redundant indirections
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.
2017-07-02 13:07:36 +02:00
wm4 91583fccac options: change path list options, and document list options
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.
2017-06-30 16:39:36 +02:00
wm4 45bd739796 options: sort action list alphabetically
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).
2017-06-27 11:27:19 +02:00
wm4 1328005937 options: expose string list actions for --sub-file option
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.)
2017-06-27 11:25:02 +02:00
wm4 50008adf4a options: handle suffixes like -add in a more generic way
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.
2017-06-26 21:07:00 +02:00
wm4 933db1b95f Revert "parse_commandline: fail gracefully on bad args"
This reverts commit 38b05daf7d.

There was actually no LGPL relicensing agreement with wd0.
2017-06-24 11:32:40 +02:00
wm4 0729bee415 options: simplify and rename m_option_type_store
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.
2017-06-23 20:51:12 +02:00
wm4 48970cd485 options: unbreak -h
Sure is a simple thing to break.
2017-06-23 20:23:51 +02:00
wm4 f001b47cb8 Revert "m_option: make geometry code GPL-only"
This reverts commit e30fe38a21.

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.)
2017-06-22 17:49:17 +02:00
wm4 e30fe38a21 m_option: make geometry code GPL-only
In commit eb22569ff0, 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
2017-06-21 18:13:53 +02:00
wm4 32833fa3d1 img_format: minor simplification 2017-06-18 13:58:42 +02:00
wm4 eb22569ff0 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 2c82d5a1d8
(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 1d0ac71ae8),
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 20:55:17 +02:00
wm4 26a173f40c m_option: revert commit 2793a70e0f 2017-06-12 20:13:18 +02:00
wm4 79dc1834f5 m_option: fix leaks with OPT_KEYVALUELIST options
For example, specifying --script-opts multiple times could leak some
data.
2017-06-08 21:51:25 +02:00
wm4 31611fc46b video: support positional arguments for automatic lavfi option bridge
Now e.g. --vf=pad=1000:1000 works.

All in all pretty ugly and hacky. Just look away.
2017-04-03 18:12:42 +02:00
wm4 a94013f585 command: change and simplify filter toggle syntax
"@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.
2017-03-26 13:13:34 +02:00
wm4 b0086d6243 m_option: consistent af/vf filter entry "enabled" flag default value
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.
2017-03-25 18:13:04 +01:00
wm4 7d424b4ce4 command: add better runtime filter toggling method
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.
2017-03-25 17:07:40 +01:00
wm4 0aa01ca743 m_option: optionally allow passing "no" to imgfmt option types
Needed for the following commit.

Also, fix that uint32_t type - we always assumed int.
2017-03-02 11:32:07 +01:00
wm4 4958c1a556 options: some simplifications
Remove more stuff that was needed only for legacy suboptions.

One user-visible change is that parent-options like --tv are now not
visible anymore. They lead to a special error message when used before,
but now they're simply not part of the option list anymore.
2016-11-29 17:10:06 +01:00
wm4 1a2319f3e4 options: remove deprecated sub-option handling for --vo and --ao
Long planned. Leads to some sanity.

There still are some rather gross things. Especially g_groups is ugly,
and a hack that can hopefully be removed. (There is a plan for it, but
whether it's implemented depends on how much energy is left.)
2016-11-25 21:17:25 +01:00
wm4 dc48893630 options: simplify M_OPT_EXIT
There were multiple values under M_OPT_EXIT (M_OPT_EXIT-n for n>=0).
Somehow M_OPT_EXIT-n either meant error code n (with n==0 no error?), or
the number of option valus consumed (0 or 1). The latter is MPlayer
legacy, which left it to the option type parsers to determine whether an
option took a value or not. All of this was changed in mpv, by requiring
the user to use explicit syntax ("--opt=val" instead of "-opt val").

In any case, the n value wasn't even used (anymore), so rip this all
out. Now M_OPT_EXIT-1 doesn't mean anything, and could be used by a new
error code.
2016-09-17 18:07:40 +02:00
wm4 fc1c004cd8 options: fix --list-options after previous commit
Fixes #3509.
2016-09-10 20:49:10 +02:00
wm4 484328fe04 options: make --h list options according to a pattern passed to it
Useless feature, but I want it.

Won't work on Windows due to missing fnmatch().
2016-09-10 16:29:24 +02:00
wm4 849480d0c9 vo_opengl: deprecate sub-options, add them as global options
vo_opengl sub-option were always rather annoying to handle. It seems
better to make them global options instead. This is simpler and easier
to use. The only disadvantage we are aware of is that it's not clear
that many/all of these new global options work with vo_opengl only.

--vo=opengl-hq is also deprecated.

There is extensive compatibility with the old behavior. One exception is
that --vo-defaults will not apply to opengl-hq (though with opengl it
still works). vo-cmdline is also dysfunctional and will be removed in a
following commit.

These changes also affect opengl-cb.

The update mechanism is still rather inefficient: it requires syncing
with the VO after each option change, rather than batching updates.
There's also no granularity (video.c just updates "everything", and if
auto-ICC profiles are enabled, vo_opengl.c will fetch them on each
update).

Most of the manpage changes were done by Niklas Haas <git@haasn.xyz>.
2016-09-02 21:21:47 +02:00
wm4 6b4f560f3c vo, ao: disable positional parameter suboptions
Positional parameters cause problems because they can be ambiguous with
flag options. If a flag option is removed or turned into a non-flag
option, it'll usually be interpreted as value for the first sub-option
(as positional parameter), resulting in very confusing error messages.
This changes it into a simple "option not found" error.

I don't expect that anyone really used positional parameters with --vo
or --ao. Although the docs for --ao=pulse seem to encourage positional
parameters for the host/sink options, which means it could possibly
annoy some PulseAudio users.

--vf and --af are still mostly used with positional parameters, so this
must be a configurable option in the option parser.
2016-09-01 14:21:32 +02:00
wm4 c55d859920 m_option: replace --no-video-aspect alias
Instead, add a hacky OPT_ASPECT option type, which only exists to accept
a "no" parameter, which in combination with the "--no-..." handling code
makes --no-video-aspect work again.

We can also remove the code in m_config.c, which only existed to make
"--no-aspect" (a deprecated alias) to work.
2016-08-31 22:17:21 +02:00
wm4 ce8dae3f0d m_property: remove pointless explicitly clamping
This is basically dead code, and even the commit that added this code 4
years ago said that this should be for debugging only.

(Though it is possible that the clamp callback was used for something
else, and then unused again. Also, some of the clamping code remains and
is used for internal checking, e.g. clamp_double().)
2016-08-31 15:31:51 +02:00
wm4 3bb134969e m_option: remove M_OPT_TYPE_DYNAMIC flag
It's actually redundant with whether m_option_type.free is set. Some
option types were flagged inconsistently. Its only use was for running
an additional sanity check without any real functionality.
2016-08-30 23:45:58 +02:00
wm4 07f8b64754 m_option: add mechanism to allow inf/-inf float options
Used by the next commit.
2016-08-17 21:48:56 +02:00
wm4 3a7e86ff6e m_option: simplify float value range handling
Use clamp_double() to handle all value restriction/verification. The
error messages become a bit less nice, but they were kind of incomplete
before.
2016-08-17 21:44:05 +02:00
wm4 eccabeb81c options: fix channels options copy/free operations
For some fucked up reason the arguments can be NULL. Makes no sense to
me, but ok.
2016-08-05 12:23:15 +02:00
wm4 0b144eac39 audio: use --audio-channels=auto behavior, except on ALSA
This commit adds an --audio-channel=auto-safe mode, and makes it the
default. This mode behaves like "auto" with most AOs, except with
ao_alsa. The intention is to allow multichannel output by default on
sane APIs. ALSA is not sane as in it's so low level that it will e.g.
configure any layout over HDMI, even if the connected A/V receiver does
not support it. The HDMI fuckup is of course not ALSA's fault, but other
audio APIs normally isolate applications from dealing with this and
require the user to globally configure the correct output layout.

This will help with other AOs too. ao_lavc (encoding) is changed to the
new semantics as well, because it used to force stereo (perhaps because
encoding mode is supposed to produce safe files for crap devices?).
Exclusive mode output on Windows might need to be adjusted accordingly,
as it grants the same kind of low level access as ALSA (requires more
research).

In addition to the things mentioned above, the --audio-channels option
is extended to accept a set of channel layouts. This is supposed to be
the correct way to configure mpv ALSA multichannel output. You need to
put a list of channel layouts that your A/V receiver supports.
2016-08-04 20:49:20 +02:00
maniak1349 c4e8c36071 options: --geometry: center window position after applying size
Center window position after applying W and H parameters of the --geometry
option. Passing valid X and Y values will still override the position.

Fixes #2397.
2016-05-22 14:31:37 +02:00
wm4 b2646911a9 client API: access choices as flags if appropriate
Options/properties that are choices, and which include "yes" or "no"
values (or both) can now be read and written as MPV_FORMAT_FLAG.

For write access, rejecting flags in these cases was obnoxiously
unintuitive and inconvenient.

For read access, the value of this is less convincing, and actually it's
a major API change. At this point I probably have to admit that the
finer details of the client API are very unstable.
2016-05-04 17:37:54 +02:00
wm4 a9bd4535d2 client API: improve mpv_set_property() handling of MPV_FORMAT_NODE
If a mpv_node wrapped a string, the behavior was different from calling
mpv_set_property() with MPV_FORMAT_STRING directly. Change this.

The original intention was to be strict about types if MPV_FORMAT_NODE
is used. But I think the result was less than ideal, and the same change
towards less strict behavior was made to mpv_set_option() ages ago.
2016-04-15 11:32:40 +02:00
wm4 0467f5287d m_option: slightly improve --msg-level=help output
In particular get rid of the semi-deprecated ":" separator.
2016-04-13 22:25:51 +02:00
wm4 9a4120f21f m_option: add string conversion for --audio-channels
Requested in #3040.
2016-04-13 22:22:53 +02:00
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4 89f05dc7d1 options: fix conversion of flags to strings
This flags stuff tried to be too clever - if there are overlapping flags
(e.g. exclusive or combined flags), the one matching with most bits has
to be chosen.

This fixes logging of the seek command. E.g. "relative" and "absolute"
overlap to make them exclusive, but "relative" was always printed as it
happened to match first.
2015-07-01 23:05:11 +02:00
wm4 85b7cbec70 options: improve an error message
"mpv --ao=wasapi:help" on Linux gave "Option ao doesn't exist.".
Completely misleading and stupid.
2015-06-27 21:26:05 +02:00
wm4 d6737c5fab audio: replace format name table
Having a big switch() is simpler.
2015-06-26 23:06:21 +02:00
wm4 a3d561f950 options: make keyvalue list parsing less strict
Affects for example --script-opts. A bunch of characters are now allowed
in them without causing trouble to the user.
2015-06-10 23:06:07 +02:00
wm4 8e0cf9d878 options: change [...] to balanced quotes
Useful for dealing with libavfilter's terrible graph syntax.

Not strictly backwards compatible (for example "[a[b]" fails now - the
"[" within the quote is interpreted now). But hopefully it's obscure
enough not to warrant any kind of compatibility hacks.
2015-04-19 15:31:17 +02:00
wm4 9e0cd3b3e7 options: don't let --vf-clr etc. take an argument
It was ignored before. Passing an argument makes no sense, and might be
mistaken for some form of --vf-del, so complain about it.

This also affects --af-clr and the vf/af commands.
2015-04-13 20:30:17 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4 5a2825ec35 video: cleanup stereo mode parsing
Use OPT_CHOICE_C() instead of the custom parser. The functionality is
pretty much equivalent.

(On a side note, it seems --video-stereo-mode can't be removed, because
it controls whether to "reduce" stereo video to mono, which is also the
default. In fact I'm not sure how this should be handled at all.)
2015-04-02 23:54:08 +02:00
wm4 9e98702493 options: fix --geometry to string conversion
Fixes #1744.
2015-04-01 22:32:34 +02:00
wm4 27715b7dd1 video: move colorspace overrides to vf_format, simplify
Remove the colorspace-related top-level options, add them to vf_format.
They are rather obscure and not needed often, so it's better to get them
out of the way. In particular, this gets rid of the semi-complicated
logic in command.c (most of which was needed for OSD display and the
direct feedback from the VO). It removes the duplicated color-related
name mappings.

This removes the ability to write the colormatrix and related
properties. Since filters can be changed at runtime, there's no loss of
functionality, except that you can't cycle automatically through the
color constants anymore (but who needs to do this).

This also changes the type of the mp_csp_names and related variables, so
they can directly be used with OPT_CHOICE. This probably ended up a bit
awkward, for the sake of not adding a new option type which would have
used the previous format.
2015-03-31 00:09:03 +02:00
wd0 38b05daf7d parse_commandline: fail gracefully on bad args
Args of zero length (i.e. --=) now display a proper error message.

Signed-off-by: wm4 <wm4@nowhere>
2015-03-29 13:44:34 +02:00
wm4 81a63545a0 options: add conversion to string for geometry option types
Pretty messy, which is why it wasn't done at first. (Also, I'd really
like to have simpler syntax and semantics for this damn option, but who
knows when this will happen.)

Fixes #1705.
2015-03-24 21:50:35 +01:00
wm4 68b71346ec m_option: remove dead initialization 2015-03-23 18:17:38 +01:00
wm4 f447179c59 options: add flag option type 2015-03-04 17:28:42 +01:00
wm4 1eb533afb3 options: handle choice -> flag fallback automatically
In the past it happened quite often that flag options (yes/no) were
changed to choice options (yes/no/some more). The problem with this was
that while flag options don't need a parameter, this wasn't the case
with choice options. A hack was introduced to compensate for this:
setting M_OPT_OPTIONAL_PARAM on the option, and an empty string ("") was
added as choice, so that the choice could be used like a flag. So, for
example, "--mute" would set the choice "".

Fix this by 1. not requiring a parameter if there's a "yes" choice, and
2. redirect an empty parameter to "yes". The effect is that a choice
option with the choices ["yes", "no"] is pretty much equivalent to a
flag option.
2015-02-27 18:31:24 +01:00
wm4 b143102f6d options: minor simplification in flag option parser 2015-02-27 18:17:46 +01:00
wm4 ffe894ec0a options: change --msg-level option
Make it accept "," as separator, instead of only ":". Do this by using
the key-value-list parser. Before this, the option was stored as a
string, with the option parser verifying that the option value as
correct. Now it's stored pre-parsed, although the log levels still
require separate verification and parsing-on-use to some degree (which
is why the msg-level option type doesn't go away).

Because the internal type changes, the client API "native" type also
changes. This could be prevented with some more effort, but I don't
think it's worth it - if MPV_FORMAT_STRING is used, it still works the
same, just with a different separator on read accesses.
2015-02-06 16:48:52 +01:00
wm4 1a38741dce options: allow ":" as separator in key-value lists
Before this, unquoted occurrences of ":" lead to parsing errors. There's
no reason to reject it, especially since the traditional MPlayer syntax
uses ":" as separator. (Which is also the reason why ":" was rejected
before: the parser shares this code for handling splitting/quoting, and
we merely checked explicitly whether the option was split on ",".)
2015-02-06 15:42:12 +01:00
wm4 9248f75853 options: allow things like --geometry=x50
Although the use is somewhat questionable, it seems strange that e.g.
--geometry=50% works (and sets the width only), but setting the height
only in a similar manner does not work.
2015-02-04 23:15:14 +01:00
wm4 cf8fa2bdd4 options: slightly improve help output for choice and flag options 2015-02-02 18:07:37 +01:00
wm4 2768ded1b9 options: fix parsing for --ab-loop-*
Editing mistake. Oops.
2014-12-12 23:22:50 +01:00
wm4 d054289f66 options: add slightly more sophistcated mechanism for option deprecation 2014-12-11 01:04:15 +01:00
wm4 d1aabb6316 m_option: never return NOPTS value as number from properties
MP_NOPTS_VALUE (basically INT64_MIN) is basically an special timestamp
value that means "unset" or "unknown". Its exact value is internal, and
should never be returned or interpreted by any API.

So return "no" instead (what is also what the parser accepts).
2014-12-10 17:15:43 +01:00
wm4 52c51149db options: fix channel map options sometimes failing
Channel amp otpions were not copied correctly: it copied the size of a
pointer to struct chmap, not the struct itself. Since mp_chmap is
currently 9 bytes, this meant the last channel entry was not copied
correctly on 64 bit systems, leading to very strange failures. It could
be triggered especially when using the client API, because the client
API always copies options on access (mpv command line options tend to
work directly on options).
2014-12-01 16:09:25 +01:00
wm4 62998e9709 options: fix swapped deprecated/replacement in warning
This was relevant for --af and --vo (both use this option type, and have
deprecated aliases).
2014-12-01 15:30:24 +01:00
wm4 8c2b78ea5a options: simplify channel map validation
The min=-1 case was never used, and the channel map must always be valid
(or in some cases, invalid but empty).
2014-12-01 15:29:02 +01:00
wm4 e082c2c3df Remove some unneeded NULL checks
Found by Coverity; also see commit 85fb2af3.
2014-11-21 09:58:09 +01:00