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
9d16e46d
Commit
9d16e46d
authored
Sep 13, 2016
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/drawutils: allow drawing opaque text on transparent background
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
6419b4c0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
5 deletions
+12
-5
drawutils.c
libavfilter/drawutils.c
+4
-3
drawutils.h
libavfilter/drawutils.h
+7
-1
vf_drawtext.c
libavfilter/vf_drawtext.c
+1
-1
No files found.
libavfilter/drawutils.c
View file @
9d16e46d
...
...
@@ -211,10 +211,11 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
draw
->
desc
=
desc
;
draw
->
format
=
format
;
draw
->
nb_planes
=
nb_planes
;
draw
->
flags
=
flags
;
memcpy
(
draw
->
pixelstep
,
pixelstep
,
sizeof
(
draw
->
pixelstep
));
draw
->
hsub
[
1
]
=
draw
->
hsub
[
2
]
=
draw
->
hsub_max
=
desc
->
log2_chroma_w
;
draw
->
vsub
[
1
]
=
draw
->
vsub
[
2
]
=
draw
->
vsub_max
=
desc
->
log2_chroma_h
;
for
(
i
=
0
;
i
<
(
desc
->
nb_components
-
!!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_ALPHA
));
i
++
)
for
(
i
=
0
;
i
<
(
desc
->
nb_components
-
!!
(
desc
->
flags
&
AV_PIX_FMT_FLAG_ALPHA
&&
!
(
flags
&
FF_DRAW_PROCESS_ALPHA
)
));
i
++
)
draw
->
comp_mask
[
desc
->
comp
[
i
].
plane
]
|=
1
<<
desc
->
comp
[
i
].
offset
;
return
0
;
...
...
@@ -452,7 +453,7 @@ void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color,
/* 0x101 * alpha is in the [ 2 ; 0x1001] range */
alpha
=
0x101
*
color
->
rgba
[
3
]
+
0x2
;
}
nb_planes
=
draw
->
nb_planes
-
!!
(
draw
->
desc
->
flags
&
AV_PIX_FMT_FLAG_ALPHA
);
nb_planes
=
draw
->
nb_planes
-
!!
(
draw
->
desc
->
flags
&
AV_PIX_FMT_FLAG_ALPHA
&&
!
(
draw
->
flags
&
FF_DRAW_PROCESS_ALPHA
)
);
nb_planes
+=
!
nb_planes
;
for
(
plane
=
0
;
plane
<
nb_planes
;
plane
++
)
{
nb_comp
=
draw
->
pixelstep
[
plane
];
...
...
@@ -630,7 +631,7 @@ void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color,
}
else
{
alpha
=
(
0x101
*
color
->
rgba
[
3
]
+
0x2
)
>>
8
;
}
nb_planes
=
draw
->
nb_planes
-
!!
(
draw
->
desc
->
flags
&
AV_PIX_FMT_FLAG_ALPHA
);
nb_planes
=
draw
->
nb_planes
-
!!
(
draw
->
desc
->
flags
&
AV_PIX_FMT_FLAG_ALPHA
&&
!
(
draw
->
flags
&
FF_DRAW_PROCESS_ALPHA
)
);
nb_planes
+=
!
nb_planes
;
for
(
plane
=
0
;
plane
<
nb_planes
;
plane
++
)
{
nb_comp
=
draw
->
pixelstep
[
plane
];
...
...
libavfilter/drawutils.h
View file @
9d16e46d
...
...
@@ -55,6 +55,7 @@ typedef struct FFDrawContext {
uint8_t
vsub
[
MAX_PLANES
];
/*< vertical subsampling */
uint8_t
hsub_max
;
uint8_t
vsub_max
;
unsigned
flags
;
}
FFDrawContext
;
typedef
struct
FFDrawColor
{
...
...
@@ -66,12 +67,17 @@ typedef struct FFDrawColor {
}
comp
[
MAX_PLANES
];
}
FFDrawColor
;
/**
* Process alpha pixel component.
*/
#define FF_DRAW_PROCESS_ALPHA 1
/**
* Init a draw context.
*
* Only a limited number of pixel formats are supported, if format is not
* supported the function will return an error.
*
No flags currently defined
.
*
flags is combination of FF_DRAW_* flags
.
* @return 0 for success, < 0 for error
*/
int
ff_draw_init
(
FFDrawContext
*
draw
,
enum
AVPixelFormat
format
,
unsigned
flags
);
...
...
libavfilter/vf_drawtext.c
View file @
9d16e46d
...
...
@@ -730,7 +730,7 @@ static int config_input(AVFilterLink *inlink)
DrawTextContext
*
s
=
ctx
->
priv
;
int
ret
;
ff_draw_init
(
&
s
->
dc
,
inlink
->
format
,
0
);
ff_draw_init
(
&
s
->
dc
,
inlink
->
format
,
FF_DRAW_PROCESS_ALPHA
);
ff_draw_color
(
&
s
->
dc
,
&
s
->
fontcolor
,
s
->
fontcolor
.
rgba
);
ff_draw_color
(
&
s
->
dc
,
&
s
->
shadowcolor
,
s
->
shadowcolor
.
rgba
);
ff_draw_color
(
&
s
->
dc
,
&
s
->
bordercolor
,
s
->
bordercolor
.
rgba
);
...
...
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