diff options
author | wm4 <wm4@nowhere> | 2012-09-30 00:45:59 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2012-10-01 15:41:33 +0200 |
commit | 20f83b10241aa9c67c3a7e0c1a7e4d986fe199f1 (patch) | |
tree | 654b9357a13e7b6959f5f9483af15e6c9dd66620 | |
parent | 0594b9fcb5952448dee7eaa3646f7b1281ae8f80 (diff) | |
download | libass-20f83b10241aa9c67c3a7e0c1a7e4d986fe199f1.tar.bz2 libass-20f83b10241aa9c67c3a7e0c1a7e4d986fe199f1.tar.xz |
Fix change detection when cache is cleared
check_cache_limits() clears the image list. If all subtitles disappear
right in the frame the cache has been cleared, ass_detect_change() will
see two empty image lists (old - not empty, but cleared, new - empty),
and signal to the application that there was no change. As result,
media players which rely on the change detection will keep displaying
the last subtitle until the next subtitle event.
This bug was found by uau and has been reported on IRC in February.
-rw-r--r-- | libass/ass_render.c | 6 | ||||
-rw-r--r-- | libass/ass_render.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index f8b7987..b11c681 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -2204,12 +2204,14 @@ static void check_cache_limits(ASS_Renderer *priv, CacheStore *cache) ass_cache_empty(cache->composite_cache, 0); ass_free_images(priv->prev_images_root); priv->prev_images_root = 0; + priv->cache_cleared = 1; } if (ass_cache_empty(cache->outline_cache, cache->glyph_max)) { ass_cache_empty(cache->bitmap_cache, 0); ass_cache_empty(cache->composite_cache, 0); ass_free_images(priv->prev_images_root); priv->prev_images_root = 0; + priv->cache_cleared = 1; } } @@ -2475,6 +2477,9 @@ static int ass_detect_change(ASS_Renderer *priv) ASS_Image *img, *img2; int diff; + if (priv->cache_cleared) + return 2; + img = priv->prev_images_root; img2 = priv->images_root; diff = 0; @@ -2571,6 +2576,7 @@ ASS_Image *ass_render_frame(ASS_Renderer *priv, ASS_Track *track, // free the previous image list ass_free_images(priv->prev_images_root); priv->prev_images_root = 0; + priv->cache_cleared = 0; return priv->images_root; } diff --git a/libass/ass_render.h b/libass/ass_render.h index d0d9aa3..45d19bb 100644 --- a/libass/ass_render.h +++ b/libass/ass_render.h @@ -253,6 +253,7 @@ struct ass_renderer { ASS_Image *images_root; // rendering result is stored here ASS_Image *prev_images_root; + int cache_cleared; EventImages *eimg; // temporary buffer for sorting rendered events int eimg_size; // allocated buffer size |