diff options
author | wm4 <wm4@nowhere> | 2012-11-01 02:12:47 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-11-01 02:12:47 +0100 |
commit | 84829a4ea1903e5db5782b72861fabc503a589cb (patch) | |
tree | 26b4acbaf6dd4b255278dcc67f28bd83357c3b86 /sub/ass_mp.c | |
parent | e45dd051c304dec189d0d4d792a89c2988c3fa71 (diff) | |
parent | f4069259cf7ffd24ac2a5b64e26a386185e94c7b (diff) | |
download | mpv-84829a4ea1903e5db5782b72861fabc503a589cb.tar.bz2 mpv-84829a4ea1903e5db5782b72861fabc503a589cb.tar.xz |
Merge branch 'osd_changes' into master
Conflicts:
DOCS/man/en/options.rst
Diffstat (limited to 'sub/ass_mp.c')
-rw-r--r-- | sub/ass_mp.c | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 908a552acf..1867880f38 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -61,17 +61,6 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts) style->treat_fontname_as_pattern = 1; double fs = track->PlayResY * text_font_scale_factor / 100.; - /* The font size is always proportional to video height only; - * real -subfont-autoscale behavior is not implemented. - * Apply a correction that corresponds to about 4:3 aspect ratio - * video to get a size somewhat closer to what non-libass rendering - * would produce with the same text_font_scale_factor - * and subtitle_autoscale. - */ - if (subtitle_autoscale == 2) - fs *= 1.3; - else if (subtitle_autoscale == 3) - fs *= 1.7; uint32_t c1 = 0xFFFFFF00; uint32_t c2 = 0x00000000; @@ -228,7 +217,7 @@ ASS_Track *mp_ass_read_stream(ASS_Library *library, const char *fname, } void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, - struct mp_eosd_res *dim, bool unscaled) + 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); @@ -243,10 +232,7 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, set_sub_pos = 100 - sub_pos; set_line_spacing = opts->ass_line_spacing; set_font_scale = opts->ass_font_scale; - if (!unscaled && (opts->ass_hinting & 4)) - set_hinting = 0; - else - set_hinting = opts->ass_hinting & 3; + set_hinting = opts->ass_hinting & 3; // +4 was for no hinting if scaled } ass_set_use_margins(priv, set_use_margins); @@ -281,6 +267,41 @@ void mp_ass_configure_fonts(ASS_Renderer *priv) free(family); } +void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time, + struct sub_bitmap **parts, struct sub_bitmaps *res) +{ + int changed; + ASS_Image *imgs = ass_render_frame(renderer, track, time, &changed); + if (changed == 2) + res->bitmap_id = ++res->bitmap_pos_id; + else if (changed) + res->bitmap_pos_id++; + res->format = SUBBITMAP_LIBASS; + + res->parts = *parts; + res->num_parts = 0; + int num_parts_alloc = MP_TALLOC_ELEMS(res->parts); + for (struct ass_image *img = imgs; img; img = img->next) { + if (img->w == 0 || img->h == 0) + continue; + if (res->num_parts >= num_parts_alloc) { + num_parts_alloc = FFMAX(num_parts_alloc * 2, 32); + res->parts = talloc_realloc(NULL, res->parts, struct sub_bitmap, + num_parts_alloc); + } + struct sub_bitmap *p = &res->parts[res->num_parts]; + p->bitmap = img->bitmap; + p->stride = img->stride; + p->libass.color = img->color; + p->dw = p->w = img->w; + p->dh = p->h = img->h; + p->x = img->dst_x; + p->y = img->dst_y; + res->num_parts++; + } + *parts = res->parts; +} + static int map_ass_level[] = { MSGL_ERR, // 0 "FATAL errors" MSGL_WARN, |