diff options
author | wm4 <wm4@nowhere> | 2015-03-18 12:33:14 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-18 13:15:20 +0100 |
commit | 51befc9debef818cbf071aebf8861457ac095f8d (patch) | |
tree | 140152a3b5db9655c5b869d83a7d0c6212c91a6a /sub | |
parent | 15478ca31c48d46b576264299803ab43fdeb1d04 (diff) | |
download | mpv-51befc9debef818cbf071aebf8861457ac095f8d.tar.bz2 mpv-51befc9debef818cbf071aebf8861457ac095f8d.tar.xz |
osd: simplify an aspect of change detection handling
There was a somewhat obscure optimization in the OSD and subtitle
rendering path: if only the position of the sub-images changed, and not
the actual image data, uploading of the image data could be skipped. In
theory, this could speed up things like scrolling subtitles.
But it turns out that even in the rare cases subtitles have such scrolls
or axis-aligned movement, modern libass rarely signals this kind of
change. Possibly this is because of sub-pixel handling and such, which
break this.
As such, it's a worthless optimization and just introduces additional
complexity and subtle bugs (especially in cases libass does the
opposite: incorrectly signaling a position change only, which happened
before). Remove this optimization, and rename bitmap_pos_id to
change_id.
Diffstat (limited to 'sub')
-rw-r--r-- | sub/ass_mp.c | 6 | ||||
-rw-r--r-- | sub/draw_bmp.c | 6 | ||||
-rw-r--r-- | sub/osd.c | 18 | ||||
-rw-r--r-- | sub/osd.h | 3 | ||||
-rw-r--r-- | sub/osd_state.h | 3 | ||||
-rw-r--r-- | sub/sd_lavc.c | 2 |
6 files changed, 14 insertions, 24 deletions
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, @@ -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; @@ -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; |