From 9e6933440ae59c523fce85b64d6f52f444910003 Mon Sep 17 00:00:00 2001 From: harklu Date: Thu, 4 Aug 2011 21:47:36 +0200 Subject: options, subs: add --ass-vsfilter-aspect-compat Add option --ass-vsfilter-aspect-compat and corresponding property ass_vsfilter_aspect_compat. The setting controls whether to enable the emulation of traditional VSFilter behavior where subtitles are stretched if the video is anamorphic (previously always enabled for native SSA/ASS subtitles). Enabled by default. Add 'V' as a new default keybinding to toggle the property. --- DOCS/man/en/mplayer.1 | 22 ++++++++++++++++++++++ DOCS/tech/slave.txt | 1 + cfg-mplayer.h | 1 + command.c | 25 +++++++++++++++++++++++++ defaultopts.c | 1 + etc/input.conf | 1 + input/input.c | 1 + libmpcodecs/vf_ass.c | 5 +++-- libmpcodecs/vf_vo.c | 3 ++- options.h | 1 + 10 files changed, 58 insertions(+), 3 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index bbbea0e7c2..3575fb22a6 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -251,6 +251,9 @@ Toggle displaying "forced subtitles". Toggle subtitle alignment: top / middle / bottom. .IPs "x and z" Adjust subtitle delay by +/\- 0.1 seconds. +.IPs "V\ \ \ \ " +Toggle subtitle VSFilter aspect compatibility mode. +See -ass\-vsfilter\-aspect\-compat for more info. .IPs "C (\-capture only)" Start/stop capturing the primary stream. .IPs "r and t" @@ -2226,6 +2229,25 @@ Enables placing toptitles and subtitles in black borders when they are available. . .TP +.B \-ass\-vsfilter\-aspect\-compat +Stretch SSA/ASS subtitles when playing anamorphic videos for compatibility +with traditional VSFilter behavior. +This switch has no effect when the video is stored with square pixels. +.sp 1 +The renderer historically most commonly used for the SSA/ASS subtitle formats, +VSFilter, had questionable behavior that resulted in subtitles being +stretched too if the video was stored in anamorphic format that required +scaling for display. +This behavior is usually undesirable and newer VSFilter versions may +behave differently. +However, many existing scripts compensate for the stretching by modifying +things in the opposite direction. +Thus if such scripts are displayed "correctly" they will not appear as intended. +This switch enables emulation of the old VSFilter behavior (undesirable but +expected by many existing scripts). +Enabled by default. +. +.TP .B \-dumpjacosub Convert the given subtitle (specified with the \-sub option) to the time-based JACOsub subtitle format. diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt index d95ef41d84..0e906cf857 100644 --- a/DOCS/tech/slave.txt +++ b/DOCS/tech/slave.txt @@ -585,6 +585,7 @@ sub_alignment int 0 2 X X X subtitle alignment sub_visibility flag 0 1 X X X show/hide subtitles sub_forced_only flag 0 1 X X X sub_scale float 0 100 X X X subtitles font size +ass_vsfilter_aspect_compat flag 0 1 X X X SSA/ASS aspect ratio correction tv_brightness int -100 100 X X X tv_contrast int -100 100 X X X tv_saturation int -100 100 X X X diff --git a/cfg-mplayer.h b/cfg-mplayer.h index a92502cb55..5dd9962238 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -699,6 +699,7 @@ const m_option_t common_opts[] = { {"ass-bottom-margin", &ass_bottom_margin, CONF_TYPE_INT, CONF_RANGE, 0, 2000, NULL}, {"ass-use-margins", &ass_use_margins, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"noass-use-margins", &ass_use_margins, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + OPT_MAKE_FLAGS("ass-vsfilter-aspect-compat", ass_vsfilter_aspect_compat, 0), {"embeddedfonts", &use_embedded_fonts, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"noembeddedfonts", &use_embedded_fonts, CONF_TYPE_FLAG, 0, 1, 0, NULL}, OPT_STRINGLIST("ass-force-style", ass_force_style_list, 0), diff --git a/command.c b/command.c index fc8750ea29..1dea8cfaab 100644 --- a/command.c +++ b/command.c @@ -1973,6 +1973,27 @@ static int mp_property_ass_use_margins(m_option_t *prop, int action, return m_property_flag(prop, action, arg, &ass_use_margins); } } + +static int mp_property_ass_vsfilter_aspect_compat(m_option_t *prop, int action, + void *arg, MPContext *mpctx) +{ + if (!mpctx->sh_video) + return M_PROPERTY_UNAVAILABLE; + + switch (action) { + case M_PROPERTY_SET: + if (!arg) + return M_PROPERTY_ERROR; + case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP_DOWN: + //has to re-render subs with new aspect ratio + mpctx->osd->ass_force_reload = 1; + default: + return m_property_flag(prop, action, arg, + &mpctx->opts.ass_vsfilter_aspect_compat); + } +} + #endif /// Show only forced subtitles (RW) @@ -2316,6 +2337,8 @@ static const m_option_t mp_properties[] = { #ifdef CONFIG_ASS { "ass_use_margins", mp_property_ass_use_margins, CONF_TYPE_FLAG, M_OPT_RANGE, 0, 1, NULL }, + { "ass_vsfilter_aspect_compat", mp_property_ass_vsfilter_aspect_compat, + CONF_TYPE_FLAG, M_OPT_RANGE, 0, 1, NULL }, #endif #ifdef CONFIG_TV @@ -2427,6 +2450,8 @@ static struct property_osd_display { #ifdef CONFIG_FREETYPE { "sub_scale", 0, -1, _("Sub Scale: %s")}, #endif + { "ass_vsfilter_aspect_compat", 0, -1, + _("Subtitle VSFilter aspect compat: %s")}, #ifdef CONFIG_TV { "tv_brightness", OSD_BRIGHTNESS, -1, _("Brightness") }, { "tv_hue", OSD_HUE, -1, _("Hue") }, diff --git a/defaultopts.c b/defaultopts.c index b498fef026..a249ec05b6 100644 --- a/defaultopts.c +++ b/defaultopts.c @@ -49,6 +49,7 @@ void set_default_mplayer_options(struct MPOpts *opts) #ifdef CONFIG_ASS .ass_enabled = 1, #endif + .ass_vsfilter_aspect_compat = 1, .lavc_param = { .workaround_bugs = 1, // autodetect diff --git a/etc/input.conf b/etc/input.conf index d9c8684996..45b20f9b23 100644 --- a/etc/input.conf +++ b/etc/input.conf @@ -75,6 +75,7 @@ t sub_pos +1 # down #? 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 diff --git a/input/input.c b/input/input.c index e1feb8e8e4..35714820e3 100644 --- a/input/input.c +++ b/input/input.c @@ -472,6 +472,7 @@ static const struct cmd_bind def_cmd_binds[] = { { { 't', 0 }, "sub_pos +1" }, { { 'a', 0 }, "sub_alignment" }, { { 'v', 0 }, "sub_visibility" }, + { { 'V', 0 }, "step_property_osd ass_vsfilter_aspect_compat" }, { { 'j', 0 }, "sub_select" }, { { 'J', 0 }, "sub_select -3" }, { { 'F', 0 }, "forced_subs_only" }, diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c index 76a08807e7..c34c0b88e3 100644 --- a/libmpcodecs/vf_ass.c +++ b/libmpcodecs/vf_ass.c @@ -358,8 +358,9 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) { struct osd_state *osd = vf->priv->osd; ASS_Image *images = 0; - ASS_Renderer *renderer = osd->vsfilter_aspect ? - vf->priv->renderer_vsfilter : vf->priv->renderer_realaspect; + ASS_Renderer *renderer = osd->vsfilter_aspect + && vf->opts->ass_vsfilter_aspect_compat + ? vf->priv->renderer_vsfilter : vf->priv->renderer_realaspect; if (sub_visibility && renderer && osd->ass_track && (pts != MP_NOPTS_VALUE)) { if (osd->ass_force_reload) { diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c index 62ec64ef3f..347c1e96b1 100644 --- a/libmpcodecs/vf_vo.c +++ b/libmpcodecs/vf_vo.c @@ -23,6 +23,7 @@ #include "config.h" #include "mp_msg.h" +#include "options.h" #include "mp_image.h" #include "vf.h" @@ -155,7 +156,7 @@ static int control(struct vf_instance *vf, int request, void* data) double pts = video_out->next_pts; ASS_Renderer *renderer; double scale; - if (osd->vsfilter_aspect) { + if (osd->vsfilter_aspect && vf->opts->ass_vsfilter_aspect_compat) { renderer = vf->priv->renderer_vsfilter; scale = vf->priv->scale_ratio; } else { diff --git a/options.h b/options.h index 3349d52edf..f6f28c0939 100644 --- a/options.h +++ b/options.h @@ -92,6 +92,7 @@ typedef struct MPOpts { char **sub_paths; int sub_auto; int ass_enabled; + int ass_vsfilter_aspect_compat; char **ass_force_style_list; struct lavc_param { int workaround_bugs; -- cgit v1.2.3