Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2014-07-03 19:58:38 +0400
committerStefano Sabatini <stefasab@gmail.com>2014-07-05 13:48:06 +0400
commit85eabd748bc783c6591e159631cbed11cf2d00fa (patch)
tree41af2081f567c0d5e0b3d5d7898fe6593edae04d /libavfilter/vf_drawtext.c
parentd5818c37f3219a4c6929c0401e6eacbfef3b843e (diff)
lavfi/drawtext: do not allocate FT_Glyph, but keep it in the Glyph structure
Slightly simplify.
Diffstat (limited to 'libavfilter/vf_drawtext.c')
-rw-r--r--libavfilter/vf_drawtext.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 202b2fad6d..8c090d7b4d 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -261,7 +261,7 @@ struct ft_error
#define FT_ERRMSG(e) ft_errors[e].err_msg
typedef struct Glyph {
- FT_Glyph *glyph;
+ FT_Glyph glyph;
FT_Glyph border_glyph;
uint32_t code;
FT_Bitmap bitmap; ///< array holding bitmaps of font
@@ -294,20 +294,19 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
if (FT_Load_Char(s->face, code, s->ft_load_flags))
return AVERROR(EINVAL);
- /* save glyph */
- if (!(glyph = av_mallocz(sizeof(*glyph))) ||
- !(glyph->glyph = av_mallocz(sizeof(*glyph->glyph)))) {
+ glyph = av_mallocz(sizeof(*glyph));
+ if (!glyph) {
ret = AVERROR(ENOMEM);
goto error;
}
glyph->code = code;
- if (FT_Get_Glyph(s->face->glyph, glyph->glyph)) {
+ if (FT_Get_Glyph(s->face->glyph, &glyph->glyph)) {
ret = AVERROR(EINVAL);
goto error;
}
if (s->borderw) {
- glyph->border_glyph = *glyph->glyph;
+ glyph->border_glyph = glyph->glyph;
if (FT_Glyph_StrokeBorder(&glyph->border_glyph, s->stroker, 0, 0) ||
FT_Glyph_To_Bitmap(&glyph->border_glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
ret = AVERROR_EXTERNAL;
@@ -316,11 +315,11 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
bitmapglyph = (FT_BitmapGlyph) glyph->border_glyph;
glyph->border_bitmap = bitmapglyph->bitmap;
}
- if (FT_Glyph_To_Bitmap(glyph->glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
+ if (FT_Glyph_To_Bitmap(&glyph->glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
ret = AVERROR_EXTERNAL;
goto error;
}
- bitmapglyph = (FT_BitmapGlyph) *glyph->glyph;
+ bitmapglyph = (FT_BitmapGlyph) glyph->glyph;
glyph->bitmap = bitmapglyph->bitmap;
glyph->bitmap_left = bitmapglyph->left;
@@ -328,7 +327,7 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
glyph->advance = s->face->glyph->advance.x >> 6;
/* measure text height to calculate text_height (or the maximum text height) */
- FT_Glyph_Get_CBox(*glyph->glyph, ft_glyph_bbox_pixels, &glyph->bbox);
+ FT_Glyph_Get_CBox(glyph->glyph, ft_glyph_bbox_pixels, &glyph->bbox);
/* cache the newly created glyph */
if (!(node = av_tree_node_alloc())) {
@@ -585,9 +584,8 @@ static int glyph_enu_free(void *opaque, void *elem)
{
Glyph *glyph = elem;
- FT_Done_Glyph(*glyph->glyph);
+ FT_Done_Glyph(glyph->glyph);
FT_Done_Glyph(glyph->border_glyph);
- av_freep(&glyph->glyph);
av_free(elem);
return 0;
}