Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
85eabd74
Commit
85eabd74
authored
Jul 03, 2014
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/drawtext: do not allocate FT_Glyph, but keep it in the Glyph structure
Slightly simplify.
parent
d5818c37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
11 deletions
+9
-11
vf_drawtext.c
libavfilter/vf_drawtext.c
+9
-11
No files found.
libavfilter/vf_drawtext.c
View file @
85eabd74
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment