summaryrefslogtreecommitdiffstats
path: root/libvo
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 /libvo
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 'libvo')
-rw-r--r--libvo/eosd_packer.c13
-rw-r--r--libvo/eosd_packer.h2
-rw-r--r--libvo/vo_vdpau.c9
3 files changed, 16 insertions, 8 deletions
diff --git a/libvo/eosd_packer.c b/libvo/eosd_packer.c
index 103648b7c4..8f831d512e 100644
--- a/libvo/eosd_packer.c
+++ b/libvo/eosd_packer.c
@@ -147,17 +147,18 @@ void eosd_packer_generate(struct eosd_packer *state, mp_eosd_images_t *imgs,
ASS_Image *p;
struct eosd_surface *sfc = &state->surface;
- *out_need_reposition = false;
- *out_need_upload = false;
+ *out_need_reposition = imgs->bitmap_pos_id != state->last_bitmap_pos_id;
+ *out_need_upload = imgs->bitmap_id != state->last_bitmap_id;
*out_need_reallocate = false;
- int change_state = imgs->changed;
+ state->last_bitmap_pos_id = imgs->bitmap_pos_id;
+ state->last_bitmap_id = imgs->bitmap_id;
// eosd_reinit() was probably called, force full reupload.
if (state->targets_count == 0 && img)
- change_state = 2;
+ *out_need_upload = true;
- if (change_state == 0)
+ if (!(*out_need_reposition) && !(*out_need_upload))
return; // Nothing changed, no need to redraw
state->targets_count = 0;
@@ -167,7 +168,7 @@ void eosd_packer_generate(struct eosd_packer *state, mp_eosd_images_t *imgs,
if (!img)
return; // There's nothing to render!
- if (change_state == 1)
+ if (!(*out_need_upload))
goto eosd_skip_upload;
*out_need_upload = true;
diff --git a/libvo/eosd_packer.h b/libvo/eosd_packer.h
index eaacd0223f..228057d3c4 100644
--- a/libvo/eosd_packer.h
+++ b/libvo/eosd_packer.h
@@ -58,6 +58,8 @@ struct eosd_packer {
uint32_t max_surface_height;
int *scratch;
+ int last_bitmap_id;
+ int last_bitmap_pos_id;
};
struct eosd_packer *eosd_packer_create(void *talloc_ctx);
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index d9b59c7dbe..922ec24201 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -186,6 +186,8 @@ struct vdpctx {
} *eosd_targets, osd_targets[MAX_OLD_OSD_BITMAPS][2];
int eosd_targets_size;
int eosd_render_count;
+ int bitmap_id;
+ int bitmap_pos_id;
// Video equalizer
struct mp_csp_equalizer video_eq;
@@ -812,6 +814,7 @@ static void mark_vdpau_objects_uninitialized(struct vo *vo)
vc->vdp_device = VDP_INVALID_HANDLE;
talloc_free(vc->osd_surface.packer);
talloc_free(vc->eosd_surface.packer);
+ vc->bitmap_id = vc->bitmap_pos_id = 0;
vc->osd_surface = vc->eosd_surface = (struct eosd_bitmap_surface){
.surface = VDP_INVALID_HANDLE,
};
@@ -999,7 +1002,7 @@ static void generate_eosd(struct vo *vo, mp_eosd_images_t *imgs)
struct eosd_bitmap_surface *sfc = &vc->eosd_surface;
bool need_upload = false;
- if (imgs->changed == 0 && sfc->packer)
+ if (imgs->bitmap_pos_id == vc->bitmap_pos_id)
return; // Nothing changed and we still have the old data
vc->eosd_render_count = 0;
@@ -1007,7 +1010,7 @@ static void generate_eosd(struct vo *vo, mp_eosd_images_t *imgs)
if (!imgs->imgs)
return; // There's nothing to render!
- if (imgs->changed == 1)
+ if (imgs->bitmap_id == vc->bitmap_id)
goto eosd_skip_upload;
need_upload = true;
@@ -1069,6 +1072,8 @@ eosd_skip_upload:
target->dest.y1 = p->h + p->dst_y;
vc->eosd_render_count++;
}
+ vc->bitmap_id = imgs->bitmap_id;
+ vc->bitmap_pos_id = imgs->bitmap_pos_id;
}
static void record_osd(void *ctx, int x0, int y0, int w, int h,