diff options
66 files changed, 2911 insertions, 1262 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 3575fb22a6..0e1ff45516 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -3894,6 +3894,9 @@ Select the scaling function to use for chrominance scaling. For details see lscale. .IPs filter-strength=<value> Set the effect strength for the lscale/cscale filters that support it. +.IPs noise-strength=<value> +Set how much noise to add. 0 to disable (default), 1.0 for level suitable +for dithering to 6 bit. .IPs stereo=<value> Select a method for stereo display. You may have to use \-aspect to fix the aspect value. @@ -368,6 +368,7 @@ SRCS_COMMON = asxparser.c \ libmpdemux/demux_avi.c \ libmpdemux/demux_demuxers.c \ libmpdemux/demux_edl.c \ + libmpdemux/demux_cue.c \ libmpdemux/demux_film.c \ libmpdemux/demux_fli.c \ libmpdemux/demux_lavf.c \ @@ -402,6 +403,7 @@ SRCS_COMMON = asxparser.c \ libmpdemux/yuv4mpeg.c \ libmpdemux/yuv4mpeg_ratio.c \ libvo/osd.c \ + libvo/eosd_packer.c \ osdep/numcores.c \ osdep/$(GETCH) \ osdep/$(TIMER) \ @@ -425,6 +427,7 @@ SRCS_COMMON = asxparser.c \ sub/vobsub.c \ timeline/tl_edl.c \ timeline/tl_matroska.c \ + timeline/tl_cue.c \ $(SRCS_COMMON-yes) @@ -185,6 +185,27 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str) return r; } +struct bstr bstr_getline(struct bstr str, struct bstr *rest) +{ + int pos = bstrchr(str, '\n'); + if (pos < 0) + pos = str.len; + if (rest) + *rest = bstr_cut(str, pos + 1); + str.len = pos; + if (str.len > 0 && str.start[str.len - 1] == '\r') + str.len -= 1; + return str; +} + +bool bstr_eatstart(struct bstr *s, struct bstr prefix) +{ + if (!bstr_startswith(*s, prefix)) + return false; + *s = bstr_cut(*s, prefix.len); + return true; +} + void bstr_lower(struct bstr str) { for (int i = 0; i < str.len; i++) @@ -201,3 +222,63 @@ int bstr_sscanf(struct bstr str, const char *format, ...) talloc_free(ptr); return ret; } + +int bstr_parse_utf8_code_length(unsigned char b) +{ + if (b < 128) + return 1; + int bytes = 7 - av_log2(b ^ 255); + return (bytes >= 2 && bytes <= 4) ? bytes : -1; +} + +int bstr_decode_utf8(struct bstr s, struct bstr *out_next) +{ + if (s.len == 0) + return -1; + unsigned int codepoint = s.start[0]; + s.start++; s.len--; + if (codepoint >= 128) { + int bytes = bstr_parse_utf8_code_length(codepoint); + if (bytes < 0 || s.len < bytes - 1) + return -1; + codepoint &= 127 >> bytes; + for (int n = 1; n < bytes; n++) { + int tmp = s.start[0]; + if ((tmp & 0xC0) != 0x80) + return -1; + codepoint = (codepoint << 6) | (tmp & ~0xC0); + s.start++; s.len--; + } + } + if (out_next) + *out_next = s; + return codepoint; +} + +bool bstr_case_startswith(struct bstr s, struct bstr prefix) +{ + struct bstr start = bstr_splice(s, 0, prefix.len); + return start.len == prefix.len && bstrcasecmp(start, prefix) == 0; +} + +bool bstr_case_endswith(struct bstr s, struct bstr suffix) +{ + struct bstr end = bstr_cut(s, -suffix.len); + return end.len == suffix.len && bstrcasecmp(end, suffix) == 0; +} + +struct bstr bstr_strip_ext(struct bstr str) +{ + int dotpos = bstrrchr(str, '.'); + if (dotpos < 0) + return str; + return (struct bstr){str.start, dotpos}; +} + +struct bstr bstr_get_ext(struct bstr s) +{ + int dotpos = bstrrchr(s, '.'); + if (dotpos < 0) + return (struct bstr){NULL, 0}; + return bstr_splice(s, dotpos + 1, s.len); +} @@ -69,8 +69,41 @@ double bstrtod(struct bstr str, struct bstr *rest); void bstr_lower(struct bstr str); int bstr_sscanf(struct bstr str, const char *format, ...); +// Decode the UTF-8 code point at the start of the string,, and return the +// character. +// After calling this function, *out_next will point to the next character. +// out_next can be NULL. +// On error, -1 is returned, and *out_next is not modified. +int bstr_decode_utf8(struct bstr str, struct bstr *out_next); + +// Return the length of the UTF-8 sequence that starts with the given byte. +// Given a string char *s, the next UTF-8 code point is to be expected at +// s + bstr_parse_utf8_code_length(s[0]) +// On error, -1 is returned. On success, it returns a value in the range [1, 4]. +int bstr_parse_utf8_code_length(unsigned char b); + +// Return the text before the next line break, and return it. Change *rest to +// point to the text following this line break. (rest can be NULL.) +// Unlike bstr_splitlines, possible \r characters coming from files with CR+LF +// line breaks are stripped. +struct bstr bstr_getline(struct bstr str, struct bstr *rest); + +// If s starts with prefix, return true and return the rest of the string in s. +bool bstr_eatstart(struct bstr *s, struct bstr prefix); + +bool bstr_case_startswith(struct bstr s, struct bstr prefix); +bool bstr_case_endswith(struct bstr s, struct bstr suffix); +struct bstr bstr_strip_ext(struct bstr str); +struct bstr bstr_get_ext(struct bstr s); + + static inline struct bstr bstr_cut(struct bstr str, int n) { + if (n < 0) { + n += str.len; + if (n < 0) + n = 0; + } if (n > str.len) n = str.len; return (struct bstr){str.start + n, str.len - n}; diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 471e3d8505..790a1d1503 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -485,6 +485,9 @@ const m_option_t common_opts[] = { {"sb", &seek_to_byte, CONF_TYPE_POSITION, CONF_MIN, 0, 0, NULL}, OPT_TIME("ss", seek_to_sec, 0), + // start paused + OPT_FLAG_ON("pause", start_paused, 0), + // stop at given position {"endpos", &end_at, CONF_TYPE_TIME_SIZE, 0, 0, 0, NULL}, @@ -909,7 +912,15 @@ const m_option_t mplayer_opts[]={ OPT_STRING("rtc-device", rtc_device, 0), #endif - OPT_MAKE_FLAGS("term-osd", term_osd, 0), + OPT_CHOICE("term-osd", term_osd, M_OPT_IMPLICIT_DEFAULT, + ({"force", 1}, + {"auto", 2}, + {"off", 0})), + + // set term_osd to 0 + // this is for compatibility + {"noterm-osd", NULL, &m_option_type_flag, 0, 1, 0, NULL, 1, offsetof(struct MPOpts, term_osd)}, + OPT_STRING("term-osd-esc", term_osd_esc, 0), OPT_STRING("playing-msg", playing_msg, 0), @@ -926,6 +937,11 @@ const m_option_t mplayer_opts[]={ {"tvscan", "MPlayer was compiled without TV interface support.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, #endif /* CONFIG_TV */ + OPT_INTRANGE("screenshot-jpeg-quality", screenshot_jpeg_quality, 0, 0, 100), + OPT_INTRANGE("screenshot-png-compression", screenshot_png_compression, 0, 0, 9), + OPT_STRING("screenshot-filetype", screenshot_filetype, 0), + OPT_STRING("screenshot-template", screenshot_template, 0), + OPT_FLAG_ON("list-properties", list_properties, CONF_GLOBAL), {"identify", &mp_msg_levels[MSGT_IDENTIFY], CONF_TYPE_FLAG, CONF_GLOBAL, 0, MSGL_V, NULL}, {"help", (void *) help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL}, @@ -21,6 +21,7 @@ #include <unistd.h> #include <string.h> #include <stdbool.h> +#include <assert.h> #include "config.h" #include "talloc.h" @@ -719,10 +720,6 @@ static int mp_property_volume(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; - mpctx->user_muted = 0; - switch (action) { case M_PROPERTY_SET: if (!arg) @@ -756,30 +753,17 @@ static int mp_property_mute(m_option_t *prop, int action, void *arg, switch (action) { case M_PROPERTY_SET: - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; if (!arg) return M_PROPERTY_ERROR; - if ((!!*(int *) arg) != mpctx->mixer.muted) - mixer_mute(&mpctx->mixer); - mpctx->user_muted = mpctx->mixer.muted; + mixer_setmuted(&mpctx->mixer, *(int *) arg); return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - if (mpctx->edl_muted) - return M_PROPERTY_DISABLED; mixer_mute(&mpctx->mixer); - mpctx->user_muted = mpctx->mixer.muted; return M_PROPERTY_OK; - case M_PROPERTY_PRINT: - if (!arg) - return M_PROPERTY_ERROR; - if (mpctx->edl_muted) { - *(char **) arg = talloc_strdup(NULL, mp_gtext("enabled (EDL)")); - return M_PROPERTY_OK; - } default: - return m_property_flag(prop, action, arg, &mpctx->mixer.muted); + return m_property_flag_ro(prop, action, arg, + mixer_getmuted(&mpctx->mixer)); } } @@ -2804,6 +2788,28 @@ static void remove_subtitle_range(MPContext *mpctx, int start, int count) } } +static void do_clear_pt(struct play_tree *node, struct play_tree *exclude) +{ + while (node) { + do_clear_pt(node->child, exclude); + struct play_tree *next = node->next; + // do not delete root node, or nodes that could lead to "exclude" node + if (node->parent && !node->child && node != exclude) + play_tree_remove(node, 1, 1); + node = next; + } +} + +static void clear_play_tree(MPContext *mpctx) +{ + struct play_tree *exclude = NULL; + if (mpctx->playtree_iter) { + assert(mpctx->playtree == mpctx->playtree_iter->root); + exclude = mpctx->playtree_iter->tree; + } + do_clear_pt(mpctx->playtree, exclude); +} + void run_command(MPContext *mpctx, mp_cmd_t *cmd) { struct MPOpts *opts = &mpctx->opts; @@ -3133,6 +3139,10 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) break; } + case MP_CMD_PLAY_TREE_CLEAR: + clear_play_tree(mpctx); + break; + case MP_CMD_STOP: // Go back to the starting point. while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != diff --git a/defaultopts.c b/defaultopts.c index 52e63cc489..bf0489a335 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -30,7 +30,7 @@ void set_default_mplayer_options(struct MPOpts *opts) .edition_id = -1, .user_correct_pts = -1, .initial_audio_sync = 1, - .term_osd = 1, + .term_osd = 2, .term_osd_esc = "\x1b[A\r\x1b[K", .consolecontrols = 1, .doubleclick_time = 300, @@ -38,6 +38,8 @@ void set_default_mplayer_options(struct MPOpts *opts) .video_id = -1, .sub_id = -1, .extension_parsing = 1, + .screenshot_jpeg_quality = 85, + .screenshot_png_compression = 7, .audio_output_channels = 2, .audio_output_format = -1, // AF_FORMAT_UNKNOWN .playback_speed = 1., diff --git a/etc/input.conf b/etc/input.conf index 509f1bf876..b358d33243 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -1,62 +1,83 @@ -## -## MPlayer input control file -## -## You are able to redefine default keyboard/joystick/mouse/LIRC bindings, or -## add new ones here. -## See DOCS/tech/slave.txt for possible commands that can be bound. -## Also see mplayer -input cmdlist for other possible options. -## The file should be placed in the $HOME/.mplayer directory. -## -## If you wish to unbind a key, use key ignore. -## e.g. ENTER ignore -## -## You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with -## modifiers Shift, Ctrl, Alt and Meta, but note that currently reading -## key combinations is only supported through the video windows of X-based -## output drivers (not in output windows of other drivers or in a terminal). +# MPlayer input control file +# +# You are able to redefine default keyboard/joystick/mouse/LIRC bindings, or +# add new ones here. +# See DOCS/tech/slave.txt for possible commands that can be bound. +# Also see mplayer -input cmdlist for other possible options. +# The file should be placed in the $HOME/.mplayer directory. +# +# If you wish to unbind a key, use key ignore. +# e.g. ENTER ignore +# +# Note that merely removing default key bindings from this file won't remove +# the default bindings mplayer was compiled with, unless +# --input=nodefault-bindings +# is specified. +# +# Lines starting with # are comments. Use SHARP to assign the # key. +# +# Some characters need to be escaped. In particular, if you want to display +# a '\' character as part of an osd_show_property_text OSD message, you have to +# escape 2 times: +# key osd_show_property_text "This is a single backslash: \\\\!" +# +# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with +# modifiers Shift, Ctrl, Alt and Meta, but note that currently reading +# key combinations is only supported through the video windows of X-based +# output drivers (not in output windows of other drivers or in a terminal). -RIGHT seek +10 +MOUSE_BTN0_DBL vo_fullscreen # toggle fullscreen on/off +MOUSE_BTN2 pause # toggle pause on/off +MOUSE_BTN3 seek 10 +MOUSE_BTN4 seek -10 +MOUSE_BTN5 volume 1 +MOUSE_BTN6 volume -1 + +# Seek units are in seconds, but note that these are mostly limited by keyframes +RIGHT seek 10 LEFT seek -10 +UP seek 60 DOWN seek -60 -UP seek +60 # Do smaller, always exact (non-keyframe-limited), seeks with shift. -Shift+Right seek +1 0 1 -Shift+Left seek -1 0 1 -Shift+Down seek -5 0 1 -Shift+Up seek +5 0 1 +Shift+RIGHT seek 1 0 1 +Shift+LEFT seek -1 0 1 +Shift+UP seek 5 0 1 +Shift+DOWN seek -5 0 1 PGUP seek 600 PGDWN seek -600 -m mute -# switch_audio # switch audio streams -+ audio_delay 0.100 -= audio_delay 0.100 ++ audio_delay 0.100 # this changes audio/video sync - audio_delay -0.100 -[ speed_mult 0.9091 # scale playback speed +[ speed_mult 0.9091 # scale playback speed ] speed_mult 1.1 { speed_mult 0.5 } speed_mult 2.0 -BS speed_set 1.0 # reset speed to normal +BS speed_set 1.0 # reset speed to normal q quit ESC quit -ENTER pt_step 1 1 # skip to next file -p pause -. frame_step # advance one frame and pause +p pause # toggle pause/playback mode +. frame_step # advance one frame and pause SPACE pause HOME pt_up_step 1 END pt_up_step -1 -> pt_step 1 # skip to next file -< pt_step -1 # previous +> pt_step 1 # skip to next file +ENTER pt_step 1 1 # skip to next file or quit +< pt_step -1 # skip to previous file INS alt_src_step 1 DEL alt_src_step -1 -o osd -I osd_show_property_text "${filename}" # display filename in osd +o osd # cycle through OSD mode +I osd_show_property_text "${filename}" # display filename in osd P osd_show_progression -z sub_delay -0.1 # subtract 100 ms delay from subs -x sub_delay +0.1 # add +z sub_delay -0.1 # subtract 100 ms delay from subs +x sub_delay +0.1 # add +g sub_step -1 # immediately display next subtitle +y sub_step +1 # previous 9 volume -1 / volume -1 0 volume 1 * volume 1 +( balance -0.1 # adjust audio balance in favor of left +) balance 0.1 # right +m mute 1 contrast -1 2 contrast 1 3 brightness -1 @@ -65,54 +86,77 @@ x sub_delay +0.1 # add 6 hue 1 7 saturation -1 8 saturation 1 -( balance -0.1 # adjust audio balance in favor of left -) balance +0.1 # right -d frame_drop -D step_property deinterlace # toggle deinterlacer, requires -vf yadif or kerndeint -r sub_pos -1 # move subtitles up -t sub_pos +1 # down -#? sub_step +1 # immediately display next subtitle -#? sub_step -1 # previous -#? sub_scale +0.1 # increase subtitle font size -#? sub_scale -0.1 # decrease subtitle font size -V step_property_osd ass_vsfilter_aspect_compat # stretch SSA/ASS subtitles with anamorphic videos to match historical VSFilter behavior -f vo_fullscreen -T vo_ontop # toggle video window ontop of other windows -w panscan -0.1 # zoom out with -panscan 0 -fs -e panscan +0.1 # in -s screenshot |