subs: fix per-file --ass-force-style

The --ass-force-style option was only applied when the main libass
library handle was created. Thus any per-file option changes later had
no effect. Do the ass_set_style_overrides() call in per-file
initialization instead so that possible changes will be applied. Also
move the option variable to the option struct.

Current libass will crash (usually) if you set style overrides to a
nonempty value, then an empty one. It'll be easier to trigger this bug
after this commit, but the problem is not on mplayer2 side. The fix is
trivial so hopefully there will be a fixed libass soon.
This commit is contained in:
Uoti Urpala 2011-07-23 05:13:25 +03:00
parent 91d6bca695
commit 99d9e56e27
5 changed files with 5 additions and 5 deletions

View File

@ -710,7 +710,7 @@ const m_option_t common_opts[] = {
{"noass-use-margins", &ass_use_margins, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"embeddedfonts", &use_embedded_fonts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"noembeddedfonts", &use_embedded_fonts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"ass-force-style", &ass_force_style_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
OPT_STRINGLIST("ass-force-style", ass_force_style_list, 0),
{"ass-color", &ass_color, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"ass-border-color", &ass_border_color, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"ass-styles", &ass_styles_file, CONF_TYPE_STRING, 0, 0, 0, NULL},

View File

@ -4230,7 +4230,9 @@ while (opts->player_idle_mode && !mpctx->filename) {
}
}
//---------------------------------------------------------------------------
#ifdef CONFIG_ASS
ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list);
#endif
if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
vo_control(mpctx->video_out, VOCTRL_RESUME, NULL);

View File

@ -91,6 +91,7 @@ typedef struct MPOpts {
char **sub_paths;
int sub_auto;
int ass_enabled;
char **ass_force_style_list;
struct lavc_param {
int workaround_bugs;
int error_resilience;

View File

@ -46,7 +46,6 @@ float ass_line_spacing = 0.;
int ass_top_margin = 0;
int ass_bottom_margin = 0;
int use_embedded_fonts = 1;
char **ass_force_style_list = NULL;
int ass_use_margins = 0;
char *ass_color = NULL;
char *ass_border_color = NULL;
@ -313,7 +312,6 @@ ASS_Library *mp_ass_init(void)
ass_set_message_cb(priv, message_callback, NULL);
ass_set_fonts_dir(priv, path);
ass_set_extract_fonts(priv, use_embedded_fonts);
ass_set_style_overrides(priv, ass_force_style_list);
free(path);
return priv;
}

View File

@ -36,7 +36,6 @@ extern float ass_line_spacing;
extern int ass_top_margin;
extern int ass_bottom_margin;
extern int use_embedded_fonts;
extern char **ass_force_style_list;
extern int ass_use_margins;
extern char *ass_color;
extern char *ass_border_color;