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
e31a239f
Commit
e31a239f
authored
May 16, 2013
by
Clément Bœsch
Committed by
Paul B Mahol
Oct 02, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_removelogo: use the name 's' for the pointer to the private context
parent
7d0ce1e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
38 deletions
+38
-38
vf_removelogo.c
libavfilter/vf_removelogo.c
+38
-38
No files found.
libavfilter/vf_removelogo.c
View file @
e31a239f
...
...
@@ -279,44 +279,44 @@ static void generate_half_size_image(const uint8_t *src_data, int src_linesize,
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
{
RemovelogoContext
*
removelogo
=
ctx
->
priv
;
RemovelogoContext
*
s
=
ctx
->
priv
;
int
***
mask
;
int
ret
=
0
;
int
a
,
b
,
c
,
w
,
h
;
int
full_max_mask_size
,
half_max_mask_size
;
if
(
!
removelogo
->
filename
)
{
if
(
!
s
->
filename
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"The bitmap file name is mandatory
\n
"
);
return
AVERROR
(
EINVAL
);
}
/* Load our mask image. */
if
((
ret
=
load_mask
(
&
removelogo
->
full_mask_data
,
&
w
,
&
h
,
removelogo
->
filename
,
ctx
))
<
0
)
if
((
ret
=
load_mask
(
&
s
->
full_mask_data
,
&
w
,
&
h
,
s
->
filename
,
ctx
))
<
0
)
return
ret
;
removelogo
->
mask_w
=
w
;
removelogo
->
mask_h
=
h
;
s
->
mask_w
=
w
;
s
->
mask_h
=
h
;
convert_mask_to_strength_mask
(
removelogo
->
full_mask_data
,
w
,
w
,
h
,
convert_mask_to_strength_mask
(
s
->
full_mask_data
,
w
,
w
,
h
,
16
,
&
full_max_mask_size
);
/* Create the scaled down mask image for the chroma planes. */
if
(
!
(
removelogo
->
half_mask_data
=
av_mallocz
(
w
/
2
*
h
/
2
)))
if
(
!
(
s
->
half_mask_data
=
av_mallocz
(
w
/
2
*
h
/
2
)))
return
AVERROR
(
ENOMEM
);
generate_half_size_image
(
removelogo
->
full_mask_data
,
w
,
removelogo
->
half_mask_data
,
w
/
2
,
generate_half_size_image
(
s
->
full_mask_data
,
w
,
s
->
half_mask_data
,
w
/
2
,
w
,
h
,
&
half_max_mask_size
);
removelogo
->
max_mask_size
=
FFMAX
(
full_max_mask_size
,
half_max_mask_size
);
s
->
max_mask_size
=
FFMAX
(
full_max_mask_size
,
half_max_mask_size
);
/* Create a circular mask for each size up to max_mask_size. When
the filter is applied, the mask size is determined on a pixel
by pixel basis, with pixels nearer the edge of the logo getting
smaller mask sizes. */
mask
=
(
int
***
)
av_malloc
(
sizeof
(
int
**
)
*
(
removelogo
->
max_mask_size
+
1
));
mask
=
(
int
***
)
av_malloc
(
sizeof
(
int
**
)
*
(
s
->
max_mask_size
+
1
));
if
(
!
mask
)
return
AVERROR
(
ENOMEM
);
for
(
a
=
0
;
a
<=
removelogo
->
max_mask_size
;
a
++
)
{
for
(
a
=
0
;
a
<=
s
->
max_mask_size
;
a
++
)
{
mask
[
a
]
=
(
int
**
)
av_malloc
(
sizeof
(
int
*
)
*
((
a
*
2
)
+
1
));
if
(
!
mask
[
a
])
return
AVERROR
(
ENOMEM
);
...
...
@@ -332,17 +332,17 @@ static av_cold int init(AVFilterContext *ctx)
}
}
}
removelogo
->
mask
=
mask
;
s
->
mask
=
mask
;
/* Calculate our bounding rectangles, which determine in what
* region the logo resides for faster processing. */
ff_calculate_bounding_box
(
&
removelogo
->
full_mask_bbox
,
removelogo
->
full_mask_data
,
w
,
w
,
h
,
0
);
ff_calculate_bounding_box
(
&
removelogo
->
half_mask_bbox
,
removelogo
->
half_mask_data
,
w
/
2
,
w
/
2
,
h
/
2
,
0
);
ff_calculate_bounding_box
(
&
s
->
full_mask_bbox
,
s
->
full_mask_data
,
w
,
w
,
h
,
0
);
ff_calculate_bounding_box
(
&
s
->
half_mask_bbox
,
s
->
half_mask_data
,
w
/
2
,
w
/
2
,
h
/
2
,
0
);
#define SHOW_LOGO_INFO(mask_type) \
av_log(ctx, AV_LOG_VERBOSE, #mask_type " x1:%d x2:%d y1:%d y2:%d max_mask_size:%d\n", \
removelogo->mask_type##_mask_bbox.x1, removelogo
->mask_type##_mask_bbox.x2, \
removelogo->mask_type##_mask_bbox.y1, removelogo
->mask_type##_mask_bbox.y2, \
s->mask_type##_mask_bbox.x1, s
->mask_type##_mask_bbox.x2, \
s->mask_type##_mask_bbox.y1, s
->mask_type##_mask_bbox.y2, \
mask_type##_max_mask_size);
SHOW_LOGO_INFO
(
full
);
SHOW_LOGO_INFO
(
half
);
...
...
@@ -353,12 +353,12 @@ static av_cold int init(AVFilterContext *ctx)
static
int
config_props_input
(
AVFilterLink
*
inlink
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
RemovelogoContext
*
removelogo
=
ctx
->
priv
;
RemovelogoContext
*
s
=
ctx
->
priv
;
if
(
inlink
->
w
!=
removelogo
->
mask_w
||
inlink
->
h
!=
removelogo
->
mask_h
)
{
if
(
inlink
->
w
!=
s
->
mask_w
||
inlink
->
h
!=
s
->
mask_h
)
{
av_log
(
ctx
,
AV_LOG_INFO
,
"Mask image size %dx%d does not match with the input video size %dx%d
\n
"
,
removelogo
->
mask_w
,
removelogo
->
mask_h
,
inlink
->
w
,
inlink
->
h
);
s
->
mask_w
,
s
->
mask_h
,
inlink
->
w
,
inlink
->
h
);
return
AVERROR
(
EINVAL
);
}
...
...
@@ -488,7 +488,7 @@ static void blur_image(int ***mask,
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
inpicref
)
{
RemovelogoContext
*
removelogo
=
inlink
->
dst
->
priv
;
RemovelogoContext
*
s
=
inlink
->
dst
->
priv
;
AVFilterLink
*
outlink
=
inlink
->
dst
->
outputs
[
0
];
AVFrame
*
outpicref
;
int
direct
=
0
;
...
...
@@ -505,21 +505,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
av_frame_copy_props
(
outpicref
,
inpicref
);
}
blur_image
(
removelogo
->
mask
,
blur_image
(
s
->
mask
,
inpicref
->
data
[
0
],
inpicref
->
linesize
[
0
],
outpicref
->
data
[
0
],
outpicref
->
linesize
[
0
],
removelogo
->
full_mask_data
,
inlink
->
w
,
inlink
->
w
,
inlink
->
h
,
direct
,
&
removelogo
->
full_mask_bbox
);
blur_image
(
removelogo
->
mask
,
s
->
full_mask_data
,
inlink
->
w
,
inlink
->
w
,
inlink
->
h
,
direct
,
&
s
->
full_mask_bbox
);
blur_image
(
s
->
mask
,
inpicref
->
data
[
1
],
inpicref
->
linesize
[
1
],
outpicref
->
data
[
1
],
outpicref
->
linesize
[
1
],
removelogo
->
half_mask_data
,
inlink
->
w
/
2
,
inlink
->
w
/
2
,
inlink
->
h
/
2
,
direct
,
&
removelogo
->
half_mask_bbox
);
blur_image
(
removelogo
->
mask
,
s
->
half_mask_data
,
inlink
->
w
/
2
,
inlink
->
w
/
2
,
inlink
->
h
/
2
,
direct
,
&
s
->
half_mask_bbox
);
blur_image
(
s
->
mask
,
inpicref
->
data
[
2
],
inpicref
->
linesize
[
2
],
outpicref
->
data
[
2
],
outpicref
->
linesize
[
2
],
removelogo
->
half_mask_data
,
inlink
->
w
/
2
,
inlink
->
w
/
2
,
inlink
->
h
/
2
,
direct
,
&
removelogo
->
half_mask_bbox
);
s
->
half_mask_data
,
inlink
->
w
/
2
,
inlink
->
w
/
2
,
inlink
->
h
/
2
,
direct
,
&
s
->
half_mask_bbox
);
if
(
!
direct
)
av_frame_free
(
&
inpicref
);
...
...
@@ -529,23 +529,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
RemovelogoContext
*
removelogo
=
ctx
->
priv
;
RemovelogoContext
*
s
=
ctx
->
priv
;
int
a
,
b
;
av_freep
(
&
removelogo
->
full_mask_data
);
av_freep
(
&
removelogo
->
half_mask_data
);
av_freep
(
&
s
->
full_mask_data
);
av_freep
(
&
s
->
half_mask_data
);
if
(
removelogo
->
mask
)
{
if
(
s
->
mask
)
{
/* Loop through each mask. */
for
(
a
=
0
;
a
<=
removelogo
->
max_mask_size
;
a
++
)
{
for
(
a
=
0
;
a
<=
s
->
max_mask_size
;
a
++
)
{
/* Loop through each scanline in a mask. */
for
(
b
=
-
a
;
b
<=
a
;
b
++
)
{
av_free
(
removelogo
->
mask
[
a
][
b
+
a
]);
/* Free a scanline. */
av_free
(
s
->
mask
[
a
][
b
+
a
]);
/* Free a scanline. */
}
av_free
(
removelogo
->
mask
[
a
]);
av_free
(
s
->
mask
[
a
]);
}
/* Free the array of pointers pointing to the masks. */
av_freep
(
&
removelogo
->
mask
);
av_freep
(
&
s
->
mask
);
}
}
...
...
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