Commit Graph

53 Commits

Author SHA1 Message Date
wm4 bd0454c31d m_option.c: fix typo in message 2013-08-02 17:06:49 +02:00
wm4 f8589c9889 Remove m_struct
Not needed anymore.
2013-08-02 17:03:13 +02:00
wm4 bc1d61cf42 stream: redo URL parsing, replace m_struct usage with m_config
Move the URL parsing code from m_option.c to stream.c, and simplify it
dramatically. This code originates from times when http code used this,
but now it's just relict from other stream implementations reusing this
code. Remove the unused bits and simplify the rest.

stream_vcd is insane, and the priv struct is different on every
platform, so drop the URL parsing. This means you can't specify a track
anymore, only the device. (Does anyone use stream_vcd? Not like this
couldn't be fixed, but it doesn't seem worth the effort, especially
because it'd require potentially touching platform specific code.)
2013-08-02 17:02:34 +02:00
wm4 d1de1e090f options: handle presets directly in m_config
This means that "mpv -vo opengl-hq:help" will actually show the correct
defaults, instead those of plain vo_opengl.
2013-07-31 20:56:00 +02:00
wm4 d6592dd2e2 m_option: fix skipping of missing -vo/-ao entries
The -vo/-ao options support skipping of unknown entries for the sake of
allowing using the same config on possibly very different systems, which
have different sets of VO/AOs available.

Unfortunately skipping didn't quite work, possibly a rebase error when
this was originally committed. Fix it.
2013-07-31 20:55:59 +02:00
wm4 78ebb3c6fa options: make legacy hacks for AFs/VFs more explicit
This means that AOs/VOs with no options set do not take the legacy
option parsing path, but instead report that they have no options.
2013-07-22 23:07:23 +02:00
wm4 3cdf4cf14d options: hide encoding AO/VO in help output
These can't be used manually. Encoding is enabled with -o instead, and
the encoding AO/VO is selected using internal mechanisms.
2013-07-21 23:27:31 +02:00
wm4 999dad454f options: add some features to video filter parser
This is in preparation of making VOs and AOs use the parser which
originally was for video filters only.

The --vo and --ao options have several very annoying features, which are
added here:
- They can skip unknown video outputs (might be useful if a config file
  is supposed to work on several systems, where not all VOs/AOs are
  available everywhere)
- The trailing "," in "-vo a,b," was significant, and meant that if "a"
  and "b" don't work, try the normal autoprobe order as fallback
- There were deprecated VO names (like "gl3" and "gl"), which have to be
  handled with the option parser
- Separating VO/VF names and options is different
  ("-vf foo=opts" vs. "-vo foo:opts")
- vo_opengl.c provides opengl-hq as opengl + preset options
2013-07-21 23:27:31 +02:00
wm4 f2e3a49810 m_option: fix memory leak on error path 2013-07-21 23:27:31 +02:00
wm4 560738ddef m_config: improve option list output a bit
This is printed with --list-options or e.g. --vf=lavfi=help.

Note that in theory, the options should be able to print their own help,
and we shouldn't special case certain types (like m_option_type_choice
in the commit). But that is too hairy for now, so we don't do it.
2013-07-21 23:27:31 +02:00
wm4 6629a95b92 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 23:27:31 +02:00
wm4 854303ad49 Remove internal network support
This commit removes the "old" networking code in favor of libavformat's
code.

The code was still used for mp_http, udp, ftp, cddb. http has been
mapped to libavformat's http support since approximately 6 months ago.
udp and ftp have support in ffmpeg (though ftp was added only last
month). cddb support is removed with this commit - it's probably not
important and rarely used if at all, so we don't care about it.
2013-07-07 19:42:38 +02:00
wm4 6fc91b44cd m_option: allow setting empty lists
There's no reason why this should be forbidden.
2013-06-07 17:05:07 +02:00
wm4 07fc939544 m_option: fix -vo opengl lscale validation
OPT_STRING_VALIDATE actually did nothing. This made -vo opengl crash or
misbehave when passing an invalid value for the lscale, cscale or 3dlut-
size (the only users for this option type).

The code added with this commit was either blatantly forgotten with the
commit introducing this option type, or somehow lost.
2013-06-03 00:00:11 +02:00
wm4 862989c011 m_option: allow removing filter entries by content with -vf-del
If a complete filter description is passed to -vf-del, search for an
existing filter with the same label or the same name/arguments, and
delete it. The rules for filter entry equality are the same as with
the -vf-toggle option.

E.g.

-vf-add gradfun=123:gradfun=456
-vf-del gradfun=456

does what you would expect.
2013-05-23 01:02:24 +02:00
wm4 f9f40a417f m_option: move code around
Move the helper functions for parsing -vf, and rename some.
2013-05-23 01:02:24 +02:00
wm4 3d87ca6b5e m_option, vf: add label support
Can be used to refer to filters by name. Intended to be used when the
filter chain is changed at runtime.

A label can be assigned to a filter by prefixing it with '@name:', where
'name' is an user-chosen identifier. For example, a filter added with
'-vf-add @label1:gradfun=123' can be removed with '-vf-del @label1'.
If a filter with an already existing label is added, the existing filter
is replaced with the new filter (this happens for both -vf-add and
-vf-pre). If a filter is replaced, the new filter takes the position of
the old filter, instead of being appended/prepended to the filter chain
as usual. For -vf-toggle, labels are compared if at least one of the
filters has a label; otherwise they are compared by filter name and
arguments (like before). This means two filters are never considered
equal if one has a label and the other one does not.
2013-05-23 01:02:24 +02:00
wm4 1ced961b92 m_option: fix parameter comparison for vf-toggle
The vf-toggle option parsing (normally used for runtime video filter
switching only) was missing comparing the parameter values. Fix this,
and also make the code a bit more robust.
2013-05-21 00:12:13 +02:00
wm4 d356f3efd2 m_option: fix -vf-del in profiles
We don't bother with option verification (as it happens in profiles),
because it's barely possible.
2013-05-21 00:04:46 +02:00
wm4 ad8aae1708 Fix commit d1b37af
Yeah, it doesn't work this way... Please look away.
2013-05-18 17:52:17 +02:00
wm4 d1b37aff32 m_option: allow -vf ""
With the current semantics, there's no reason to disallow this.

(Although in my opinion, -vf should rather map to -vf-add than -vf-set,
however that is an independent issue from this change.)
2013-05-18 17:45:54 +02:00
wm4 6b42881791 m_option: add -vf-toggle
Works like -vf-add, except if a filter already exists and has the same
parameters, it's removed instead of added.

Not really useful on the command line itself, but will make sense for
runtime filter changing in the following commit.
2013-05-18 17:32:37 +02:00
wm4 1dad548640 m_option: allow using -vf-del with a name
Until now, -vf-del required a list of indexes. This was a bit
inconvenient, so add support for using filter names too. Also simplify
the code a bit, doing the change would have been too painful otherwise.
2013-05-18 17:32:37 +02:00
wm4 759b3bdc47 options: use case-sensitive comparsion for options
This is better for consistency, and also allows using -V as alias
for --version.
2013-05-15 15:30:06 +02:00
Rudolf Polzer 3edb563b23 m_option: fix segfault in parse_chmap 2013-05-14 14:45:06 +02:00
wm4 e6e5a7b221 Merge branch 'audio_changes'
Conflicts:
	audio/out/ao_lavc.c
2013-05-12 21:47:55 +02:00
wm4 0042735d7a audio: add channel map API
Unused, will be used in the following commits.

Let chmap.h define the number of maximum channels, because that is most
convenient.
2013-05-12 21:24:54 +02:00
wm4 28a971e26f options: allow using [ ] for quoting in sub-options
This is an attempt to make quoting of sub-option values less awkward,
even if it works only with some shells. This is needed mainly for
vf_lavfi. Also update the vf_lavfi manpage section.
2013-04-26 20:44:18 +02:00
wm4 50ce2bd6c8 m_option: fix positional sub-option skipping
Empty sub-option parameters mean the sub-option should be skipped,
e.g. -vf gradfun=:10 sets the second option (by position) to 10. This
was broken in commit 04f1e2d.
2013-04-23 14:21:08 +02:00
wm4 c8df1799d9 m_option: allow quoted positional parameters for -vf
This allows things like:

    '--vf=lavfi="gradfun=20:30"'

Adjust the documentation for vf_lavfi to make the example less verbose.
As an unrelated change, add a general description to vf_lavfi.
2013-04-23 14:10:43 +02:00
wm4 04f1e2dc43 m_option: redo code for parsing -vf to accept quotes
Parsing sub-configs (like --rawvideo=subopts or the suboptions for
--vo=opengl:subopts) was completely different from the -vf parsing code
for a variety of reasons. This change at least makes -vf use the same
splitter code as sub-config options.

The main improvement is that -vf now accepts quotes, so you can write
things like:

     -vf 'lavfi=graph="gradfun=10:20"'

(The '' quotes are for shell escaping.)

This is a rather big and intrusive change. Trying some -vf lines from
etc/encoding-example-profiles.conf seems to confirm it still works.

This also attempts to unify one subtle difference in handling of
positional arguments. One consequence is that a minor detail changes.
Sub-configs don't know positional arguments, and something like "--
opt=sub1=val1:sub2" means that sub2 has to be a flag option. In -vf
parsing, sub2 would be a positional option value. To remove this
conflict and to facilitate actual unification of the parsers in the
future, the sub2 will be considered a flag option if and only if such a
flag option exists. Otherwise, it's considered a value for a positional
option.

E.g. if there's a filter "foo" with a string option "sopt" and a flag
option "fopt", the behavior of the following changes:

   -vf foo=fopt

Before this commit, this would set "sopt=fopt" in the filter. Now, it
enables the fopt flag, and the sopt option remains unset. This is not an
actual problem to my knowledge.
2013-04-21 04:39:57 +02:00
wm4 9fd2e449de m_option: add function to check whether parameters are required
To avoid that it will be duplicated with m_option.c and m_config.c.
2013-04-21 03:48:30 +02:00
wm4 c6037982fd options: untangle track range parsing for stream_cdda
Remove the "object settings" based track range parsing (needed by
stream_cdda only), and make stream_cdda use CONF_TYPE_INT_PAIR.

This makes the -vf parsing code completely independent from other
options. A bit of that code was used by the mechanism removed with
this commit.
2013-04-21 03:48:30 +02:00
wm4 6526162bc0 m_option: split out sub-config parsing 2013-04-21 03:48:30 +02:00
wm4 2182c3ffd5 m_option: pretty-print floats with 3 pre-decimal digits instead of 2
There were complaints that ${fps} was printed as e.g. "23.98" instead of
"23.976". Since there's no way to format floats exactly _and_ in a user-
friendly way, just change the default precision for printing floats.
2013-03-26 01:29:54 +01:00
wm4 9180263c4d m_options: more typesafety
Change the option definition macros so that they cause compiler warnings
if the type of the referenced option struct member doesn't match the
type implied by the macro. The compiler warning printed isn't very
telling, but it's better than silently invoking undefined behavior by
violating the C strict aliasing rules.

Also fix some minor cases that violate the type rules. For the option
"no-aspect" we have to add a new option type to handle it properly.

Some option types are hard to check, so we don't in these cases.
2013-03-01 11:21:13 +01:00
wm4 7af2bc6607 options: reject nan, inf, 0:0, etc. for float options
Same for time values.
2013-02-26 01:55:52 +01:00
wm4 bbea6cc6d4 options: remove parsing of "," as decimal point
Apparently the intention was parsing numbers reliably in presence of
non-C locales. mpv is always in C locale, and not being in C locale
would probably break even more things, so remove this code.
2013-02-26 01:55:52 +01:00
wm4 5374e26f9e m_option: remove preset mechanism
Was very complicated to use, and its uses have been removed in the
previous commits.

(While this feature sounded kind of useful, it could be rewritten in
a much simpler way, like storing presets as strings, and then using
the option parser to apply a preset. The removed code did some major
pointer juggling to handle raw values, which made it hard to use.)
2013-02-23 00:10:23 +01:00
wm4 0bad744d68 options: parse C-style escapes for some options
Being able to insert newline characters ("\n") is useful for
--osd-status-msg, and possibly also for anything that prints to the
terminal. Espcially --term-osd-esc looks relatively useless without
being able to specify escapes.

Maybe parsing escapes should happen during command line / config parsing
instead (for all options).
2013-02-20 23:45:56 +01:00
wm4 267a889cc2 options: unify single dash and double dash options
There were two option syntax variations:

    "old":  -opt value
    "new": --opt=value

"-opt=value" was invalid, and "--opt value" meant "--opt=" followed by
a separate option "value" (i.e. interpreted as filename). There isn't
really any reason to do this. The "old" syntax used to be ambiguous
(you had to call the option parser to know whether the following
argument is an option value or a new option), but that has been removed.
Further, using "=" in the option string is always unambiguous.

Since the distinction between the two option variants is confusing,
just remove the difference and allow "--opt value" and "-opt=value".

To make this easier, do some other cleanups as well (e.g. avoid having
to do a manual lookup of the option just to check for M_OPT_PRE_PARSE,
which somehow ended up with finally getting rid of the m_config.mode
member).

Error reporting is still a mess, and we opt for reporting too many
rather than too few errors to the user.

There shouldn't be many user-visible changes. The --framedrop and
--term-osd options now always require parameters.

The --mute option is intentionally made ambiguous: it works like a flag
option, but a value can be passed to it explicitly ("--mute=auto"). If
the interpretation of the option is ambiguous (like "--mute auto"), the
second string is interpreted as separate option or filename. (Normal
flag options are actually ambiguous in this way too.)
2013-02-09 00:21:17 +01:00
wm4 830560979c options: change handling of "no-" options
Normally, all flag options can be negated by prepending a "no-", for
example "--no-opt" becomes "--opt=no". Some flag options can't actually
be negated, so add a CONF_TYPE_STORE option type to disallow the "no-"
fallback.

Do the same for choice options. Remove the explicit "no-" prefixed
options, add "no" as choice.

Move the handling of automatic "no-" options from parser-mpcmd.c to
m_config.c, and use it in m_config_set_option/m_config_parse_option.
This makes these options available in the config file. It also
simplifies sub-option parsing, because it doesn't need to handle "no-"
anymore.
2013-02-09 00:21:16 +01:00
wm4 7885fce7ea video: add --autofit and --autofit-larger options
--autofit=WxH sets the window size to a maximum width and/or height,
without changing the window's aspect ratio.

--autofit-larger=WxH does the same, but only if the video size is
actually larger than the window size that would result when using
the --autofit=WxH option with the same arguments.
2013-01-23 10:56:36 +01:00
wm4 ccaed5eb07 options: allow using % for width and height in --geometry
Now all numbers in the --geometry specification can take percentages.

Rewrite the parsing of --geometry, because adjusting the sscanf() mess
would require adding all the combinations of using and not using %. As
a side effect, using % and pixel values can be freely mixed.

Keep the aspect if only one of width or height is set. This is more
useful in general.

Note: there is one semantic change: --geometry=num used to mean setting
the window X position, but now it means setting the window width.
Apparently this was a mplayer-specific feature (not part of standard X
geometry specifications), and it doesn't look like an overly useful
feature, so we are fine with breaking it.

In general, the new parsing should still adhere to standard X geometry
specification (as used by XParseGeometry()).
2013-01-23 10:56:27 +01:00
wm4 4c56baba40 options: move -geometry parsing to m_option.c
This also means the option is verified on program start, not when the VO
is created. The actual code becomes a bit more complex, because the
screen width/height is not available at program start.

The actual parsing code is still the same, with its unusual sscanf()
usage.
2013-01-23 10:56:11 +01:00
wm4 8751a0e261 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.
2013-01-13 20:04:11 +01:00
wm4 967e1e8290 m_option: print valid integer range for choices on parsing errors
Only some choices have an additional integer range. For those which
do, printing the choices only would be confusing.

E.g. --cursor-autohide accepts the choices "always", "no", or an
integer value. The help text printed on option parse errors should
print the accepted integer range additional to "always" and "no".
2012-11-20 18:00:15 +01:00
wm4 d23b620a89 m_option: add color option type
This accepts HTML-style hex colors in the form #RRGGBB. It's also
possible to provide an alpha component with #AARRGGBB. Each 2-digit
group is a hex number, which gives the color value from 0-255 (e.g.

There is existing code in subassconvert.c, which parses HTML-style
color values in SRT subs. This is not used: it's probably better if
option parsing is completely separate from code specific to certain
subtitle formats, even if a little code is duplicated.
2012-11-20 18:00:15 +01:00
wm4 f5e2ee5138 options: support chapters for --start and --end
The --start and --end switch now accept a chapter number. The chapter
number is prefixed with '#', e.g. "--start=#2" jumps to chapter 2.

The chapter support might be able to replace --chapter completely, but
for now I am not sure how well this works out with e.g. DVDs and BDs,
and a separate --chapter option is useful interface-wise.

(This was supposed to be added in 51503a, but apparently the fixup
commit adding it was lost in a rebase. This might also be the reason
for the mess-up fixed in 394285.)
2012-11-20 18:00:11 +01:00
wm4 39428525c3 m_option: fix braindead --start, --length, --end option parsing bugs
The option type m_option_type_rel_time was completely broken. It
interpreted everything starting with a number as percent position. This
is because sscanf() semantics are idiotic (trailing string doesn't need
to be matched), and due to my own idiocy this was overlooked when
testing. Fix by considering sscanf() evil and not using it.
(bstr_sscanf() is a straight wrapper around sscanf()).

Even if the percent code was fixed, there was another bug: it always
interpreted times as negative (starting from end for --start). Fix the
basic logic.
2012-11-18 00:25:25 +01:00