summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/command.c2
-rw-r--r--sub/ass_mp.c6
-rw-r--r--sub/draw_bmp.c6
-rw-r--r--sub/osd.c18
-rw-r--r--sub/osd.h3
-rw-r--r--sub/osd_state.h3
-rw-r--r--sub/sd_lavc.c2
-rw-r--r--video/out/gl_osd.c13
-rw-r--r--video/out/vo_direct3d.c15
-rw-r--r--video/out/vo_sdl.c80
-rw-r--r--video/out/vo_vaapi.c6
-rw-r--r--video/out/vo_vdpau.c14
-rw-r--r--video/out/vo_wayland.c6
13 files changed, 74 insertions, 100 deletions
diff --git a/player/command.c b/player/command.c
index 7db54d6cf8..782629500d 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3931,7 +3931,7 @@ static void recreate_overlays(struct MPContext *mpctx)
if (new == cmd->overlay_osd_current)
new += 1; // pick the unused one
new->format = SUBBITMAP_RGBA;
- new->bitmap_id = new->bitmap_pos_id = 1;
+ new->change_id = 1;
// overlay array can have unused entries, but parts list must be "packed"
new->num_parts = 0;
for (int n = 0; n < cmd->num_overlays; n++) {
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index 44ce330d0e..a02ff8d632 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -134,10 +134,8 @@ void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time,
{
int changed;
ASS_Image *imgs = ass_render_frame(renderer, track, time, &changed);
- if (changed == 2)
- res->bitmap_id = ++res->bitmap_pos_id;
- else if (changed)
- res->bitmap_pos_id++;
+ if (changed)
+ res->change_id++;
res->format = SUBBITMAP_LIBASS;
res->parts = *parts;
diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c
index c5c0dddd29..d9cb0522df 100644
--- a/sub/draw_bmp.c
+++ b/sub/draw_bmp.c
@@ -43,7 +43,7 @@ struct sub_cache {
};
struct part {
- int bitmap_pos_id;
+ int change_id;
int imgfmt;
enum mp_csp colorspace;
enum mp_csp_levels levels;
@@ -399,7 +399,7 @@ static struct part *get_cache(struct mp_draw_sub_cache *cache,
if (use_cache) {
part = cache->parts[sbs->render_index];
if (part) {
- if (part->bitmap_pos_id != sbs->bitmap_pos_id
+ if (part->change_id != sbs->change_id
|| part->imgfmt != format->imgfmt
|| part->colorspace != format->params.colorspace
|| part->levels != format->params.colorlevels)
@@ -411,7 +411,7 @@ static struct part *get_cache(struct mp_draw_sub_cache *cache,
if (!part) {
part = talloc(cache, struct part);
*part = (struct part) {
- .bitmap_pos_id = sbs->bitmap_pos_id,
+ .change_id = sbs->change_id,
.num_imgs = sbs->num_parts,
.imgfmt = format->imgfmt,
.levels = format->params.colorlevels,
diff --git a/sub/osd.c b/sub/osd.c
index 3e1260d3f8..7ab191191a 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -263,7 +263,7 @@ static void render_object(struct osd_state *osd, struct osd_object *obj,
} else if (obj->type == OSDTYPE_EXTERNAL2) {
if (obj->external2 && obj->external2->format) {
*out_imgs = *obj->external2;
- obj->external2->bitmap_id = obj->external2->bitmap_pos_id = 0;
+ obj->external2->change_id = 0;
}
} else if (obj->type == OSDTYPE_NAV_HIGHLIGHT) {
if (obj->highlight_priv)
@@ -272,29 +272,23 @@ static void render_object(struct osd_state *osd, struct osd_object *obj,
osd_object_get_bitmaps(osd, obj, out_imgs);
}
- if (obj->force_redraw) {
- out_imgs->bitmap_id++;
- out_imgs->bitmap_pos_id++;
- }
+ if (obj->force_redraw)
+ out_imgs->change_id++;
obj->force_redraw = false;
- obj->vo_bitmap_id += out_imgs->bitmap_id;
- obj->vo_bitmap_pos_id += out_imgs->bitmap_pos_id;
+ obj->vo_change_id += out_imgs->change_id;
if (out_imgs->num_parts == 0)
return;
- if (obj->cached.bitmap_id == obj->vo_bitmap_id
- && obj->cached.bitmap_pos_id == obj->vo_bitmap_pos_id
- && formats[obj->cached.format])
+ if (obj->cached.change_id == obj->vo_change_id && formats[obj->cached.format])
{
*out_imgs = obj->cached;
return;
}
out_imgs->render_index = obj->type;
- out_imgs->bitmap_id = obj->vo_bitmap_id;
- out_imgs->bitmap_pos_id = obj->vo_bitmap_pos_id;
+ out_imgs->change_id = obj->vo_change_id;
if (formats[out_imgs->format])
return;
diff --git a/sub/osd.h b/sub/osd.h
index a96fc63663..704a424c4c 100644
--- a/sub/osd.h
+++ b/sub/osd.h
@@ -70,8 +70,7 @@ struct sub_bitmaps {
struct sub_bitmap *parts;
int num_parts;
- // Incremented on each change
- int bitmap_id, bitmap_pos_id;
+ int change_id; // Incremented on each change
};
struct mp_osd_res {
diff --git a/sub/osd_state.h b/sub/osd_state.h
index 01546d7c6f..73bfcdd7d3 100644
--- a/sub/osd_state.h
+++ b/sub/osd_state.h
@@ -36,8 +36,7 @@ struct osd_object {
struct sub_bitmaps cached;
// VO cache state
- int vo_bitmap_id;
- int vo_bitmap_pos_id;
+ int vo_change_id;
struct mp_osd_res vo_res;
// Internally used by osd_libass.c
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 496b47459c..228690fe27 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -256,7 +256,7 @@ static void get_bitmaps(struct sd *sd, struct mp_osd_res d, double pts,
res->parts = priv->outbitmaps;
res->num_parts = current->count;
if (priv->displayed_id != current->id)
- res->bitmap_id = ++res->bitmap_pos_id;
+ res->change_id++;
priv->displayed_id = current->id;
res->format = SUBBITMAP_INDEXED;
diff --git a/video/out/gl_osd.c b/video/out/gl_osd.c
index 74074915a2..88a7e938fb 100644
--- a/video/out/gl_osd.c
+++ b/video/out/gl_osd.c
@@ -68,7 +68,7 @@ static const struct gl_vao_entry vertex_vao[] = {
struct mpgl_osd_part {
enum sub_bitmap_format format;
- int bitmap_id, bitmap_pos_id;
+ int change_id;
GLuint texture;
int w, h;
GLuint buffer;
@@ -278,14 +278,11 @@ static void gen_osd_cb(void *pctx, struct sub_bitmaps *imgs)
struct mpgl_osd_part *osd = ctx->parts[imgs->render_index];
- if (imgs->bitmap_pos_id != osd->bitmap_pos_id) {
- if (imgs->bitmap_id != osd->bitmap_id) {
- if (!upload_osd(ctx, osd, imgs))
- osd->packer->count = 0;
- }
+ if (imgs->change_id != osd->change_id) {
+ if (!upload_osd(ctx, osd, imgs))
+ osd->packer->count = 0;
- osd->bitmap_id = imgs->bitmap_id;
- osd->bitmap_pos_id = imgs->bitmap_pos_id;
+ osd->change_id = imgs->change_id;
}
osd->num_subparts = osd->packer->count;
diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c
index 1977d64a11..b6e40e75ec 100644
--- a/video/out/vo_direct3d.c
+++ b/video/out/vo_direct3d.c
@@ -103,7 +103,7 @@ struct texplane {
struct osdpart {
enum sub_bitmap_format format;
- int bitmap_id, bitmap_pos_id;
+ int change_id;
struct d3dtex texture;
int num_vertices;
vertex_osd *vertices;
@@ -453,7 +453,7 @@ static void destroy_d3d_surfaces(d3d_priv *priv)
for (int n = 0; n < MAX_OSD_PARTS; n++) {
struct osdpart *osd = priv->osd[n];
d3dtex_release(priv, &osd->texture);
- osd->bitmap_id = osd->bitmap_pos_id = -1;
+ osd->change_id = -1;
}
if (priv->d3d_backbuf)
@@ -1618,14 +1618,11 @@ static struct osdpart *generate_osd(d3d_priv *priv, struct sub_bitmaps *imgs)
struct osdpart *osd = priv->osd[imgs->render_index];
- if (imgs->bitmap_pos_id != osd->bitmap_pos_id) {
- if (imgs->bitmap_id != osd->bitmap_id) {
- if (!upload_osd(priv, osd, imgs))
- osd->packer->count = 0;
- }
+ if (imgs->change_id != osd->change_id) {
+ if (!upload_osd(priv, osd, imgs))
+ osd->packer->count = 0;
- osd->bitmap_id = imgs->bitmap_id;
- osd->bitmap_pos_id = imgs->bitmap_pos_id;
+ osd->change_id = imgs->change_id;
osd->num_vertices = 0;
}
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index 8bde820b38..c2cc711d2f 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -177,8 +177,7 @@ struct priv {
struct mp_osd_res osd_res;
struct formatmap_entry osd_format;
struct osd_bitmap_surface {
- int bitmap_id;
- int bitmap_pos_id;
+ int change_id;
struct osd_target {
SDL_Rect source;
SDL_Rect dest;
@@ -702,7 +701,7 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
if (imgs->format == SUBBITMAP_EMPTY || imgs->num_parts == 0)
return;
- if (imgs->bitmap_pos_id == sfc->bitmap_pos_id)
+ if (imgs->change_id == sfc->change_id)
return;
if (imgs->num_parts > sfc->targets_size) {
@@ -725,49 +724,46 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
bmp->x, bmp->y, bmp->dw, bmp->dh
};
- if (imgs->bitmap_id != sfc->bitmap_id || !target->tex) {
- // tex: alpha blended texture
- if (target->tex) {
- SDL_DestroyTexture(target->tex);
- target->tex = NULL;
- }
- if (!target->tex)
- target->tex = SDL_CreateTexture(vc->renderer,
- vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING,
- bmp->w, bmp->h);
- if (!target->tex) {
- MP_ERR(vo, "Could not create texture\n");
- }
- if (target->tex) {
- SDL_SetTextureBlendMode(target->tex,
- SDL_BLENDMODE_BLEND);
- SDL_SetTextureColorMod(target->tex, 0, 0, 0);
- subbitmap_to_texture(vo, target->tex, bmp, 0); // RGBA -> 000A
- }
+ // tex: alpha blended texture
+ if (target->tex) {
+ SDL_DestroyTexture(target->tex);
+ target->tex = NULL;
+ }
+ if (!target->tex)
+ target->tex = SDL_CreateTexture(vc->renderer,
+ vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING,
+ bmp->w, bmp->h);
+ if (!target->tex) {
+ MP_ERR(vo, "Could not create texture\n");
+ }
+ if (target->tex) {
+ SDL_SetTextureBlendMode(target->tex,
+ SDL_BLENDMODE_BLEND);
+ SDL_SetTextureColorMod(target->tex, 0, 0, 0);
+ subbitmap_to_texture(vo, target->tex, bmp, 0); // RGBA -> 000A
+ }
- // tex2: added texture
- if (target->tex2) {
- SDL_DestroyTexture(target->tex2);
- target->tex2 = NULL;
- }
- if (!target->tex2)
- target->tex2 = SDL_CreateTexture(vc->renderer,
- vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING,
- bmp->w, bmp->h);
- if (!target->tex2) {
- MP_ERR(vo, "Could not create texture\n");
- }
- if (target->tex2) {
- SDL_SetTextureBlendMode(target->tex2,
- SDL_BLENDMODE_ADD);
- subbitmap_to_texture(vo, target->tex2, bmp,
- 0xFF000000); // RGBA -> RGB1
- }
+ // tex2: added texture
+ if (target->tex2) {
+ SDL_DestroyTexture(target->tex2);
+ target->tex2 = NULL;
+ }
+ if (!target->tex2)
+ target->tex2 = SDL_CreateTexture(vc->renderer,
+ vc->osd_format.sdl, SDL_TEXTUREACCESS_STREAMING,
+ bmp->w, bmp->h);
+ if (!target->tex2) {
+ MP_ERR(vo, "Could not create texture\n");
+ }
+ if (target->tex2) {
+ SDL_SetTextureBlendMode(target->tex2,
+ SDL_BLENDMODE_ADD);
+ subbitmap_to_texture(vo, target->tex2, bmp,
+ 0xFF000000); // RGBA -> RGB1
}
}
- sfc->bitmap_id = imgs->bitmap_id;
- sfc->bitmap_pos_id = imgs->bitmap_pos_id;
+ sfc->change_id = imgs->change_id;
}
static void draw_osd_part(struct vo *vo, int index)
diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c
index 8d0102be77..31479ff41b 100644
--- a/video/out/vo_vaapi.c
+++ b/video/out/vo_vaapi.c
@@ -57,7 +57,7 @@ struct vaapi_subpic {
struct vaapi_osd_part {
bool active;
- int bitmap_pos_id;
+ int change_id;
struct vaapi_osd_image image;
struct vaapi_subpic subpic;
struct osd_conv_cache *conv_cache;
@@ -345,8 +345,8 @@ static void draw_osd_cb(void *pctx, struct sub_bitmaps *imgs)
struct priv *p = pctx;
struct vaapi_osd_part *part = &p->osd_parts[imgs->render_index];
- if (imgs->bitmap_pos_id != part->bitmap_pos_id) {
- part->bitmap_pos_id = imgs->bitmap_pos_id;
+ if (imgs->change_id != part->change_id) {
+ part->change_id = imgs->change_id;
osd_scale_rgba(part->conv_cache, imgs);
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index 89bbb142a3..995b579ba6 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -136,8 +136,7 @@ struct vdpctx {
} *targets;
int targets_size;
int render_count;
- int bitmap_id;
- int bitmap_pos_id;
+ int change_id;
} osd_surfaces[MAX_OSD_PARTS];
// Video equalizer
@@ -388,7 +387,7 @@ static void mark_vdpau_objects_uninitialized(struct vo *vo)
for (int i = 0; i < MAX_OSD_PARTS; i++) {
struct osd_bitmap_surface *sfc = &vc->osd_surfaces[i];
talloc_free(sfc->packer);
- sfc->bitmap_id = sfc->bitmap_pos_id = 0;
+ sfc->change_id = 0;
*sfc = (struct osd_bitmap_surface){
.surface = VDP_INVALID_HANDLE,
};
@@ -512,7 +511,7 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
struct osd_bitmap_surface *sfc = &vc->osd_surfaces[imgs->render_index];
bool need_upload = false;
- if (imgs->bitmap_pos_id == sfc->bitmap_pos_id)
+ if (imgs->change_id == sfc->change_id)
return; // Nothing changed and we still have the old data
sfc->render_count = 0;
@@ -520,9 +519,6 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
if (imgs->format == SUBBITMAP_EMPTY || imgs->num_parts == 0)
return;
- if (imgs->bitmap_id == sfc->bitmap_id)
- goto osd_skip_upload;
-
need_upload = true;
VdpRGBAFormat format;
int format_size;
@@ -574,7 +570,6 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs)
sfc->packer->used_height});
}
-osd_skip_upload:
if (sfc->surface == VDP_INVALID_HANDLE)
return;
if (sfc->packer->count > sfc->targets_size) {
@@ -610,8 +605,7 @@ osd_skip_upload:
sfc->render_count++;
}
- sfc->bitmap_id = imgs->bitmap_id;
- sfc->bitmap_pos_id = imgs->bitmap_pos_id;
+ sfc->change_id = imgs->change_id;
}
static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs)
diff --git a/video/out/vo_wayland.c b/video/out/vo_wayland.c
index 9da24ddf3e..c179bbe179 100644
--- a/video/out/vo_wayland.c
+++ b/video/out/vo_wayland.c
@@ -134,7 +134,7 @@ struct priv {
struct wl_subsurface *osd_subsurfaces[MAX_OSD_PARTS];
shm_buffer_t *osd_buffers[MAX_OSD_PARTS];
// this id tells us if the subtitle part has changed or not
- int bitmap_pos_id[MAX_OSD_PARTS];
+ int change_id[MAX_OSD_PARTS];
int64_t recent_flip_time; // last frame event
@@ -455,8 +455,8 @@ static void draw_osd_cb(void *ctx, struct sub_bitmaps *imgs)
struct wl_surface *s = p->osd_surfaces[id];
- if (imgs->bitmap_pos_id != p->bitmap_pos_id[id]) {
- p->bitmap_pos_id[id] = imgs->bitmap_pos_id;
+ if (imgs->change_id != p->change_id[id]) {
+ p->change_id[id] = imgs->change_id;
struct mp_rect bb;
if (!mp_sub_bitmaps_bb(imgs, &bb))