summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-08 20:49:33 +0100
committerwm4 <wm4@nowhere>2016-03-08 21:59:55 +0100
commitf5bfe01932b2895ad9b9faa8c04d8a1466dbeeb0 (patch)
treec29722a35a9b444b7677a0d8aa968979123736d8 /sub
parent87ae215853d3e5c6d691803907d3827b3ee88a06 (diff)
downloadmpv-f5bfe01932b2895ad9b9faa8c04d8a1466dbeeb0.tar.bz2
mpv-f5bfe01932b2895ad9b9faa8c04d8a1466dbeeb0.tar.xz
osd: refactor how mp_ass_render_frame() is called
Instead of passing an explicit cache to the function, the res parameter is used. Also, instead of replacing its contents, sub bitmaps are now appended to it (all assuming the format doesn't actually change). This is preparation for the following commits.
Diffstat (limited to 'sub')
-rw-r--r--sub/ass_mp.c7
-rw-r--r--sub/ass_mp.h2
-rw-r--r--sub/dec_sub.c2
-rw-r--r--sub/osd_libass.c11
-rw-r--r--sub/osd_state.h2
-rw-r--r--sub/sd_ass.c14
6 files changed, 22 insertions, 16 deletions
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index 8d40b5256a..93a797e036 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
+#include <assert.h>
#include <ass/ass.h>
#include <ass/ass_types.h>
@@ -96,16 +97,15 @@ void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts,
}
void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time,
- struct sub_bitmap **parts, struct sub_bitmaps *res)
+ struct sub_bitmaps *res)
{
int changed;
ASS_Image *imgs = ass_render_frame(renderer, track, time, &changed);
if (changed)
res->change_id++;
+ assert(res->format == 0 || res->format == SUBBITMAP_LIBASS);
res->format = SUBBITMAP_LIBASS;
- res->parts = *parts;
- res->num_parts = 0;
int num_parts_alloc = MP_TALLOC_AVAIL(res->parts);
for (struct ass_image *img = imgs; img; img = img->next) {
if (img->w == 0 || img->h == 0)
@@ -125,7 +125,6 @@ void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time,
p->y = img->dst_y;
res->num_parts++;
}
- *parts = res->parts;
}
static const int map_ass_level[] = {
diff --git a/sub/ass_mp.h b/sub/ass_mp.h
index 789a53acb1..b4cae24ddc 100644
--- a/sub/ass_mp.h
+++ b/sub/ass_mp.h
@@ -55,7 +55,7 @@ ASS_Library *mp_ass_init(struct mpv_global *global, struct mp_log *log);
struct sub_bitmap;
struct sub_bitmaps;
void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time,
- struct sub_bitmap **parts, struct sub_bitmaps *res);
+ struct sub_bitmaps *res);
#endif /* HAVE_LIBASS */
#endif /* MPLAYER_ASS_MP_H */
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index be55fc0906..b6672348a5 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -252,8 +252,6 @@ void sub_get_bitmaps(struct dec_sub *sub, struct mp_osd_res dim, double pts,
{
struct MPOpts *opts = sub->opts;
- *res = (struct sub_bitmaps) {0};
-
sub->last_vo_pts = pts;
update_segment(sub);
diff --git a/sub/osd_libass.c b/sub/osd_libass.c
index cd28396746..36fe6ca7d6 100644
--- a/sub/osd_libass.c
+++ b/sub/osd_libass.c
@@ -77,6 +77,7 @@ void osd_destroy_backend(struct osd_state *osd)
if (obj->osd_ass_library)
ass_library_done(obj->osd_ass_library);
obj->osd_ass_library = NULL;
+ talloc_free(obj->parts_cache.parts);
}
}
@@ -467,13 +468,15 @@ void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj,
if (obj->force_redraw)
update_object(osd, obj);
- *out_imgs = (struct sub_bitmaps) {0};
if (!obj->osd_track)
return;
+ obj->parts_cache.change_id = 0;
+ obj->parts_cache.num_parts = 0;
+
ass_set_frame_size(obj->osd_render, obj->vo_res.w, obj->vo_res.h);
ass_set_aspect_ratio(obj->osd_render, obj->vo_res.display_par, 1.0);
- mp_ass_render_frame(obj->osd_render, obj->osd_track, 0,
- &obj->parts_cache, out_imgs);
- talloc_steal(obj, obj->parts_cache);
+ mp_ass_render_frame(obj->osd_render, obj->osd_track, 0, &obj->parts_cache);
+
+ *out_imgs = obj->parts_cache;
}
diff --git a/sub/osd_state.h b/sub/osd_state.h
index 30f04d8449..9ef8458f0d 100644
--- a/sub/osd_state.h
+++ b/sub/osd_state.h
@@ -37,7 +37,7 @@ struct osd_object {
struct mp_osd_res vo_res;
// Internally used by osd_libass.c
- struct sub_bitmap *parts_cache;
+ struct sub_bitmaps parts_cache;
struct ass_track *osd_track;
struct ass_renderer *osd_render;
struct ass_library *osd_ass_library;
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 23f0c882f8..788b78f3a4 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -44,7 +44,7 @@ struct sd_ass_priv {
bool is_converted;
struct lavc_conv *converter;
bool on_top;
- struct sub_bitmap *parts;
+ struct sub_bitmaps part_cache;
char last_text[500];
struct mp_image_params video_params;
struct mp_image_params last_params;
@@ -454,13 +454,19 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res dim, double pts,
ctx->num_seen_packets = 0;
sd->preload_ok = false;
}
+
if (no_ass)
fill_plaintext(sd, pts);
- mp_ass_render_frame(renderer, track, ts, &ctx->parts, res);
- talloc_steal(ctx, ctx->parts);
+
+ 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);
if (!converted)
- mangle_colors(sd, res);
+ mangle_colors(sd, &ctx->part_cache);
+
+ *res = ctx->part_cache;
}
struct buf {