Commit Graph

41 Commits

Author SHA1 Message Date
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
wm4 51503a0577 options: rename -ss and -endpos, allow relative times
Rename the -ss option to -start, and -endpos to -length. Add a -end
option. The -end option always specifies an absolute end time, as
opposed to -endpos/-length.

All these options (--start, --end, --length) now accept relative times.
Percent positions (e.g. "--start=30%") are interpreted as fractions of
the file duration. Negative times (e.g. "--start=-1:00) are interpreted
relative to the end of the file. Chapters (e.g. "--start=#3") yield the
chapter's time position.

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.
2012-11-16 21:21:15 +01:00
wm4 4873b32c59 Rename directories, move files (step 2 of 2)
Finish renaming directories and moving files. Adjust all include
statements to make the previous commit compile.

The two commits are separate, because git is bad at tracking renames
and content changes at the same time.

Also take this as an opportunity to remove the separation between
"common" and "mplayer" sources in the Makefile. ("common" used to be
shared between mplayer and mencoder.)
2012-11-12 20:08:18 +01:00
wm4 d4bdd0473d Rename directories, move files (step 1 of 2) (does not compile)
Tis drops the silly lib prefixes, and attempts to organize the tree in
a more logical way. Make the top-level directory less cluttered as
well.

Renames the following directories:
    libaf -> audio/filter
    libao2 -> audio/out
    libvo -> video/out
    libmpdemux -> demux

Split libmpcodecs:
    vf* -> video/filter
    vd*, dec_video.* -> video/decode
    mp_image*, img_format*, ... -> video/
    ad*, dec_audio.* -> audio/decode

libaf/format.* is moved to audio/ - this is similar to how mp_image.*
is located in video/.

Move most top-level .c/.h files to core. (talloc.c/.h is left on top-
level, because it's external.) Park some of the more annoying files
in compat/. Some of these are relicts from the time mplayer used
ffmpeg internals.

sub/ is not split, because it's too much of a mess (subtitle code is
mixed with OSD display and rendering).

Maybe the organization of core is not ideal: it mixes playback core
(like mplayer.c) and utility helpers (like bstr.c/h). Should the need
arise, the playback core will be moved somewhere else, while core
contains all helper and common code.
2012-11-12 20:06:14 +01:00