diff options
Diffstat (limited to 'options')
-rw-r--r-- | options/m_option.c | 110 | ||||
-rw-r--r-- | options/m_option.h | 18 | ||||
-rw-r--r-- | options/options.c | 14 | ||||
-rw-r--r-- | options/options.h | 6 |
4 files changed, 112 insertions, 36 deletions
diff --git a/options/m_option.c b/options/m_option.c index b7b76634f8..fd1e6770ee 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -2287,51 +2287,111 @@ const m_option_type_t m_option_type_afmt = { #include "audio/chmap.h" -static int parse_chmap(struct mp_log *log, const m_option_t *opt, - struct bstr name, struct bstr param, void *dst) +static int parse_channels(struct mp_log *log, const m_option_t *opt, + struct bstr name, struct bstr param, void *dst) { - // min>0: at least min channels, min=0: empty ok - int min_ch = (opt->flags & M_OPT_MIN) ? opt->min : 1; - assert(min_ch >= 0); + // see OPT_CHANNELS for semantics. + bool limited = opt->min; + + struct m_channels res = {0}; if (bstr_equals0(param, "help")) { mp_chmap_print_help(log); + if (!limited) { + mp_info(log, "\nOther values:\n" + " auto-safe\n"); + } return M_OPT_EXIT - 1; } - if (param.len == 0 && min_ch >= 1) - return M_OPT_MISSING_PARAM; - - struct mp_chmap res = {0}; - if (!mp_chmap_from_str(&res, param)) { - mp_err(log, "Error parsing channel layout: %.*s\n", BSTR_P(param)); - return M_OPT_INVALID; + bool auto_safe = bstr_equals0(param, "auto-safe"); + if (bstr_equals0(param, "auto") || bstr_equals0(param, "empty") || auto_safe) { + if (limited) { + mp_err(log, "Disallowed parameter.\n"); + return M_OPT_INVALID; + } + param.len = 0; + res.set = true; + res.auto_safe = auto_safe; } - if (!mp_chmap_is_valid(&res) && !(min_ch == 0 && mp_chmap_is_empty(&res))) { - mp_err(log, "Invalid channel layout: %.*s\n", BSTR_P(param)); - return M_OPT_INVALID; + while (param.len) { + bstr item; + if (limited) { + item = param; + param.len = 0; + } else { + bstr_split_tok(param, ",", &item, ¶m); + } + + struct mp_chmap map = {0}; + if (!mp_chmap_from_str(&map, item) || !mp_chmap_is_valid(&map)) { + mp_err(log, "Invalid channel layout: %.*s\n", BSTR_P(item)); + talloc_free(res.chmaps); + return M_OPT_INVALID; + } + + MP_TARRAY_APPEND(NULL, res.chmaps, res.num_chmaps, map); + res.set = true; } - if (dst) - *(struct mp_chmap *)dst = res; + if (dst) { + *(struct m_channels *)dst = res; + } else { + talloc_free(res.chmaps); + } return 1; } -static char *print_chmap(const m_option_t *opt, const void *val) +static char *print_channels(const m_option_t *opt, const void *val) { - const struct mp_chmap *chmap = val; - return talloc_strdup(NULL, mp_chmap_to_str(chmap)); + const struct m_channels *ch = val; + if (!ch->set) + return talloc_strdup(NULL, ""); + if (ch->auto_safe) + return talloc_strdup(NULL, "auto-safe"); + if (ch->num_chmaps > 0) { + char *res = talloc_strdup(NULL, ""); + for (int n = 0; n < ch->num_chmaps; n++) { + if (n > 0) + res = talloc_strdup_append(res, ","); + res = talloc_strdup_append(res, mp_chmap_to_str(&ch->chmaps[n])); + } + return res; + } + return talloc_strdup(NULL, "auto"); } +static void free_channels(void *src) +{ + if (!src) + return; -const m_option_type_t m_option_type_chmap = { + struct m_channels *ch = src; + talloc_free(ch->chmaps); + *ch = (struct m_channels){0}; +} + +static void copy_channels(const m_option_t *opt, void *dst, const void *src) +{ + if (!(dst && src)) + return; + + struct m_channels *ch = dst; + free_channels(dst); + *ch = *(struct m_channels *)src; + ch->chmaps = + talloc_memdup(NULL, ch->chmaps, sizeof(ch->chmaps[0]) * ch->num_chmaps); +} + +const m_option_type_t m_option_type_channels = { .name = "Audio channels or channel map", - .size = sizeof(struct mp_chmap), - .parse = parse_chmap, - .print = print_chmap, - .copy = copy_opt, + .size = sizeof(struct m_channels), + .parse = parse_channels, + .print = print_channels, + .copy = copy_channels, + .free = free_channels, }; static int parse_timestring(struct bstr str, double *time, char endchar) diff --git a/options/m_option.h b/options/m_option.h index e77452af69..80be447c42 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -61,7 +61,7 @@ extern const m_option_type_t m_option_type_afmt; extern const m_option_type_t m_option_type_color; extern const m_option_type_t m_option_type_geometry; extern const m_option_type_t m_option_type_size_box; -extern const m_option_type_t m_option_type_chmap; +extern const m_option_type_t m_option_type_channels; extern const m_option_type_t m_option_type_node; // Used internally by m_config.c @@ -98,6 +98,13 @@ struct m_geometry { void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh, struct m_geometry *gm); +struct m_channels { + bool set : 1; + bool auto_safe : 1; + struct mp_chmap *chmaps; + int num_chmaps; +}; + struct m_obj_desc { // Name which will be used in the option string const char *name; @@ -218,7 +225,7 @@ union m_option_value { struct m_color color; struct m_geometry geometry; struct m_geometry size_box; - struct mp_chmap chmap; + struct m_channels channels; }; //////////////////////////////////////////////////////////////////////////// @@ -626,9 +633,10 @@ extern const char m_option_path_separator; #define OPT_AUDIOFORMAT(...) \ OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_afmt) -#define OPT_CHMAP(...) \ - OPT_GENERAL(struct mp_chmap, __VA_ARGS__, .type = &m_option_type_chmap) - +// If .min==1, then passing auto is disallowed, but "" is still accepted, and +// limit channel list to 1 item. +#define OPT_CHANNELS(...) \ + OPT_GENERAL(struct m_channels, __VA_ARGS__, .type = &m_option_type_channels) #define M_CHOICES(choices) \ .priv = (void *)&(const struct m_opt_choice_alternatives[]){ \ diff --git a/options/options.c b/options/options.c index e58eea1bc9..9e3e70385e 100644 --- a/options/options.c +++ b/options/options.c @@ -40,7 +40,6 @@ #include "video/csputils.h" #include "video/hwdec.h" #include "sub/osd.h" -#include "audio/mixer.h" #include "audio/filter/af.h" #include "audio/decode/dec_audio.h" #include "player/core.h" @@ -85,6 +84,7 @@ const struct m_opt_choice_alternatives mp_hwdec_names[] = { {"auto-copy", HWDEC_AUTO_COPY}, {"vdpau", HWDEC_VDPAU}, {"videotoolbox",HWDEC_VIDEOTOOLBOX}, + {"videotoolbox-copy",HWDEC_VIDEOTOOLBOX_COPY}, {"vaapi", HWDEC_VAAPI}, {"vaapi-copy", HWDEC_VAAPI_COPY}, {"dxva2", HWDEC_DXVA2}, @@ -279,7 +279,7 @@ const m_option_t mp_opts[] = { // force video/audio rate: OPT_DOUBLE("fps", force_fps, CONF_MIN, .min = 0), OPT_INTRANGE("audio-samplerate", force_srate, 0, 1000, 16*48000), - OPT_CHMAP("audio-channels", audio_output_channels, CONF_MIN, .min = 0), + OPT_CHANNELS("audio-channels", audio_output_channels, 0), OPT_AUDIOFORMAT("audio-format", audio_output_format, 0), OPT_FLAG("audio-normalize-downmix", audio_normalize, 0), OPT_DOUBLE("speed", playback_speed, M_OPT_RANGE | M_OPT_FIXED, @@ -288,7 +288,7 @@ const m_option_t mp_opts[] = { OPT_FLAG("audio-pitch-correction", pitch_correction, 0), // set a-v distance - OPT_FLOATRANGE("audio-delay", audio_delay, 0, -100.0, 100.0), + OPT_FLOAT("audio-delay", audio_delay, 0), // ------------------------- codec/vfilter options -------------------- @@ -342,6 +342,7 @@ const m_option_t mp_opts[] = { OPT_PATHLIST("sub-paths", sub_paths, 0), OPT_PATHLIST("audio-file-paths", audiofile_paths, 0), OPT_STRING_APPEND_LIST("external-file", external_files, M_OPT_FILE), + OPT_FLAG("autoload-files", autoload_files, 0), OPT_STRING("sub-codepage", sub_cp, 0), OPT_FLOAT("sub-delay", sub_delay, 0), OPT_FLOAT("sub-fps", sub_fps, 0), @@ -396,6 +397,8 @@ const m_option_t mp_opts[] = { OPT_STRING("audio-device", audio_device, 0), OPT_STRING("audio-client-name", audio_client_name, 0), OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0), + OPT_FLAG("audio-stream-silence", audio_stream_silence, 0), + OPT_FLOATRANGE("audio-wait-open", audio_wait_open, 0, 0, 60), OPT_CHOICE("force-window", force_vo, 0, ({"no", 0}, {"yes", 1}, {"immediate", 2})), OPT_FLAG("taskbar-progress", vo.taskbar_progress, 0), @@ -423,6 +426,7 @@ const m_option_t mp_opts[] = { {"weak", -1})), OPT_DOUBLE("audio-buffer", audio_buffer, M_OPT_MIN | M_OPT_MAX, .min = 0, .max = 10), + OPT_FLOATRANGE("balance", balance, 0, -1, 1), OPT_GEOMETRY("geometry", vo.geometry, 0), OPT_SIZE_BOX("autofit", vo.autofit, 0), @@ -760,6 +764,7 @@ const struct MPOpts mp_default_opts = { .sync_audio_drop_size = 0.020, .load_config = 1, .position_resume = 1, + .autoload_files = 1, .stream_cache = { .size = -1, .def_size = 75000, @@ -804,7 +809,6 @@ const struct MPOpts mp_default_opts = { .sub_visibility = 1, .sub_pos = 100, .sub_speed = 1.0, - .audio_output_channels = MP_CHMAP_INIT_STEREO, .audio_output_format = 0, // AF_FORMAT_UNKNOWN .playback_speed = 1., .pitch_correction = 1, @@ -827,7 +831,7 @@ const struct MPOpts mp_default_opts = { .sub_cp = "auto", .screenshot_template = "mpv-shot%n", - .hwdec_codecs = "h264,vc1,wmv3,hevc,mpeg2video", + .hwdec_codecs = "h264,vc1,wmv3,hevc,mpeg2video,vp9", .videotoolbox_format = IMGFMT_NV12, .index_mode = 1, diff --git a/options/options.h b/options/options.h index 3e8474fd75..4de4a831bb 100644 --- a/options/options.h +++ b/options/options.h @@ -87,9 +87,12 @@ typedef struct MPOpts { char *audio_device; char *audio_client_name; int ao_null_fallback; + int audio_stream_silence; + float audio_wait_open; int force_vo; int softvol; float softvol_volume; + float balance; int softvol_mute; float softvol_max; int gapless_audio; @@ -225,7 +228,7 @@ typedef struct MPOpts { double force_fps; int index_mode; - struct mp_chmap audio_output_channels; + struct m_channels audio_output_channels; int audio_output_format; int audio_normalize; int force_srate; @@ -242,6 +245,7 @@ typedef struct MPOpts { char **sub_paths; char **audiofile_paths; char **external_files; + int autoload_files; int sub_auto; int audiofile_auto; int osd_bar_visible; |