1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-31 15:59:34 +00:00

sub: fix and simplify some change detection details

Fix spudec change detection. The internal changed-flag was not reset
when retrieving indexed bitmaps, and subtitles were rescaled every
frame, even if they were not changing.

Simplify subtitle decoders by not requiring them to check whether the
passed-in screen size has changed. sd_lavc did this, and spudec would
have needed to do the same. Instead, leave this to the osd_object
force_redraw flag. Subtitle decoders (such as libass) can still signal
that only the positions of subtitles have changed, but making _all_
subtitle decoders do this just to deal with screen size changes is
worthless.
This commit is contained in:
wm4 2012-10-16 07:26:45 +02:00
parent 84c3480686
commit f45eab6fae
3 changed files with 14 additions and 15 deletions

View File

@ -187,7 +187,6 @@ static void get_bitmaps(struct sh_sub *sh, struct osd_state *osd,
if (priv->bitmaps_changed && priv->count > 0)
priv->outbitmaps = talloc_memdup(priv, priv->inbitmaps,
talloc_get_size(priv->inbitmaps));
bool pos_changed = false;
int inw = priv->avctx->width;
int inh = priv->avctx->height;
guess_resolution(sh->type, &inw, &inh);
@ -197,18 +196,15 @@ static void get_bitmaps(struct sh_sub *sh, struct osd_state *osd,
for (int i = 0; i < priv->count; i++) {
struct sub_bitmap *bi = &priv->inbitmaps[i];
struct sub_bitmap *bo = &priv->outbitmaps[i];
#define SET(var, val) pos_changed |= var != (int)(val); var = (val)
SET(bo->x, bi->x * xscale + d->ml);
SET(bo->y, bi->y * yscale + d->mt);
SET(bo->dw, bi->w * xscale);
SET(bo->dh, bi->h * yscale);
bo->x = bi->x * xscale + d->ml;
bo->y = bi->y * yscale + d->mt;
bo->dw = bi->w * xscale;
bo->dh = bi->h * yscale;
}
res->parts = priv->outbitmaps;
res->num_parts = priv->count;
if (priv->bitmaps_changed)
res->bitmap_id = ++res->bitmap_pos_id;
else if (pos_changed)
res->bitmap_pos_id++;
priv->bitmaps_changed = false;
res->format = SUBBITMAP_INDEXED;
res->scaled = xscale != 1 || yscale != 1;

View File

@ -857,6 +857,10 @@ void spudec_get_indexed(void *this, struct mp_eosd_res *dim,
res->num_parts = 1;
res->scaled = true;
}
if (spu->spu_changed) {
res->bitmap_id = res->bitmap_pos_id = 1;
spu->spu_changed = 0;
}
}
void spudec_draw(void *this, void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx)

View File

@ -176,11 +176,6 @@ static bool render_object(struct osd_state *osd, struct osd_object *obj,
//spudec_get_bitmap(vo_spudec, osd->res.w, osd->res.h, out_imgs);
spudec_get_indexed(vo_spudec, &osd->res, out_imgs);
}
// Normal change-detection (sub. dec. calls vo_osd_changed(OSDTYPE_SPU))
if (obj->force_redraw) {
out_imgs->bitmap_id++;
out_imgs->bitmap_pos_id++;
}
} else if (obj->type == OSDTYPE_SUB) {
struct sub_render_params p = *sub_params;
if (p.pts != MP_NOPTS_VALUE)
@ -190,6 +185,11 @@ static bool 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++;
}
obj->force_redraw = false;
obj->vo_bitmap_id += out_imgs->bitmap_id;
obj->vo_bitmap_pos_id += out_imgs->bitmap_pos_id;
@ -197,8 +197,7 @@ static bool render_object(struct osd_state *osd, struct osd_object *obj,
if (out_imgs->num_parts == 0)
return false;
if (out_imgs->bitmap_id == 0 && out_imgs->bitmap_pos_id == 0
&& obj->cached.bitmap_id == obj->vo_bitmap_id
if (obj->cached.bitmap_id == obj->vo_bitmap_id
&& obj->cached.bitmap_pos_id == obj->vo_bitmap_pos_id
&& formats[obj->cached.format])
{