mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
player: remove OSD subtitle render path
This was used with --no-sub-ass (aka --no-ass). This option (which is not yet removed) strips all styling from the subtitles, and renders them as plaintext only. For some reason, it originally seemed convenient to reuse all the OSD text rendering code (osd_libass.c). While this was indeed simple, it had a bad influence on the rest of the code. For example, it had to decide whether to go through the OSD code path, or the proper subtitle renderer in sd_ass.c. Kill the OSD subtitle renderer. Reimplement --no-sub-ass and also "secondary" subtitles in sd_ass.c. fill_plaintext() contains some rather minor code duplication with osd_libass.c for setting up a dummy ASS_Event and escaping the stripped text. Since sd_ass.c already has to handle "normal" text subtitles, and has code for stripping ASS tags, this remains all relatively simple. Remove all the unnecessary crap from the rest of the code.
This commit is contained in:
@@ -423,42 +423,12 @@ static void update_external(struct osd_state *osd, struct osd_object *obj)
|
||||
}
|
||||
}
|
||||
|
||||
static void update_sub(struct osd_state *osd, struct osd_object *obj)
|
||||
{
|
||||
struct MPOpts *opts = osd->opts;
|
||||
|
||||
clear_obj(obj);
|
||||
|
||||
if (!obj->text || !obj->text[0] || obj->sub_state.render_bitmap_subs)
|
||||
return;
|
||||
|
||||
create_ass_renderer(osd, obj);
|
||||
if (!obj->osd_track)
|
||||
obj->osd_track = mp_ass_default_track(obj->osd_ass_library, osd->opts);
|
||||
|
||||
struct osd_style_opts font = *opts->sub_text_style;
|
||||
font.font_size *= opts->sub_scale;
|
||||
|
||||
ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style;
|
||||
mp_ass_set_style(style, obj->osd_track->PlayResY, &font);
|
||||
if (obj->type == OSDTYPE_SUB2)
|
||||
style->Alignment = 6;
|
||||
|
||||
ass_set_line_position(obj->osd_render, 100 - opts->sub_pos);
|
||||
|
||||
add_osd_ass_event_escaped(obj->osd_track, obj->text);
|
||||
}
|
||||
|
||||
static void update_object(struct osd_state *osd, struct osd_object *obj)
|
||||
{
|
||||
switch (obj->type) {
|
||||
case OSDTYPE_OSD:
|
||||
update_osd(osd, obj);
|
||||
break;
|
||||
case OSDTYPE_SUB:
|
||||
case OSDTYPE_SUB2:
|
||||
update_sub(osd, obj);
|
||||
break;
|
||||
case OSDTYPE_PROGBAR:
|
||||
update_progbar(osd, obj);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user