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
ae732640
Commit
ae732640
authored
Mar 13, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/cropdetect: add support for named options
parent
febd78e9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
24 deletions
+45
-24
filters.texi
doc/filters.texi
+16
-13
version.h
libavfilter/version.h
+1
-1
vf_cropdetect.c
libavfilter/vf_cropdetect.c
+28
-10
No files found.
doc/filters.texi
View file @
ae732640
...
...
@@ -2190,27 +2190,30 @@ Calculate necessary cropping parameters and prints the recommended
parameters through the logging system. The detected dimensions
correspond to the non-black area of the input video.
It accepts the syntax:
@example
cropdetect[=@var{limit}[:@var{round}[:@var{reset}]]]
@end example
The filter accepts parameters as a list of @var{key}=@var{value}
pairs, separated by ":". If the key of the first options is omitted,
the arguments are interpreted according to the syntax
[@option{limit}[:@option{round}[:@option{reset}]]].
A description of the accepted options follows.
@table @option
@item limit
Threshold, which can be optionally specified from nothing (0) to
everything (255), defaults to 24.
Set higher black value threshold, which can be optionally specified
from nothing (0) to everything (255). An intensity value greater
to the set value is considered non-black. Default value is 24.
@item round
Value which the width/height should be divisible by, defaults to
16. The offset is automatically adjusted to center the video. Use 2 to
get
only even dimensions (needed for 4:2:2 video). 16 is best when
encoding to most video codecs.
Set the value for which the width/height should be divisible by. The
offset is automatically adjusted to center the video. Use 2 to get
only even dimensions (needed for 4:2:2 video). 16 is best when
encoding to most video codecs.
Default value is 16.
@item reset
Counter that determines after how many frames cropdetect will reset
the previously detected largest video area and start over to detect
the current optimal crop area. Defaults to
0.
Set the counter that determines after how many frames cropdetect will
reset the previously detected largest video area and start over to
detect the current optimal crop area. Default value is
0.
This can be useful when channel logos distort the video area. 0
indicates never reset and return the largest area encountered during
...
...
libavfilter/version.h
View file @
ae732640
...
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 45
#define LIBAVFILTER_VERSION_MICRO 10
1
#define LIBAVFILTER_VERSION_MICRO 10
2
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vf_cropdetect.c
View file @
ae732640
...
...
@@ -23,16 +23,16 @@
* Ported from MPlayer libmpcodecs/vf_cropdetect.c.
*/
#include <stdio.h>
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
typedef
struct
{
const
AVClass
*
class
;
int
x1
,
y1
,
x2
,
y2
;
int
limit
;
int
round
;
...
...
@@ -41,6 +41,18 @@ typedef struct {
int
max_pixsteps
[
4
];
}
CropDetectContext
;
#define OFFSET(x) offsetof(CropDetectContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
cropdetect_options
[]
=
{
{
"limit"
,
"set black threshold"
,
OFFSET
(
limit
),
AV_OPT_TYPE_INT
,
{.
i64
=
24
},
0
,
255
,
FLAGS
},
{
"round"
,
"set width/height round value"
,
OFFSET
(
round
),
AV_OPT_TYPE_INT
,
{.
i64
=
16
},
0
,
INT_MAX
,
FLAGS
},
{
"reset_count"
,
"set after how many frames to reset detected info"
,
OFFSET
(
reset_count
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
INT_MAX
,
FLAGS
},
{
NULL
}
};
AVFILTER_DEFINE_CLASS
(
cropdetect
);
static
int
query_formats
(
AVFilterContext
*
ctx
)
{
static
const
enum
AVPixelFormat
pix_fmts
[]
=
{
...
...
@@ -86,14 +98,15 @@ static int checkline(void *ctx, const unsigned char *src, int stride, int len, i
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
{
CropDetectContext
*
cd
=
ctx
->
priv
;
static
const
char
*
shorthand
[]
=
{
"limit"
,
"round"
,
"reset_count"
,
NULL
};
int
ret
;
cd
->
limit
=
24
;
cd
->
round
=
0
;
cd
->
reset_count
=
0
;
cd
->
frame_nb
=
-
2
;
cd
->
class
=
&
cropdetect_class
;
av_opt_set_defaults
(
cd
);
if
(
args
)
sscanf
(
args
,
"%d:%d:%d"
,
&
cd
->
limit
,
&
cd
->
round
,
&
cd
->
reset_count
)
;
if
(
(
ret
=
av_opt_set_from_string
(
cd
,
args
,
shorthand
,
"="
,
":"
))
<
0
)
return
ret
;
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"limit:%d round:%d reset_count:%d
\n
"
,
cd
->
limit
,
cd
->
round
,
cd
->
reset_count
);
...
...
@@ -101,6 +114,12 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
return
0
;
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
CropDetectContext
*
cd
=
ctx
->
priv
;
av_opt_free
(
cd
);
}
static
int
config_input
(
AVFilterLink
*
inlink
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
...
...
@@ -221,10 +240,9 @@ AVFilter avfilter_vf_cropdetect = {
.
priv_size
=
sizeof
(
CropDetectContext
),
.
init
=
init
,
.
uninit
=
uninit
,
.
query_formats
=
query_formats
,
.
inputs
=
avfilter_vf_cropdetect_inputs
,
.
outputs
=
avfilter_vf_cropdetect_outputs
,
.
priv_class
=
&
cropdetect_class
,
};
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