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.
This commit is contained in:
harklu 2011-08-04 21:47:36 +02:00 committed by Uoti Urpala
parent e30416c997
commit 9e6933440a
10 changed files with 58 additions and 3 deletions

View File

@ -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.

View File

@ -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

View File

@ -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),

View File

@ -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") },

View File

@ -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

View File

@ -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

View File

@ -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" },

View File

@ -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) {

View File

@ -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 {

View File

@ -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;