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
a64a2c5f
Commit
a64a2c5f
authored
Feb 22, 2011
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor draw_glyphs out of drawtext filter
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
bccea088
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
27 deletions
+41
-27
vf_drawtext.c
libavfilter/vf_drawtext.c
+41
-27
No files found.
libavfilter/vf_drawtext.c
View file @
a64a2c5f
...
...
@@ -475,13 +475,51 @@ static inline void drawbox(AVFilterBufferRef *picref, unsigned int x, unsigned i
}
}
static
int
draw_glyphs
(
DrawTextContext
*
dtext
,
AVFilterBufferRef
*
picref
,
int
width
,
int
height
)
{
char
*
text
=
dtext
->
text
;
uint32_t
code
=
0
;
int
i
;
uint8_t
*
p
;
Glyph
*
glyph
=
NULL
;
for
(
i
=
0
,
p
=
text
;
*
p
;
i
++
)
{
Glyph
dummy
=
{
0
};
GET_UTF8
(
code
,
*
p
++
,
continue
;);
/* skip new line chars, just go to new line */
if
(
code
==
'\n'
||
code
==
'\r'
||
code
==
'\t'
)
continue
;
dummy
.
code
=
code
;
glyph
=
av_tree_find
(
dtext
->
glyphs
,
&
dummy
,
(
void
*
)
glyph_cmp
,
NULL
);
if
(
glyph
->
bitmap
.
pixel_mode
!=
FT_PIXEL_MODE_MONO
&&
glyph
->
bitmap
.
pixel_mode
!=
FT_PIXEL_MODE_GRAY
)
return
AVERROR
(
EINVAL
);
if
(
dtext
->
is_packed_rgb
)
{
draw_glyph_rgb
(
picref
,
&
glyph
->
bitmap
,
dtext
->
positions
[
i
].
x
,
dtext
->
positions
[
i
].
y
,
width
,
height
,
dtext
->
pixel_step
[
0
],
dtext
->
fontcolor_rgba
,
dtext
->
rgba_map
);
}
else
{
draw_glyph_yuv
(
picref
,
&
glyph
->
bitmap
,
dtext
->
positions
[
i
].
x
,
dtext
->
positions
[
i
].
y
,
width
,
height
,
dtext
->
fontcolor
,
dtext
->
hsub
,
dtext
->
vsub
);
}
}
return
0
;
}
static
int
draw_text
(
AVFilterContext
*
ctx
,
AVFilterBufferRef
*
picref
,
int
width
,
int
height
)
{
DrawTextContext
*
dtext
=
ctx
->
priv
;
char
*
text
=
dtext
->
text
;
uint32_t
code
=
0
,
prev_code
=
0
;
int
x
=
0
,
y
=
0
,
i
=
0
;
int
x
=
0
,
y
=
0
,
i
=
0
,
ret
;
int
text_height
,
baseline
;
uint8_t
*
p
;
int
str_w
,
str_w_max
;
...
...
@@ -583,32 +621,8 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
dtext
->
hsub
,
dtext
->
vsub
,
dtext
->
is_packed_rgb
,
dtext
->
rgba_map
);
}
/* draw glyphs */
for
(
i
=
0
,
p
=
text
;
*
p
;
i
++
)
{
Glyph
dummy
=
{
0
};
GET_UTF8
(
code
,
*
p
++
,
continue
;);
/* skip new line chars, just go to new line */
if
(
code
==
'\n'
||
code
==
'\r'
||
code
==
'\t'
)
continue
;
dummy
.
code
=
code
;
glyph
=
av_tree_find
(
dtext
->
glyphs
,
&
dummy
,
(
void
*
)
glyph_cmp
,
NULL
);
if
(
glyph
->
bitmap
.
pixel_mode
!=
FT_PIXEL_MODE_MONO
&&
glyph
->
bitmap
.
pixel_mode
!=
FT_PIXEL_MODE_GRAY
)
return
AVERROR
(
EINVAL
);
if
(
dtext
->
is_packed_rgb
)
{
draw_glyph_rgb
(
picref
,
&
glyph
->
bitmap
,
dtext
->
positions
[
i
].
x
,
dtext
->
positions
[
i
].
y
,
width
,
height
,
dtext
->
pixel_step
[
0
],
dtext
->
fontcolor_rgba
,
dtext
->
rgba_map
);
}
else
{
draw_glyph_yuv
(
picref
,
&
glyph
->
bitmap
,
dtext
->
positions
[
i
].
x
,
dtext
->
positions
[
i
].
y
,
width
,
height
,
dtext
->
fontcolor
,
dtext
->
hsub
,
dtext
->
vsub
);
}
}
if
((
ret
=
draw_glyphs
(
dtext
,
picref
,
width
,
height
))
<
0
)
return
ret
;
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