Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
9dd14477
Commit
9dd14477
authored
Jul 05, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/cropdetect: export cropdetect info to frame metadata
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
4e8d6b31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
vf_cropdetect.c
libavfilter/vf_cropdetect.c
+17
-0
No files found.
libavfilter/vf_cropdetect.c
View file @
9dd14477
...
@@ -112,15 +112,23 @@ static int config_input(AVFilterLink *inlink)
...
@@ -112,15 +112,23 @@ static int config_input(AVFilterLink *inlink)
return
0
;
return
0
;
}
}
#define SET_META(key, value) \
snprintf(buf, sizeof(buf), "%d", value); \
av_dict_set(metadata, #key, buf, 0) \
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
{
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterContext
*
ctx
=
inlink
->
dst
;
CropDetectContext
*
s
=
ctx
->
priv
;
CropDetectContext
*
s
=
ctx
->
priv
;
int
bpp
=
s
->
max_pixsteps
[
0
];
int
bpp
=
s
->
max_pixsteps
[
0
];
int
w
,
h
,
x
,
y
,
shrink_by
;
int
w
,
h
,
x
,
y
,
shrink_by
;
AVDictionary
**
metadata
;
char
buf
[
32
];
// ignore first 2 frames - they may be empty
// ignore first 2 frames - they may be empty
if
(
++
s
->
frame_nb
>
0
)
{
if
(
++
s
->
frame_nb
>
0
)
{
metadata
=
avpriv_frame_get_metadatap
(
frame
);
// Reset the crop area every reset_count frames, if reset_count is > 0
// Reset the crop area every reset_count frames, if reset_count is > 0
if
(
s
->
reset_count
>
0
&&
s
->
frame_nb
>
s
->
reset_count
)
{
if
(
s
->
reset_count
>
0
&&
s
->
frame_nb
>
s
->
reset_count
)
{
s
->
x1
=
frame
->
width
-
1
;
s
->
x1
=
frame
->
width
-
1
;
...
@@ -181,6 +189,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
...
@@ -181,6 +189,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
h
-=
shrink_by
;
h
-=
shrink_by
;
y
+=
(
shrink_by
/
2
+
1
)
&
~
1
;
y
+=
(
shrink_by
/
2
+
1
)
&
~
1
;
SET_META
(
"lavfi.cropdetect.x1"
,
s
->
x1
);
SET_META
(
"lavfi.cropdetect.x2"
,
s
->
x2
);
SET_META
(
"lavfi.cropdetect.y1"
,
s
->
y1
);
SET_META
(
"lavfi.cropdetect.y2"
,
s
->
y2
);
SET_META
(
"lavfi.cropdetect.w"
,
w
);
SET_META
(
"lavfi.cropdetect.h"
,
h
);
SET_META
(
"lavfi.cropdetect.x"
,
x
);
SET_META
(
"lavfi.cropdetect.y"
,
y
);
av_log
(
ctx
,
AV_LOG_INFO
,
av_log
(
ctx
,
AV_LOG_INFO
,
"x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"
PRId64
" t:%f crop=%d:%d:%d:%d
\n
"
,
"x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"
PRId64
" t:%f crop=%d:%d:%d:%d
\n
"
,
s
->
x1
,
s
->
x2
,
s
->
y1
,
s
->
y2
,
w
,
h
,
x
,
y
,
frame
->
pts
,
s
->
x1
,
s
->
x2
,
s
->
y1
,
s
->
y2
,
w
,
h
,
x
,
y
,
frame
->
pts
,
...
...
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