diff options
author | wm4 <wm4@nowhere> | 2016-06-30 21:38:50 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-06-30 21:38:50 +0200 |
commit | c57304a591d46df490e1584b1a3c9cda1ff91b44 (patch) | |
tree | d64734c8782bbd1b0a8be01b9c2b4a90df39899d /sub/sd_ass.c | |
parent | 2d6da37b6b4acfd31487e59e788e2d7b13172314 (diff) | |
download | mpv-c57304a591d46df490e1584b1a3c9cda1ff91b44.tar.bz2 mpv-c57304a591d46df490e1584b1a3c9cda1ff91b44.tar.xz |
sub: pack libass bitmaps directly in sd_ass.c and osd_libass.c
Change all producer of libass images to packing the bitmaps into a
single larger bitmap directly when they're output. This is supposed to
help working towards refcounted sub bitmaps.
This will reduce performance for VOs like vo_xv, but not for vo_opengl.
vo_opengl simply will pick up the pre-packed sub bitmaps, and skip
packing them again. vo_xv will copy and pack the sub bitmaps
unnecessarily - but if we want sub bitmap refcounting, they'd have to be
copied anyway.
The packing code cannot be removed yet from vo_opengl, because there are
certain corner cases that still produce unpackad other sub bitmaps.
Actual refcounting will also require more work.
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r-- | sub/sd_ass.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 6f35053370..879d528fb7 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -44,7 +44,8 @@ struct sd_ass_priv { bool is_converted; struct lavc_conv *converter; bool on_top; - struct sub_bitmaps part_cache; + struct mp_ass_packer *packer; + struct sub_bitmap *bs; char last_text[500]; struct mp_image_params video_params; struct mp_image_params last_params; @@ -212,6 +213,8 @@ static int init(struct sd *sd) enable_output(sd, true); + ctx->packer = mp_ass_packer_alloc(ctx); + return 0; } @@ -459,15 +462,18 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res dim, double pts, if (no_ass) fill_plaintext(sd, pts); - ctx->part_cache.change_id = 0; - ctx->part_cache.num_parts = 0; - mp_ass_render_frame(renderer, track, ts, &ctx->part_cache); - talloc_steal(ctx, ctx->part_cache.parts); + int changed; + ASS_Image *imgs = ass_render_frame(renderer, track, ts, &changed); + mp_ass_packer_pack(ctx->packer, &imgs, 1, changed, SUBBITMAP_LIBASS, res); - if (!converted) - mangle_colors(sd, &ctx->part_cache); + if (!converted && res->num_parts > 0) { + // mangle_colors() modifies the color field, so copy the thing. + MP_TARRAY_GROW(ctx, ctx->bs, res->num_parts); + memcpy(ctx->bs, res->parts, sizeof(ctx->bs[0]) * res->num_parts); + res->parts = ctx->bs; - *res = ctx->part_cache; + mangle_colors(sd, res); + } } struct buf { |