summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-02-22 19:31:53 +0000
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-02-22 19:31:53 +0000
commitfc6600af48394770f091ea7051b126b1f254b322 (patch)
tree93a2a1960afd888e987b7f18db4cb92d021074df
parentb803331d0c9ca82d1734fc97dfa74726566ac40f (diff)
downloadmpv-fc6600af48394770f091ea7051b126b1f254b322.tar.bz2
mpv-fc6600af48394770f091ea7051b126b1f254b322.tar.xz
Check glyph bounding box before rasterizing and complain if it is too large.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26067 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--help/help_mp-en.h1
-rw-r--r--libass/ass_bitmap.c16
2 files changed, 17 insertions, 0 deletions
diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index af2aae9f63..58e1e8310a 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -2010,6 +2010,7 @@ static char help_text[]=
// ass_bitmap.c
#define MSGTR_LIBASS_FT_Glyph_To_BitmapError "[ass] FT_Glyph_To_Bitmap error %d \n"
#define MSGTR_LIBASS_UnsupportedPixelMode "[ass] Unsupported pixel mode: %d\n"
+#define MSGTR_LIBASS_GlyphBBoxTooLarge "[ass] Glyph bounding box too large: %dx%dpx\n"
// ass.c
#define MSGTR_LIBASS_NoStyleNamedXFoundUsingY "[ass] [%p] Warning: no style named '%s' found, using '%s'\n"
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c
index 8aa1fe7a65..f84b453b36 100644
--- a/libass/ass_bitmap.c
+++ b/libass/ass_bitmap.c
@@ -150,6 +150,20 @@ static bitmap_t* copy_bitmap(const bitmap_t* src)
return dst;
}
+static int check_glyph_area(FT_Glyph glyph)
+{
+ FT_BBox bbox;
+ long long dx, dy;
+ FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_TRUNCATE, &bbox);
+ dx = bbox.xMax - bbox.xMin;
+ dy = bbox.yMax - bbox.yMin;
+ if (dx * dy > 8000000) {
+ mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_GlyphBBoxTooLarge, (int)dx, (int)dy);
+ return 1;
+ } else
+ return 0;
+}
+
static bitmap_t* glyph_to_bitmap_internal(FT_Glyph glyph, int bord)
{
FT_BitmapGlyph bg;
@@ -161,6 +175,8 @@ static bitmap_t* glyph_to_bitmap_internal(FT_Glyph glyph, int bord)
int i;
int error;
+ if (check_glyph_area(glyph))
+ return 0;
error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 0);
if (error) {
mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FT_Glyph_To_BitmapError, error);