summaryrefslogtreecommitdiffstats
path: root/m_option.c
Commit message (Collapse)AuthorAgeFilesLines
* Rename directories, move files (step 1 of 2) (does not compile)wm42012-11-121-2117/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* m_option: minor simplificationwm42012-11-011-4/+2
| | | | Relict of mplayer's C89 compatibility?
* options: fix URL user/password parsingUoti Urpala2012-10-301-2/+2
| | | | | | | Code parsing the optional user/password part for some URL types given as files to play, such as "ftp://user:password@host/filename", was broken. Fix. I guess this isn't used much as nobody reported it earlier.
* commands: handle property clamping in m_optionwm42012-10-121-1/+98
| | | | | | | | | | | | | | | Instead of clamping property values to the valid range in each property implementation, handle it in the property layer. The functionality to handle clamping for each type is in m_option.c. It's not really clear whether this is really needed. Normally, the raw values for M_PROPERTY_SET come only from m_option_type.parse (setting properties as string) or from m_option_parse.add (using the "switch" input command). However, since this was already done before, and since we _really_ want to be sure only to write valid values, add this code anyway. The newly added warnings/error messages should never actually be printed during normal operation and are for debugging (if they happen, we definitely want to see them).
* options: accept "yes" and "no" only for flagswm42012-10-121-16/+8
| | | | | | | | | | This removes the alternative values like "off", "0", "false" etc., and also the non-English versions of these. This is done for general consistency. It's better to have a single way of doing things when multiple ways don't add singificant value. Also update some choices for consistency.
* commands: generally handle property formatting with m_optionwm42012-10-121-2/+18
| | | | | | | | | | | | | Use the m_option code by default to format property values, instead of having separate code in m_property. To facilitate that, add a pretty_print callback to option types. These format values in a more human readable and user friendly way, as opposed to the print callback, which produces parseable values. This also changes the strings used with flags. Instead of "enabled" and "disabled", flags are formatted as "yes" and "no". (We could use the pretty_print callback to deal with this, but we don't for consistency.)
* commands: handle property stepping in a generic waywm42012-10-121-2/+135
| | | | | | | | | | | | | | | | | | | | | Instead of forcing each property implementation implement its own logic for M_PROPERTY_STEP_UP/M_PROPERTY_STEP_DOWN, handle it in the generic property code. Rename the M_PROPERTY_STEP_UP command to M_PROPERTY_SWITCH (the other property command, M_PROPERTY_STEP_DOWN, isn't needed anymore: stepping downwards is done by passing a negative argument). Always use double as argument type; it makes the code easier, and covers all property types. Move the code which does the actual type-specific value stepping to m_option.c (the idea is that m_option handles types). Some properties still have custom handlers implemented with M_PROPERTY_SWITCH. They can't be mapped to the generic mechanism, because their value range is dynamic or entirely unknown. For some properties, the default step stride is changed to 1. This is no issue, because the default bindings in input.conf all use an explicit stride in the affected cases.
* options: remove CONF_TYPE_POSITIONwm42012-10-121-29/+0
| | | | | | | | | This was the option parser for the off_t C type. These days, off_t is always int64_t, so replace all its uses by int64_t and CONF_TYPE_INT64. Fix the --sstep option. It used CONF_TYPE_INT with an off_t variable, which will result in invalid memory accesses. Make it use type double instead, which seems to make more sense for this option.
* options: change --loop option, and extend choice option typewm42012-09-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | The --loop option takes slightly different parameters now. --loop=0 used to mean looping forever. Now it means looping is disabled (this is more logical: 2 means playing 2 more times, 1 means playing 1 more time, and 0 should mean playing not again). Now --loop=inf must be used to enable looping forever. Extend choice types to allow an optional range of integers as values. If CONF_RANGE is added to the flags of a m_option_type_choice option, m_option.min/max specify a range of allowed integer values. This can be used to remove "special" values from make integer range options. These special values are unintuitive, and sometimes expose mplayer internals to the user. The (internal) choice values can be freely mixed with the specified integer value range. If there are overlaps, the choice values are preferred for conversion to/from strings. Also make sure the extension to choice options works with properties. Add the ability to step choice properties downwards, instead of just upwards.
* options: remove M_OPT_IMPLICIT_DEFAULTwm42012-09-181-14/+6
| | | | | | | | | This was to make an option without value use the option's default value (e.g. --term-osd is the same as --term-osd=auto). Make it simpler by handling this case as an empty choice. The flag was probably needed when option handling still did ambiguous argument parsing.
* libaf: rename af_format.h to format.hwm42012-08-291-1/+1
| | | | | | | | | | af_format.h declares some symbols which are defined in format.c. The fact that af_format.c is a completely unrelated file is rather confusing. Having the header and implementation file use the same base name is more uniform. (af_format.c is the audio conversion filter, while af_format.h and format.c are about audio formats and their properties.) Also fix all source files which include this file.
* options, libaf: unify audio format name handlingwm42012-08-291-60/+8
| | | | | | | | | Remove the duplicated list of audio format names from m_option.c. Remove "long" audio format names, and let af_fmt2str() print the usual short format names. The long names were overly verbose, and were actually rarely user visible. The only difference between af_fmt2str() and af_fmt2str_short() is that the former prints unknown format values as hexadecimal string as fallback.
* options, codecs.conf, img_format: unify imgfmt name handlingwm42012-08-291-19/+7
| | | | | | | | | | | | | Remove the duplication of image format name lists from codec-cfg.c and img_format.c. Remove the list of "long" image format names from img_format.c. One user visible change is that now mplayer won't print "long" format names anymore: e.g. instead of "Planar 420P 10-bit little-endian", the name "420p10le" is used. This is consistent with the names used by the option parser, and also less noisy. Partially based on mplayer2 commit f98e47574de15, with some differences.
* img_format, m_option: make image format name list globally availablewm42012-08-231-81/+0
| | | | And add functions for converting them from/to the name string.
* m_config: support auto-allocated sub-structswm42012-08-061-0/+6
| | | | | | | | | | | | | | Given your option struct has a field that is a pointer to another struct, this commit allows you to declare options that write into that other struct. The code in m_config will dereference the pointer field on its own if such an option is accessed. If the field is NULL on initialization of the containing m_config, the struct is automatically allocated. OPT_SUBSTRUCT() can be used to declare such a field. struct m_sub_options is used to describe the pointed-to struct, and includes size and defaults if the struct has to be allocated by m_config.
* options: get rid of ambiguous option parsingwm42012-08-051-38/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Options parsing used to be ambiguous, as in the splitting into option and values pairs was ambiguous. Example: -option -something It wasn't clear whether -option actually takes an argument or not. The string "-something" could either be a separate option, or an argument to "-option". The code had to call the option specific parser function to resolve this. This made everything complicated and didn't even have a real use. There was only one case where this was actually used: string lists (m_option_type_string_list) and options based on it. That is because this option type actually turns a single option into a proxy for several real arguments, e.g. "vf*" can handle "-vf-add" and "-vf-clr". Options suffixed with "-clr" are the only options of this group which take no arguments. This is ambiguous only with the "old syntax" (as shown above). The "new" option syntax always puts option name and value into same argument. (E.g. "--option=--something" or "--option" "--something".) Simplify the code by making it statically known whether an option takes a parameter or not with the flag M_OPT_TYPE_OLD_SYNTAX_NO_PARAM. If it's set, the option parser assumes the option takes no argument. The only real ambiguity left, string list options that end on "-clr", are special cased in the parser. Remove some duplication of the logic in the command line parser by moving all argument splitting logic into split_opt(). (It's arguable whether that can be considered code duplication, but now the code is a bit simpler anyway. This might be subjective.) Remove the "ambiguous" parameter from all option parsing related code. Make m_config unaware of the pre-parsing concept. Make most CONF_NOCFG options also CONF_GLOBAL (except those explicitly usable as per-file options.)
* options: remove CONF_TYPE_PRINT_INDIRECTwm42012-08-051-8/+1
| | | | This was unused.
* options: revert passing around talloc contextswm42012-08-041-56/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 48f0692ab9 "options: make option struct the talloc parent of options". This made things actually more complicated. It introduced a new parameter to the option parse and copy functions, which was used inconsistently. Some code passed a parent, some not. Morever, you have to call m_option_free() anyway, because not all options actually respect the talloc parent. There is also the question whether passing NULL as parent is supposed to work, or if you still have to implement m_config_free(). On the other hand, this simplifies nothing. I assume the intention was being able to free all option values with a single talloc_free() call, but the same goal can be reached by simply freeing the m_config struct. (The m_config talloc destructor will free each option values.) Get rid of the talloc parent context parameter. This essentially reverts commit 48f0692ab9 ("options: make option struct the talloc parent of options"). In video_out.c, make the VO priv struct the talloc parent for the m_config object, so that destroying the VO will free the options. The ability to free the m_config struct and all its managed options was introduced in commit 89a17bcda6c.
* libmpcodecs: add support for 422P9mplayer-svn2012-08-031-0/+2
| | | | | | | For some reason only 9-bit 422 wasn't added before. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34524 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: reimar
* bstr: rename bstr() function to bstr0(), and typedef bstr to struct bstrwm42012-07-281-9/+9
| | | | | Replace all uses of bstr() with bstr0(). Also remove the ridiculous C++ workaround.
* Merge remote-tracking branch 'origin/master'wm42012-07-281-52/+62
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .gitignore bstr.c cfg-mplayer.h defaultopts.c libvo/video_out.c The conflict in bstr.c is due to uau adding a bstr_getline function in commit 2ba8b91a97e7e8. This function already existed in this branch. While uau's function is obviously derived from mine, it's incompatible. His function preserves line breaks, while mine strips them. Add a bstr_strip_linebreaks function, fix all other uses of bstr_getline, and pick uau's implementation. In .gitignore, change vo_gl3_shaders.h to use an absolute path additional to resolving the merge conflict.
| * options: fix specifying string options without parameterUoti Urpala2012-07-161-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifying a string option with no parameter, as in "--dumpfile" with no '=', erroneously set the corresponding variable to NULL. Fix this to give an error about missing parameter instead. Suboption parsing explicitly treated empty option values as if the option had been specified with no value (no '='). Thus it was not possible to specify empty strings as values. I think this behavior was originally added only because of other limitations in the old implementation. Remove it, so that suboptions now behave the same as top-level ones in this regard. Document the NULL-distinguishing property of bstrdup0() that the code depends on, and also make bstrdup() behave consistently.
| * options: make option struct the talloc parent of optionsUoti Urpala2012-07-161-35/+56
| | | | | | | | | | | | | | | | | | | | | | Allocate dynamically-allocated option values as talloc children of the option struct. This will allow implementing per-object (VO etc) options so that simply freeing the object will free associated options too. This doesn't change quite every allocation in m_option.c, but the exceptions are legacy types which will not matter for new per-object options.
| * options: support parsing values into substructsUoti Urpala2012-07-161-16/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an alternate mode for option parser objects (struct m_config) which is not inherently tied to any particular instance of an option value struct. Instead, this type or parsers can be used to initialize defaults in or parse values into a struct given as a parameter. They do not have the save slot functionality used for main player configuration. The new functionality will be used to replace the separate subopt_helper.c parsing code that is currently used to parse per-object suboptions in VOs etc. Previously, option default values were handled by initializing them in external code before creating a parser. This initialization was done with constants even for dynamically-allocated types like strings. Because trying to free a pointer to a constant would cause a crash when trying to replace the default with another value, parser initialization code then replaced all the original defaults with dynamically-allocated copies. This replace-with-copy behavior is no longer supported for new-style options; instead the option definition itself may contain a default value (new OPTDEF macros), and the new function m_config_initialize() is used to set all options to their default values. Convert the existing initialized dynamically allocated options in main config (the string options --dumpfile, --term-osd-esc, --input=conf) to use this. Other non-dynamic ones could be later converted to use this style of initialization too. There's currently no public call to free all dynamically allocated options in a given option struct because I intend to use talloc functionality for that (make them children of the struct and free with it).
* | Merge remote-tracking branch 'origin/master'wm42012-05-201-353/+104
|\|
| * options: simplify option parsing/setting machineryUoti Urpala2012-05-081-353/+104
| | | | | | | | | | | | | | | | | | | | | | | | Each option type had three separate operations to copy option values between memory locations: copy between general memory locations ("copy"), copy from general memory to active configuration of the program ("set"), and in the other direction ("save"). No normal option depends on this distinction any more. Change everything to define and use a single "copy" operation only. Change the special options "include" and "profile", which depended on hacky option types, to be special-cased directly in option parsing instead. Remove the now unused option types m_option_type_func and m_option_type_func_param.
* | libmpcodecs: rename IMGFMT_GBR24P to IMGFMT_GBRPwm42012-03-251-1/+1
| | | | | | | | This is more in line with the ffmpeg/libav names.
* | libmpcodecs: support planar GBR24 decodingcehoyos2012-03-251-0/+1
| | | | | | | | | | | | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34245 b3059339-0415-0410-9bf9-f77b7e298cf2 Note: ffmpeg first introduced PIX_FMT_GBR24P, which was used in this commit. Later, it was renamed to PIX_FMT_GBRP in ffmpeg and libav. This was updated in revision 34492 in mplayer, but the mplayer specific names (such as IMGFMT_GBR24) were left unchanged.
* | options: allow choice options without parameterwm42012-01-181-8/+15
|/ | | | | | | | | | | If an m_option_type_choice option is declared with M_OPT_IMPLICIT_DEFAULT in its flags, it doesn't require a parameter. For example, if --opt is such an option, it can be invoked as "--opt=val", "-opt", or "--opt". The last two will set the option to the first choice the option declares. Note that "-opt val" (using the old option syntax) is not allowed in this case, as it would be ambiguous. Normal option parsing should be unaffected.
* options: make "choice" option type parsing ignore caseUoti Urpala2011-09-111-1/+1
|
* options: commandline: don't print video filter list twiceUoti Urpala2011-07-311-14/+14
| | | | | | | | | Video filter help output was printed twice since it used a MSGT type that was not suppressed during preparsing. Fix. This removes a "ID_VIDEO_FILTERS" line that was printed --identify, but I'm not aware of anything using that and other things like audio filters have no such ID_ output either. Also change some printf() calls to mp_msg() in code printing filter-specific help.
* options: fix failure to parse trailing ',' in string listUoti Urpala2011-07-311-2/+4
| | | | | | A trailing separator in string list options was ignored after recent commit e873d703e9 ("options: change option parsing to use bstr"), which broke uses such as "-vo vdpau,". Fix.
* options: commandline: print error type for parse failuresUoti Urpala2011-07-291-0/+18
| | | | | | | | | | | | If parsing an option fails, print a string corresponding to the parse function return value (M_OPT_MISSING_PARAM etc). The primary motivation is that the parsing code already outputs messages explaining most problems, but does not itself print anything in the missing parameter case. Before double-dash --options such errors were rare (or rather they resulted in the next commandline argument being silently misinterpreted as an argument to the previous option instead); but now an argument like "--ss" should give a better indication about the problem than just "Error parsing option".
* options: change option parsing to use bstrUoti Urpala2011-07-291-592/+501
| | | | | | Using bstr allows simpler parsing code, especially because it avoids the need to modify or copy strings just to terminate extracted substrings.
* options: indicate ambiguous option parameters explicitlyUoti Urpala2011-07-291-33/+32
| | | | | | | | Command line options like "-foo xyz" are ambiguous: "xyz" may be a parameter to the option "foo" or an unrelated argument. Instead of relying on the struct m_config mode field (commandline/file) pass parameters to specify ambiguous mode explicitly. Meant for "--foo" options which are never ambiguous on command line either.
* Merge branch 'mplayer1_changes'Uoti Urpala2011-07-061-0/+1
|\
| * options: allow colorspace options to recognize "yvyu"reimar2011-07-061-0/+1
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33693 b3059339-0415-0410-9bf9-f77b7e298cf2
* | options: allocate dynamic options with tallocUoti Urpala2011-07-061-97/+80
|/ | | | | | | | | Allocate data structures for dynamic option values with talloc. Hopefully there's no code left that tries to modify those dynamic option values outside the option parser and relies on them being malloc-allocated. Currently talloc functionality isn't used much and the allocations are not hierarchical, so the main practical use for now is just to allow very easy checking for memory leaks.
* commands: change property mechanism to use talloc stringsUoti Urpala2011-07-031-49/+15
|
* cosmetics: reformat demux_lavf.c, m_option.[ch] and m_property.cUoti Urpala2011-07-031-1743/+1908
|
* video/colorspaces: add new 9/10-bit formats from libavcodecUoti Urpala2011-06-261-0/+15
| | | | | | | Add new internal 9/10-bit IMGFMT values and mappings to the corresponding libav* PIX_FMT_* values. Partially based on a patch from Arne Bochem <arneb.mp@ccan.de>.
* options: fix -profile parsing after 2db33ab48cUoti Urpala2011-05-071-1/+3
| | | | | | | | | | | | | | Commit 2db33ab48cfa785 ("options: support string list separators other than ','") started using the "priv" field in options of string list type to store the separator character. However, the "profile" option has a custom type which uses the same parsing function but uses the "priv" field for another purpose. As a result "-profile" parsing used a "random" character as the separator instead of ','; at least uses which depended on ',' working were likely to fail, and if the separator used happened to be a character occurring in the profile name then any use of -profile could break. Fix by adding a check in the parsing function to only read the priv field if the option type is normal string list.
* cleanup: shut up more warningsClément Bœsch2011-05-061-2/+3
|
* options: support string list separators other than ','Uoti Urpala2011-04-201-5/+4
| | | | | | Allow specifying a custom separator character for options of string list type, and use that to define OPT_PATHLIST which takes a list of strings separated by ':' (or ';' on Windows).
* options: remove unused "func_full" option typeUoti Urpala2011-01-311-29/+2
| | | | | | vo_zr was the last user of the "func_full" option type. I think it's better if future features are implemented using more straightforward option functionality. Delete the func_full implementation.
* options: add special -leak-report optionUoti Urpala2011-01-151-1/+1
| | | | | | | | | | | | Add a special option "-leak-report" that enables talloc leak reporting. It only works if it's given as the first argument. The code abuses the CONF_TYPE_PRINT option type to make main option parsing ignore the opti