summaryrefslogtreecommitdiffstats
path: root/sub/sd_ass.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-12-29 17:19:25 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-02 14:27:37 -0800
commit6aad532aa39481a8100910612fad039dd75236b9 (patch)
tree53c790d6c66917e66039c25a13cdf27f90bbf0d9 /sub/sd_ass.c
parent3bf7df4a5e1f46248c78e9e596cd8dab6ff57356 (diff)
downloadmpv-6aad532aa39481a8100910612fad039dd75236b9.tar.bz2
mpv-6aad532aa39481a8100910612fad039dd75236b9.tar.xz
options: move most subtitle and OSD rendering options to sub structs
Remove them from the big MPOpts struct and move them to their sub structs. In the places where their fields are used, create a private copy of the structs, instead of accessing the semi-deprecated global option struct instance (mpv_global.opts) directly. This actually makes accessing these options finally thread-safe. They weren't even if they should have for years. (Including some potential for undefined behavior when e.g. the OSD font was changed at runtime.) This is mostly transparent. All options get moved around, but most users of the options just need to access a different struct (changing sd.opts to a different type changes a lot of uses, for example). One thing which has to be considered and could cause potential regressions is that the new option copies must be explicitly updated. sub_update_opts() takes care of this for example. Another thing is that writing to the option structs manually won't work, because the changes won't be propagated to other copies. Apparently the only affected case is the implementation of the sub-step command, which tries to change sub_delay. Handle this one explicitly (osd_changed() doesn't need to be called anymore, because changing the option triggers UPDATE_OSD, and updates the OSD as a consequence). The way the option value is propagated is rather hacky, but for now this will do.
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r--sub/sd_ass.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 74d500be8d..1cecfe3215 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -59,7 +59,7 @@ static void fill_plaintext(struct sd *sd, double pts);
// Add default styles, if the track does not have any styles yet.
// Apply style overrides if the user provides any.
-static void mp_ass_add_default_styles(ASS_Track *track, struct MPOpts *opts)
+static void mp_ass_add_default_styles(ASS_Track *track, struct mp_subtitle_opts *opts)
{
if (opts->ass_styles_file && opts->ass_style_override)
ass_read_styles(track, opts->ass_styles_file, NULL);
@@ -120,7 +120,7 @@ static bool attachment_is_font(struct mp_log *log, struct demux_attachment *f)
static void add_subtitle_fonts(struct sd *sd)
{
struct sd_ass_priv *ctx = sd->priv;
- struct MPOpts *opts = sd->opts;
+ struct mp_subtitle_opts *opts = sd->opts;
if (!opts->ass_enabled || !opts->use_embedded_fonts || !sd->attachments)
return;
for (int i = 0; i < sd->attachments->num_entries; i++) {
@@ -148,7 +148,7 @@ static void enable_output(struct sd *sd, bool enable)
static int init(struct sd *sd)
{
- struct MPOpts *opts = sd->opts;
+ struct mp_subtitle_opts *opts = sd->opts;
struct sd_ass_priv *ctx = talloc_zero(sd, struct sd_ass_priv);
sd->priv = ctx;
@@ -169,6 +169,7 @@ static int init(struct sd *sd)
}
ctx->ass_library = mp_ass_init(sd->global, sd->log);
+ ass_set_extract_fonts(ctx->ass_library, opts->use_embedded_fonts);
add_subtitle_fonts(sd);
@@ -279,7 +280,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
bool converted, ASS_Track *track)
{
- struct MPOpts *opts = sd->opts;
+ struct mp_subtitle_opts *opts = sd->opts;
struct sd_ass_priv *ctx = sd->priv;
ASS_Renderer *priv = ctx->ass_renderer;
@@ -428,7 +429,7 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res dim, int format,
double pts, struct sub_bitmaps *res)
{
struct sd_ass_priv *ctx = sd->priv;
- struct MPOpts *opts = sd->opts;
+ struct mp_subtitle_opts *opts = sd->opts;
bool no_ass = !opts->ass_enabled || ctx->on_top ||
opts->ass_style_override == 5;
bool converted = ctx->is_converted || no_ass;
@@ -689,7 +690,7 @@ const struct sd_functions sd_ass = {
// Disgusting hack for (xy-)vsfilter color compatibility.
static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts)
{
- struct MPOpts *opts = sd->opts;
+ struct mp_subtitle_opts *opts = sd->opts;
struct sd_ass_priv *ctx = sd->priv;
enum mp_csp csp = 0;
enum mp_csp_levels levels = 0;