summaryrefslogtreecommitdiffstats
path: root/sub/sd_ass.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-28 21:38:52 +0200
committerwm4 <wm4@nowhere>2012-10-16 07:26:30 +0200
commit3365514951e9c07ec3a21bb3898e5796c214f8b7 (patch)
tree168eec4a47cbd32fa6e6485a884203e350ba8474 /sub/sd_ass.c
parent3099498154a06c6df0c365de2cc0af09686cd6e1 (diff)
downloadmpv-3365514951e9c07ec3a21bb3898e5796c214f8b7.tar.bz2
mpv-3365514951e9c07ec3a21bb3898e5796c214f8b7.tar.xz
sub: allow rendering OSD in ASS image format directly, simplify
Before this commit, the OSD was drawn using libass, but the resulting bitmaps were converted to the internal mplayer OSD format. We want to get rid of the old OSD format, because it's monochrome, and can't even be rendered directly using modern video output methods (like with OpenGL/Direct3D/VDPAU). Change it so that VOs can get the ASS images directly, without additional conversions. (This also has the consequence that the OSD can render colors now.) Currently, this is vo_gl3 only. The other VOs still use the old method. Also, the old OSD format is still used for all VOs with DVD subtitles (spudec). Rewrite sub.c. Remove all the awkward flags and bounding boxes and change detection things. It turns out that much of that isn't needed. Move code related to converting subtitle images to img_convert.c. (It has to be noted that all of these conversions were already done before in some places, and that the new code actually makes less use of them.)
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r--sub/sd_ass.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index aa190ee4ac..478b1c96a9 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -141,39 +141,9 @@ static void get_bitmaps(struct sh_sub *sh, struct osd_state *osd,
ASS_Renderer *renderer = osd->ass_renderer;
mp_ass_configure(renderer, opts, &osd->dim, osd->unscaled);
ass_set_aspect_ratio(renderer, scale, 1);
- int changed;
- res->imgs = ass_render_frame(renderer, ctx->ass_track,
- osd->sub_pts * 1000 + .5, &changed);
- if (changed == 2)
- res->bitmap_id = ++res->bitmap_pos_id;
- else if (changed)
- res->bitmap_pos_id++;
- res->format = SUBBITMAP_LIBASS;
-
- int num_parts = 0;
- int num_parts_alloc = MP_TALLOC_ELEMS(ctx->parts);
- struct ass_image *img = res->imgs;
- while (img) {
- if (img->w == 0 || img->h == 0)
- continue;
- if (num_parts >= num_parts_alloc) {
- num_parts_alloc = FFMAX(num_parts_alloc * 2, 32);
- ctx->parts = talloc_realloc(ctx, ctx->parts, struct sub_bitmap,
- num_parts_alloc);
- }
- struct sub_bitmap *p = &ctx->parts[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;
- img = img->next;
- num_parts++;
- }
- res->parts = ctx->parts;
- res->num_parts = num_parts;
+ mp_ass_render_frame(renderer, ctx->ass_track, osd->sub_pts * 1000 + .5,
+ &ctx->parts, res);
+ talloc_steal(ctx, ctx->parts);
}
static void reset(struct sh_sub *sh, struct osd_state *osd)