diff options
author | wm4 <wm4@nowhere> | 2013-04-28 21:12:11 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-05-30 22:20:02 +0200 |
commit | b44202b69fc4a1dd1659f7940c5f8846d316e0ff (patch) | |
tree | cba363991fc52000ec3f02b9ade2d94e56af873e /sub/sub.c | |
parent | f7ad81c0f5905637c16480b2e44dd41f2839293a (diff) | |
download | mpv-b44202b69fc4a1dd1659f7940c5f8846d316e0ff.tar.bz2 mpv-b44202b69fc4a1dd1659f7940c5f8846d316e0ff.tar.xz |
sub: redo how -no-ass is handled
The -no-ass switch used to disable any use of libass for text subtitles.
This is not really the case anymore, because libass is now always
involved when rendering text. The only remaining use of -no-ass is
disabling styling or showing subtitles on the terminal. On the other
hand, the old subtitle rendering path is a big reason why the subtitle
code is still a big mess with an awful number of obscure special cases.
In order to simplify it, remove the old subtitle rendering code, and
always go through sd_ass.c. Basically, we use ASS_Track as central data
structure for storing text subtitles instead of struct sub_data. This
also makes libass mandatory for all text subs, even if they are printed
to the terminal in -no-video mode. (We could add something like sd_text
to avoid this, but it's not worth the trouble.)
struct sub_data and subreader.c are still around, even its ASS/SSA
reader. But struct sub_data is freed right after converting it to
ASS_Track. The internal ASS reader actually can handle some obscure
cases libass can't, like files encoded in UTF-16.
Diffstat (limited to 'sub/sub.c')
-rw-r--r-- | sub/sub.c | 39 |
1 files changed, 26 insertions, 13 deletions
@@ -45,8 +45,6 @@ int sub_pos=100; int sub_visibility=1; -subtitle* vo_sub=NULL; - float sub_delay = 0; float sub_fps = 0; @@ -103,6 +101,7 @@ struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib) .opts = opts, .ass_library = asslib, .osd_text = talloc_strdup(osd, ""), + .sub_text = talloc_strdup(osd, ""), .progbar_type = -1, }; @@ -117,7 +116,7 @@ struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib) osd->objs[OSDTYPE_SPU]->is_sub = true; // spudec.c osd->objs[OSDTYPE_SUB]->is_sub = true; // dec_sub.c - osd->objs[OSDTYPE_SUBTITLE]->is_sub = true; // osd_libass.c + osd->objs[OSDTYPE_SUBTEXT]->is_sub = true; // osd_libass.c osd_init_backend(osd); global_osd = osd; @@ -133,15 +132,27 @@ void osd_free(struct osd_state *osd) global_osd = NULL; } -void osd_set_text(struct osd_state *osd, const char *text) +static bool set_text(void *talloc_ctx, char **var, const char *text) { if (!text) text = ""; - if (strcmp(osd->osd_text, text) == 0) - return; - talloc_free(osd->osd_text); - osd->osd_text = talloc_strdup(osd, text); - vo_osd_changed(OSDTYPE_OSD); + if (strcmp(*var, text) == 0) + return true; + talloc_free(*var); + *var = talloc_strdup(talloc_ctx, text); + return false; +} + +void osd_set_text(struct osd_state *osd, const char *text) +{ + if (!set_text(osd, &osd->osd_text, text)) + vo_osd_changed(OSDTYPE_OSD); +} + +void osd_set_sub(struct osd_state *osd, const char *text) +{ + if (!set_text(osd, &osd->sub_text, text)) + vo_osd_changed(OSDTYPE_SUBTEXT); } static bool spu_visible(struct osd_state *osd, struct osd_object *obj) @@ -172,10 +183,12 @@ static void render_object(struct osd_state *osd, struct osd_object *obj, if (spu_visible(osd, obj)) spudec_get_indexed(vo_spudec, &obj->vo_res, out_imgs); } else if (obj->type == OSDTYPE_SUB) { - double sub_pts = video_pts; - if (sub_pts != MP_NOPTS_VALUE) - sub_pts += sub_delay - osd->sub_offset; - sub_get_bitmaps(osd, obj->vo_res, sub_pts, out_imgs); + if (osd->render_bitmap_subs) { + double sub_pts = video_pts; + if (sub_pts != MP_NOPTS_VALUE) + sub_pts -= osd->sub_offset; + sub_get_bitmaps(osd, obj->vo_res, sub_pts, out_imgs); + } } else { osd_object_get_bitmaps(osd, obj, out_imgs); } |