summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-08-28 19:12:27 +0300
committerwm4 <wm4@nowhere>2012-09-18 21:04:46 +0200
commitfd52cb65f43d262493724899c7b0fb49971f745d (patch)
treeae6b38171d67b26ad05aaf107fb48ab8e63ab96e /sub
parent62ccf6c5cccdf1a34a4b85f91615f0f8305b5279 (diff)
downloadmpv-fd52cb65f43d262493724899c7b0fb49971f745d.tar.bz2
mpv-fd52cb65f43d262493724899c7b0fb49971f745d.tar.xz
subs, vo: do sub bitmap change detection by comparing IDs
vo_vdpau and vo_gl cache the last subtitle bitmaps uploaded to video card in case they stay the same over multiple frames. Detecting whether the bitmaps have changed and should be re-uploaded was somewhat fragile. Change the VO API to provide a bitmap ID which can be compared with what the VO has to determine whether a new upload of the bitmaps is needed. Conflicts: libvo/vo_gl.c Note: the changes for vo_gl.c were not merged. Instead, eosd_packer is modified to use the new way of detecting EOSD changes. This takes care of vo_gl, vo_gl3 and vo_direct3d, which all render EOSD. They don't need to be updated in turn.
Diffstat (limited to 'sub')
-rw-r--r--sub/dec_sub.c19
-rw-r--r--sub/dec_sub.h2
-rw-r--r--sub/sd_ass.c7
-rw-r--r--sub/sub.h3
4 files changed, 22 insertions, 9 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index c710ff575a..3278c10d85 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -45,7 +45,7 @@ void sub_init(struct sh_sub *sh, struct osd_state *osd)
if (sh->sd_driver->init(sh, osd) < 0)
return;
osd->sh_sub = sh;
- osd->changed_outside_sd = true;
+ osd->bitmap_id = ++osd->bitmap_pos_id;
sh->initialized = true;
sh->active = true;
}
@@ -62,16 +62,23 @@ void sub_get_bitmaps(struct osd_state *osd, struct sub_bitmaps *res)
{
struct MPOpts *opts = osd->opts;
- *res = (struct sub_bitmaps){.imgs = NULL, .changed = 2};
+ *res = (struct sub_bitmaps){ .bitmap_id = osd->bitmap_id,
+ .bitmap_pos_id = osd->bitmap_pos_id };
if (!opts->sub_visibility || !osd->sh_sub || !osd->sh_sub->active) {
- osd->changed_outside_sd = true;
+ /* Change ID in case we just switched from visible subtitles
+ * to current state. Hopefully, unnecessarily claiming that
+ * things may have changed is harmless for empty contents.
+ * Increase osd-> values ahead so that _next_ returned id
+ * is also guaranteed to differ from this one.
+ */
+ res->bitmap_id = ++res->bitmap_pos_id;
+ osd->bitmap_id = osd->bitmap_pos_id += 2;
return;
}
if (osd->sh_sub->sd_driver->get_bitmaps)
osd->sh_sub->sd_driver->get_bitmaps(osd->sh_sub, osd, res);
- if (osd->changed_outside_sd)
- res->changed = 2;
- osd->changed_outside_sd = false;
+ osd->bitmap_id = res->bitmap_id;
+ osd->bitmap_pos_id = res->bitmap_pos_id;
}
void sub_reset(struct sh_sub *sh, struct osd_state *osd)
diff --git a/sub/dec_sub.h b/sub/dec_sub.h
index f09b555685..ae39f15f31 100644
--- a/sub/dec_sub.h
+++ b/sub/dec_sub.h
@@ -12,7 +12,7 @@ typedef struct mp_eosd_res {
typedef struct sub_bitmaps {
struct ass_image *imgs;
- int changed;
+ int bitmap_id, bitmap_pos_id;
} mp_eosd_images_t;
static inline bool is_text_sub(int type)
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 72dee06018..67bbd4665e 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -140,8 +140,13 @@ 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, &res->changed);
+ osd->sub_pts * 1000 + .5, &changed);
+ if (changed == 2)
+ res->bitmap_id = ++res->bitmap_pos_id;
+ else if (changed)
+ res->bitmap_pos_id++;
}
static void reset(struct sh_sub *sh, struct osd_state *osd)
diff --git a/sub/sub.h b/sub/sub.h
index 8a8a2ab941..05c89af565 100644
--- a/sub/sub.h
+++ b/sub/sub.h
@@ -63,7 +63,8 @@ struct osd_state {
struct ass_library *ass_library;
struct ass_renderer *ass_renderer;
struct sh_sub *sh_sub;
- bool changed_outside_sd;
+ int bitmap_id;
+ int bitmap_pos_id;
double sub_pts;
double sub_offset;
struct mp_eosd_res dim;