diff options
-rw-r--r-- | sub/ass_mp.c | 57 | ||||
-rw-r--r-- | sub/ass_mp.h | 3 | ||||
-rw-r--r-- | sub/sd_ass.c | 57 |
3 files changed, 57 insertions, 60 deletions
diff --git a/sub/ass_mp.c b/sub/ass_mp.c index be8afe374d..9ec86e9dd8 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -113,63 +113,6 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts) return track; } -void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, bool is_ass, - struct mp_osd_res *dim) -{ - ass_set_frame_size(priv, dim->w, dim->h); - ass_set_margins(priv, dim->mt, dim->mb, dim->ml, dim->mr); - - bool set_use_margins = false; - int set_sub_pos = 0; - float set_line_spacing = 0; - float set_font_scale = 1; - int set_hinting = 0; - bool set_scale_with_window = false; - bool set_scale_by_window = true; - bool total_override = false; - // With forced overrides, apply the --sub-* specific options - if (!is_ass || opts->ass_style_override == 3) { - set_scale_with_window = opts->sub_scale_with_window; - set_use_margins = opts->sub_use_margins; - set_scale_by_window = opts->sub_scale_by_window; - total_override = true; - } else { - set_scale_with_window = opts->ass_scale_with_window; - set_use_margins = opts->ass_use_margins; - } - if (!is_ass || opts->ass_style_override) { - set_sub_pos = 100 - opts->sub_pos; - set_line_spacing = opts->ass_line_spacing; - set_hinting = opts->ass_hinting; - set_font_scale = opts->sub_scale; - } - if (set_scale_with_window) { - int vidh = dim->h - (dim->mt + dim->mb); - set_font_scale *= dim->h / (float)MPMAX(vidh, 1); - } - if (!set_scale_by_window) { - double factor = dim->h / 720.0; - if (factor != 0.0) - set_font_scale /= factor; - } - ass_set_use_margins(priv, set_use_margins); - ass_set_line_position(priv, set_sub_pos); - ass_set_shaper(priv, opts->ass_shaper); - int set_force_flags = 0; - if (total_override) - set_force_flags |= ASS_OVERRIDE_BIT_STYLE | ASS_OVERRIDE_BIT_FONT_SIZE; - if (opts->ass_style_override == 4) - set_force_flags |= ASS_OVERRIDE_BIT_FONT_SIZE; - ass_set_selective_style_override_enabled(priv, set_force_flags); - ASS_Style style = {0}; - mp_ass_set_style(&style, 288, opts->sub_text_style); - ass_set_selective_style_override(priv, &style); - free(style.FontName); - ass_set_font_scale(priv, set_font_scale); - ass_set_hinting(priv, set_hinting); - ass_set_line_spacing(priv, set_line_spacing); -} - void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts, struct mpv_global *global, struct mp_log *log) { diff --git a/sub/ass_mp.h b/sub/ass_mp.h index 4e5cc88554..ac0dc26803 100644 --- a/sub/ass_mp.h +++ b/sub/ass_mp.h @@ -52,9 +52,6 @@ void mp_ass_add_default_styles(ASS_Track *track, struct MPOpts *opts); ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts); -struct MPOpts; -void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, bool is_ass, - struct mp_osd_res *dim); void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts, struct mpv_global *global, struct mp_log *log); ASS_Library *mp_ass_init(struct mpv_global *global, struct mp_log *log); diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 2ccfb5fc23..0a82b21aa4 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -124,6 +124,63 @@ static void decode(struct sd *sd, struct demux_packet *packet) event->Text = strdup(text); } +static void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, bool is_ass, + struct mp_osd_res *dim) +{ + ass_set_frame_size(priv, dim->w, dim->h); + ass_set_margins(priv, dim->mt, dim->mb, dim->ml, dim->mr); + + bool set_use_margins = false; + int set_sub_pos = 0; + float set_line_spacing = 0; + float set_font_scale = 1; + int set_hinting = 0; + bool set_scale_with_window = false; + bool set_scale_by_window = true; + bool total_override = false; + // With forced overrides, apply the --sub-* specific options + if (!is_ass || opts->ass_style_override == 3) { + set_scale_with_window = opts->sub_scale_with_window; + set_use_margins = opts->sub_use_margins; + set_scale_by_window = opts->sub_scale_by_window; + total_override = true; + } else { + set_scale_with_window = opts->ass_scale_with_window; + set_use_margins = opts->ass_use_margins; + } + if (!is_ass || opts->ass_style_override) { + set_sub_pos = 100 - opts->sub_pos; + set_line_spacing = opts->ass_line_spacing; + set_hinting = opts->ass_hinting; + set_font_scale = opts->sub_scale; + } + if (set_scale_with_window) { + int vidh = dim->h - (dim->mt + dim->mb); + set_font_scale *= dim->h / (float)MPMAX(vidh, 1); + } + if (!set_scale_by_window) { + double factor = dim->h / 720.0; + if (factor != 0.0) + set_font_scale /= factor; + } + ass_set_use_margins(priv, set_use_margins); + ass_set_line_position(priv, set_sub_pos); + ass_set_shaper(priv, opts->ass_shaper); + int set_force_flags = 0; + if (total_override) + set_force_flags |= ASS_OVERRIDE_BIT_STYLE | ASS_OVERRIDE_BIT_FONT_SIZE; + if (opts->ass_style_override == 4) + set_force_flags |= ASS_OVERRIDE_BIT_FONT_SIZE; + ass_set_selective_style_override_enabled(priv, set_force_flags); + ASS_Style style = {0}; + mp_ass_set_style(&style, 288, opts->sub_text_style); + ass_set_selective_style_override(priv, &style); + free(style.FontName); + ass_set_font_scale(priv, set_font_scale); + ass_set_hinting(priv, set_hinting); + ass_set_line_spacing(priv, set_line_spacing); +} + static void get_bitmaps(struct sd *sd, struct mp_osd_res dim, double pts, struct sub_bitmaps *res) { |