Commit Graph

187 Commits

Author SHA1 Message Date
wm4 5d12a2696e command: export some option metadata
This might be interesting for GUIs and such.

It's probably still a little bit insufficient. For example, the filter
and audio/video output lists are not available through this.
2014-11-13 18:01:27 +01:00
wm4 4590ac2082 m_option: format mpv_node as json
Useful for debugging and informational purposes. Not sure if it's sane
in any form.
2014-10-23 15:13:05 +02:00
wm4 ff029cb4cf lua: strictly free memory on errors
Thanks to the recently introduced mp_lua_PITA(), this is "simple" now.
It fixes leaks on Lua errors. The hack to avoid stack overflows
manually isn't needed anymore, and the Lua error handler will take
care of this.
2014-10-19 05:51:37 +02:00
wm4 8599c959fe video: initial Matroska 3D support
This inserts an automatic conversion filter if a Matroska file is marked
as 3D (StereoMode element). The basic idea is similar to video rotation
and colorspace handling: the 3D mode is added as a property to the video
params. Depending on this property, a video filter can be inserted.

As of this commit, extending mp_image_params is actually completely
unnecessary - but the idea is that it will make it easier to integrate
with VOs supporting stereo 3D mogrification. Although vo_opengl does
support some stereo rendering, it didn't support the mode my sample file
used, so I'll leave that part for later.

Not that most mappings from Matroska mode to vf_stereo3d mode are
probably wrong, and some are missing.

Assuming that Matroska modes, and vf_stereo3d in modes, and out modes
are all the same might be an oversimplification - we'll see.

See issue #1045.
2014-08-30 23:24:46 +02:00
wm4 ff7a1c21ce options: more detailed output for --vf-... error message 2014-08-28 17:51:33 +02:00
wm4 9a6d7af074 options: fix key-value-list options
The parser can be called with dst (the target) set to NULL if the option
should be verified only. The code didn't respect this, and could result
in crashes when used in config profiles or filter sub-options.

Fixes #981.
2014-08-05 02:24:45 +02:00
wm4 9a210ca2d5 Audit and replace all ctype.h uses
Something like "char *s = ...; isdigit(s[0]);" triggers undefined
behavior, because char can be signed, and thus s[0] can be a negative
value. The is*() functions require unsigned char _or_ EOF. EOF is a
special value outside of unsigned char range, thus the argument to the
is*() functions can't be a char.

This undefined behavior can actually trigger crashes if the
implementation of these functions e.g. uses lookup tables, which are
then indexed with out-of-range values.

Replace all <ctype.h> uses with our own custom mp_is*() functions added
with misc/ctype.h. As a bonus, these functions are locale-independent.
(Although currently, we _require_ C locale for other reasons.)
2014-07-01 23:11:08 +02:00
Tsukasa OMOTO 1aef780b6c options: support setting start time relative to start PTS
Signed-off-by: wm4 <wm4@nowhere>
2014-06-29 20:39:49 +02:00
wm4 b7bedbbc36 options: remove some more stuff
The "classic" sub-option stuff is not really needed anymore. The only
remaining use can be emulated in a simpler way. But note that this
breaks the --screenshot option (instead of the "flat" options like
--screenshot-...). This was undocumented and discouraged, so it
shouldn't affect anyone.
2014-06-13 02:18:26 +02:00
wm4 6a4a5595d8 options: remove OPT_FLAG_CONSTANTS
This means use of the min/max fields can be dropped for the flag option
type, which makes some things slightly easier. I'm also not sure if the
client API handled the case of flag not being 0 or 1 correctly, and this
change gets rid of this concern.
2014-06-13 02:10:45 +02:00
wm4 924d4db0de options: change --sub-file behavior
--sub-file is actually a string list, so you can add multipel external
subtitle files. But to be able to set a list, the option value was split
on ",". This made it impossible to add filenames.

One possible solution would be adding escaping. That's probably a good
idea (and some other options already do this), but it's also complicated
both to implement and for the user.

The simpler solution is making --sub-file appending, and make it take
only a single entry.

I'm not quite sure about this yet. It breaks the invariant that if a
value is printed and parsed, you get the same value back. So for now,
just go with the simple solution.

Fixes #840.
2014-06-08 00:03:45 +02:00
wm4 2bc871b577 m_option: use isfinite() instead of isnormal()
This accidentally rejected d==0. We can actually deal with sub-normals
fine, we just want to exclude nan and infinity (although infinity is
already accounted for, but anyway).
2014-06-01 17:23:56 +02:00
wm4 05bad1f57a command: allow native access to "vf" property
This allows client API users and Lua scripts to side-step the pretty
horrible video filter string "language" (although it's back and can't be
avoided when using libavfilter).
2014-04-24 02:30:00 +02:00
wm4 059d989bf6 options: don't allow --no-foo=yes
It's a bit strange to allow this, so get rid of it.

This probably breaks a bunch of user config files.

The client API still allows setting them with MPV_FORMAT_FLAG with a
value of 1 (i.e. true), but I guess this is tolerable.
2014-04-14 20:51:27 +02:00
wm4 186fd0311d video: change image format names, prefer mostly FFmpeg names
The most user visible change is that "420p" is now displayed as
"yuv420p". This is what FFmpeg uses (almost), and is also less confusing
since "420p" is often confused with "420 pixels vertical resolution".

In general, we return the FFmpeg pixel format name. We still use our own
old mechanism to keep a list of exceptions to provide compatibility for
a while.

Also, never return NULL for image format names. If the format is unset
(0/IMGFMT_NONE), return "none". If the format has no name (probably
never happens, FFmpeg seems to guarantee that a name is set), return
"unknown".
2014-04-14 20:51:27 +02:00
wm4 378a15564c m_option: fix handling of empty channel layouts
Even if a channel map option signaled that empty layouts are accepted,
the option parser never actually accepted them.
2014-03-10 01:48:18 +01:00
wm4 5eab4f43ec m_option: make converting mpv_node to string always fail 2014-02-26 22:30:18 +01:00
wm4 25f086973f m_option: fix key/value list string conversion
Meh.
2014-02-26 21:03:35 +01:00
wm4 8461143ed7 m_option: don't make "unset" string and string list return NULL strings
This is a bit weird: m_option_string types (i.e. char*) can be NULL. But
they're supposed to be treated just like empty strings. So don't make
the m_option_type.print function return NULL for these values. Returning
NULL would mean failure.

This didn't matter much before, but was quite visible through the client
API.
2014-02-26 21:03:35 +01:00
wm4 e94bab5a99 m_option: add a way to convert values to/from mpv_node
m_option is basically the mechanism to handle C data types in a dynamic
way. Add functions to convert values to and from mpv_node. For example,
string lists are turned into mpv_node using MPV_FORMAT_NODE_ARRAY, and
so on.
2014-02-24 22:50:23 +01:00
wm4 e3f7d4f5ea m_option: fix printf format specifier 2014-02-24 12:00:56 +01:00
wm4 c3c82f5c3b m_option: explicitly allow m_option.name==NULL
Doesn't require other code to care about this, which will allow us to
simplify the property code.

Only "wildcard" options like "vf" and string lists used this, and
m_option_list_findb() (which is excused).
2014-02-23 16:49:18 +01:00
wm4 98dc8206ae options: handle escape sequences in e.g. --playing-msg differently
M_OPT_PARSE_ESCAPES was pretty stupid, and broke the (useful) assumption
that string variables contain exactly the same value as set by the
option. Simplify it, and move escape handling to the place where it's
used.

Escape handling itself is not terribly useful, but still allows useful
things like multiline custom OSD with "\n".
2014-02-20 14:46:23 +01:00
wm4 36f6e6b826 options: alternative way to specify color options
Try to make it more intuitive by not requiring hex values. The new way
uses float values in the range 0.0-1.0, separated by '/' (':' was
suggested, but that wouldn't allow color options in sub-options).

Example: --osd-color=1.0/0.0/0.0/0.75

Using the range 0.0-1.0 has the advantage that it could be easily
extended to colors beyond 8 bit.

Details see manpage.

Suggestions for alternative syntax or value ranges are welcome, but be
quick with it.
2014-01-31 00:41:54 +01:00
wm4 82067e6ac3 options: add key/value pair list option type 2014-01-16 23:06:41 +01:00
wm4 99ee43b33b msg: move special declarations to msg_control.h
While almost everything uses msg.h, the moved definitions are rarely
needed by anything.
2014-01-16 23:06:40 +01:00
wm4 2214ee8472 options: make --msglevel=help print something helpful 2014-01-01 19:42:48 +01:00
wm4 066ecfcbfb common: simplify and optimize string escape parsing
This code is shared between input.conf parser and option parser. Until
now, the performance didn't really matter. But I want to use this code
for JSON parsing too, and since JSON will have to be parsed a lot, it
should probably try to avoid realloc'ing too much.

This commit moves parsing of C-style escaped strings into a common
function, and allows using it in a way realloc can be completely
avoided, if the already allocated buffer is large enough.
2013-12-30 22:49:50 +01:00
wm4 dacb6ad98f options: simplify handling of some help options 2013-12-26 19:25:51 +01:00
wm4 bd5e0a2ba2 options: make --msglevel extend previous settings
Make it so --msglevel extends previous --msglevel uses, instead of
overwriting them. Do this by literally appending the --msglevel option
value to the previous one.
2013-12-22 12:18:01 +01:00
wm4 7bdee8f35e m_option: add mp_log context to sub-module print_help callback 2013-12-21 21:43:16 +01:00
wm4 9242c34fa2 m_option: add mp_log callback to OPT_STRING_VALIDATE options
And also convert a bunch of other code, especially ao_wasapi and
ao_portaudio.
2013-12-21 21:43:16 +01:00
wm4 d8d42b44fc m_option, m_config: mp_msg conversions
Always pass around mp_log contexts in the option parser code. This of
course affects all users of this API as well.

In stream.c, pass a mp_null_log, because we can't do it properly yet.
This will be fixed later.
2013-12-21 21:05:02 +01:00
wm4 6a8fc3f5e3 msg: change --msglevel, reduce legacy glue
Basically, reimplement --msglevel. Instead of making the new msg code
use the legacy code, make the legacy code use the reimplemented
functionality.

The handling of the deprecated --identify switch changes. It temporarily
stops working; this will be fixed in later commits.

The actual sub-options syntax (like --msglevel-vo=...) goes away, but I
bet nobody knew about this or used this anyway.
2013-12-20 21:07:57 +01:00
wm4 80b34ebea4 m_option: don't include config.h in header
Requires a small workaround.
2013-12-18 17:12:27 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
Since m_option.h and options.h are extremely often included, a lot of
files have to be changed.

Moving path.c/h to options/ is a bit questionable, but since this is
mainly about access to config files (which are also handled in
options/), it's probably ok.
2013-12-17 02:07:57 +01:00