summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-28 13:50:08 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-07-28 13:50:08 +0000
commit615166ab611c9f784d1caa06da4efe0df5d37149 (patch)
treeb148bbb2d8521b302df1f8e45f5d18ef037353c6 /libvo
parentc3cdf1ced9b4becdfc215a7c6bb63b4c6ba22134 (diff)
downloadmpv-615166ab611c9f784d1caa06da4efe0df5d37149.tar.bz2
mpv-615166ab611c9f784d1caa06da4efe0df5d37149.tar.xz
Avoid large amounts of data on the stack (> 900k on 64 bit systems).
Patch by Tobias Diedrich (ranma at tdiedrich de) with minor modifications by me. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19213 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/font_load_ft.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c
index 09b3b0bb6e..89396c5a2e 100644
--- a/libvo/font_load_ft.c
+++ b/libvo/font_load_ft.c
@@ -955,12 +955,12 @@ int kerning(font_desc_t *desc, int prevc, int c)
font_desc_t* read_font_desc_ft(const char *fname, int movie_width, int movie_height)
{
- font_desc_t *desc;
+ font_desc_t *desc = NULL;
FT_Face face;
- FT_ULong my_charset[MAX_CHARSET_SIZE]; /* characters we want to render; Unicode */
- FT_ULong my_charcodes[MAX_CHARSET_SIZE]; /* character codes in 'encoding' */
+ FT_ULong *my_charset = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* characters we want to render; Unicode */
+ FT_ULong *my_charcodes = malloc(MAX_CHARSET_SIZE * sizeof(FT_ULong)); /* character codes in 'encoding' */
char *charmap = "ucs-4";
int err;
@@ -973,6 +973,11 @@ font_desc_t* read_font_desc_ft(const char *fname, int movie_width, int movie_hei
float subtitle_font_ppem;
float osd_font_ppem;
+ if (my_charset == NULL || my_charcodes == NULL) {
+ mp_msg(MSGT_OSD, MSGL_ERR, "subtitle font: malloc failed.\n");
+ goto err_out;
+ }
+
switch (subtitle_autoscale) {
case 1:
movie_size = movie_height;
@@ -1005,7 +1010,7 @@ font_desc_t* read_font_desc_ft(const char *fname, int movie_width, int movie_hei
}
desc = init_font_desc();
- if(!desc) return NULL;
+ if(!desc) goto err_out;
// t=GetTimer();
@@ -1030,11 +1035,10 @@ font_desc_t* read_font_desc_ft(const char *fname, int movie_width, int movie_hei
if (charset_size < 0) {
mp_msg(MSGT_OSD, MSGL_ERR, "subtitle font: prepare_charset failed.\n");
- free_font_desc(desc);
- return NULL;
+ goto err_out;
}
#else
- return NULL;
+ goto err_out;
#endif
// fprintf(stderr, "fg: prepare t = %lf\n", GetTimer()-t);
@@ -1045,8 +1049,7 @@ font_desc_t* read_font_desc_ft(const char *fname, int movie_width, int movie_hei
if (err) {
mp_msg(MSGT_OSD, MSGL_ERR, "Cannot prepare subtitle font.\n");
- free_font_desc(desc);
- return NULL;
+ goto err_out;
}
gen_osd:
@@ -1054,8 +1057,7 @@ gen_osd:
/* generate the OSD font */
err = load_osd_face(&face);
if (err) {
- free_font_desc(desc);
- return NULL;
+ goto err_out;
}
desc->face_cnt++;
@@ -1065,16 +1067,14 @@ gen_osd:
if (err) {
mp_msg(MSGT_OSD, MSGL_ERR, "Cannot prepare OSD font.\n");
- free_font_desc(desc);
- return NULL;
+ goto err_out;
}
err = generate_tables(desc, subtitle_font_thickness, subtitle_font_radius);
if (err) {
mp_msg(MSGT_OSD, MSGL_ERR, "Cannot generate tables.\n");
- free_font_desc(desc);
- return NULL;
+ goto err_out;
}
// final cleanup
@@ -1092,7 +1092,16 @@ gen_osd:
desc->font[i] = desc->font[j];
}
}
+ free(my_charset);
+ free(my_charcodes);
return desc;
+
+err_out:
+ if (desc)
+ free_font_desc(desc);
+ free(my_charset);
+ free(my_charcodes);
+ return NULL;
}
int init_freetype(void)