Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
9b44f993
Commit
9b44f993
authored
Jan 17, 2021
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/bbox: add support for >8 depth
parent
294854bd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
54 deletions
+69
-54
bbox.c
libavfilter/bbox.c
+65
-50
bbox.h
libavfilter/bbox.h
+1
-1
vf_bbox.c
libavfilter/vf_bbox.c
+1
-1
vf_removelogo.c
libavfilter/vf_removelogo.c
+2
-2
No files found.
libavfilter/bbox.c
View file @
9b44f993
...
@@ -20,56 +20,71 @@
...
@@ -20,56 +20,71 @@
#include "bbox.h"
#include "bbox.h"
int
ff_calculate_bounding_box
(
FFBoundingBox
*
bbox
,
#define BBOX(type, name) \
const
uint8_t
*
data
,
int
linesize
,
int
w
,
int
h
,
static int bbox_##name(FFBoundingBox *bbox, \
int
min_val
)
const type *data, int linesize, int w, int h, \
{
int min_val) \
int
x
,
y
;
{ \
int
start_x
;
int x, y; \
int
start_y
;
int start_x; \
int
end_x
;
int start_y; \
int
end_y
;
int end_x; \
const
uint8_t
*
line
;
int end_y; \
const type *line; \
/* left bound */
\
for
(
start_x
=
0
;
start_x
<
w
;
start_x
++
)
/* left bound */
\
for
(
y
=
0
;
y
<
h
;
y
++
)
for (start_x = 0; start_x < w; start_x++) \
if
((
data
[
y
*
linesize
+
start_x
]
>
min_val
))
for (y = 0; y < h; y++) \
goto
outl
;
if ((data[y * linesize + start_x] > min_val)) \
outl:
goto outl; \
if
(
start_x
==
w
)
/* no points found */
outl: \
return
0
;
if (start_x == w)
/* no points found */
\
return 0; \
/* right bound */
\
for
(
end_x
=
w
-
1
;
end_x
>=
start_x
;
end_x
--
)
/* right bound */
\
for
(
y
=
0
;
y
<
h
;
y
++
)
for (end_x = w - 1; end_x >= start_x; end_x--) \
if
((
data
[
y
*
linesize
+
end_x
]
>
min_val
))
for (y = 0; y < h; y++) \
goto
outr
;
if ((data[y * linesize + end_x] > min_val)) \
outr:
goto outr; \
outr: \
/* top bound */
\
line
=
data
;
/* top bound */
\
for
(
start_y
=
0
;
start_y
<
h
;
start_y
++
)
{
line = data; \
for
(
x
=
0
;
x
<
w
;
x
++
)
for (start_y = 0; start_y < h; start_y++) { \
if
(
line
[
x
]
>
min_val
)
for (x = 0; x < w; x++) \
goto
outt
;
if (line[x] > min_val) \
line
+=
linesize
;
goto outt; \
}
line += linesize; \
outt:
} \
outt: \
\
/* bottom bound */
\
line = data + (h-1)*linesize; \
for (end_y = h - 1; end_y >= start_y; end_y--) { \
for (x = 0; x < w; x++) \
if (line[x] > min_val) \
goto outb; \
line -= linesize; \
} \
outb: \
\
bbox->x1 = start_x; \
bbox->y1 = start_y; \
bbox->x2 = end_x; \
bbox->y2 = end_y; \
return 1; \
}
/* bottom bound */
BBOX
(
uint8_t
,
8
)
line
=
data
+
(
h
-
1
)
*
linesize
;
BBOX
(
uint16_t
,
16
)
for
(
end_y
=
h
-
1
;
end_y
>=
start_y
;
end_y
--
)
{
for
(
x
=
0
;
x
<
w
;
x
++
)
if
(
line
[
x
]
>
min_val
)
goto
outb
;
line
-=
linesize
;
}
outb:
bbox
->
x1
=
start_x
;
int
ff_calculate_bounding_box
(
FFBoundingBox
*
bbox
,
bbox
->
y1
=
start_y
;
const
uint8_t
*
data
,
int
linesize
,
bbox
->
x2
=
end_x
;
int
w
,
int
h
,
bbox
->
y2
=
end_y
;
int
min_val
,
int
depth
)
return
1
;
{
if
(
depth
<=
8
)
return
bbox_8
(
bbox
,
data
,
linesize
,
w
,
h
,
min_val
);
else
return
bbox_16
(
bbox
,
(
const
uint16_t
*
)
data
,
linesize
/
2
,
w
,
h
,
min_val
);
}
}
libavfilter/bbox.h
View file @
9b44f993
...
@@ -39,6 +39,6 @@ typedef struct FFBoundingBox {
...
@@ -39,6 +39,6 @@ typedef struct FFBoundingBox {
*/
*/
int
ff_calculate_bounding_box
(
FFBoundingBox
*
bbox
,
int
ff_calculate_bounding_box
(
FFBoundingBox
*
bbox
,
const
uint8_t
*
data
,
int
linesize
,
const
uint8_t
*
data
,
int
linesize
,
int
w
,
int
h
,
int
min_val
);
int
w
,
int
h
,
int
min_val
,
int
depth
);
#endif
/* AVFILTER_BBOX_H */
#endif
/* AVFILTER_BBOX_H */
libavfilter/vf_bbox.c
View file @
9b44f993
...
@@ -75,7 +75,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
...
@@ -75,7 +75,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
has_bbox
=
has_bbox
=
ff_calculate_bounding_box
(
&
box
,
ff_calculate_bounding_box
(
&
box
,
frame
->
data
[
0
],
frame
->
linesize
[
0
],
frame
->
data
[
0
],
frame
->
linesize
[
0
],
inlink
->
w
,
inlink
->
h
,
bbox
->
min_val
);
inlink
->
w
,
inlink
->
h
,
bbox
->
min_val
,
8
);
w
=
box
.
x2
-
box
.
x1
+
1
;
w
=
box
.
x2
-
box
.
x1
+
1
;
h
=
box
.
y2
-
box
.
y1
+
1
;
h
=
box
.
y2
-
box
.
y1
+
1
;
...
...
libavfilter/vf_removelogo.c
View file @
9b44f993
...
@@ -342,8 +342,8 @@ static av_cold int init(AVFilterContext *ctx)
...
@@ -342,8 +342,8 @@ static av_cold int init(AVFilterContext *ctx)
/* Calculate our bounding rectangles, which determine in what
/* Calculate our bounding rectangles, which determine in what
* region the logo resides for faster processing. */
* region the logo resides for faster processing. */
ff_calculate_bounding_box
(
&
s
->
full_mask_bbox
,
s
->
full_mask_data
,
w
,
w
,
h
,
0
);
ff_calculate_bounding_box
(
&
s
->
full_mask_bbox
,
s
->
full_mask_data
,
w
,
w
,
h
,
0
,
8
);
ff_calculate_bounding_box
(
&
s
->
half_mask_bbox
,
s
->
half_mask_data
,
w
/
2
,
w
/
2
,
h
/
2
,
0
);
ff_calculate_bounding_box
(
&
s
->
half_mask_bbox
,
s
->
half_mask_data
,
w
/
2
,
w
/
2
,
h
/
2
,
0
,
8
);
#define SHOW_LOGO_INFO(mask_type) \
#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", \
av_log(ctx, AV_LOG_VERBOSE, #mask_type " x1:%d x2:%d y1:%d y2:%d max_mask_size:%d\n", \
...
...
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