Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
fba0156a
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fba0156a
编写于
2月 25, 2013
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vf_crop: switch to an AVOptions-based system.
上级
51def31d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
26 deletion
+50
-26
doc/filters.texi
doc/filters.texi
+27
-9
libavfilter/vf_crop.c
libavfilter/vf_crop.c
+23
-17
未找到文件。
doc/filters.texi
浏览文件 @
fba0156a
...
...
@@ -623,7 +623,25 @@ testing purposes.
@section crop
Crop the input video to @var{out_w}:@var{out_h}:@var{x}:@var{y}.
Crop the input video to given dimensions.
This filter accepts the following options:
@table @option
@item out_w
Width of the output video.
@item out_h
Height of the output video.
@item x
Horizontal position, in the input video, of the left edge of the output video.
@item y
Vertical position, in the input video, of the top edge of the output video.
@end table
The parameters are expressions containing the following constants:
...
...
@@ -683,34 +701,34 @@ for @var{y} may depend on @var{x}.
Follow some examples:
@example
# crop the central input area with size 100x100
crop=
100:
100
crop=
out_w=100:out_h=
100
# crop the central input area with size 2/3 of the input video
"crop=
2/3*in_w:
2/3*in_h"
"crop=
out_w=2/3*in_w:out_h=
2/3*in_h"
# crop the input video central square
crop=in_h
crop=
out_w=
in_h
# delimit the rectangle with the top-left corner placed at position
# 100:100 and the right-bottom corner corresponding to the right-bottom
# corner of the input image.
crop=
in_w-100:in_h-100:100:
100
crop=
out_w=in_w-100:out_h=in_h-100:x=100:y=
100
# crop 10 pixels from the left and right borders, and 20 pixels from
# the top and bottom borders
"crop=
in_w-2*10:
in_h-2*20"
"crop=
out_w=in_w-2*10:out_h=
in_h-2*20"
# keep only the bottom right quarter of the input image
"crop=
in_w/2:in_h/2:in_w/2:
in_h/2"
"crop=
out_w=in_w/2:out_h=in_h/2:x=in_w/2:y=
in_h/2"
# crop height for getting Greek harmony
"crop=
in_w:
1/PHI*in_w"
"crop=
out_w=in_w:out_h=
1/PHI*in_w"
# trembling effect
"crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(n/10):(in_h-out_h)/2 +((in_h-out_h)/2)*sin(n/7)"
# erratic camera effect depending on timestamp
"crop=
in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(t*10):
(in_h-out_h)/2 +((in_h-out_h)/2)*sin(t*13)"
"crop=
out_w=in_w/2:out_h=in_h/2:x=(in_w-out_w)/2+((in_w-out_w)/2)*sin(t*10):y=
(in_h-out_h)/2 +((in_h-out_h)/2)*sin(t*13)"
# set x depending on the value of y
"crop=in_w/2:in_h/2:y:10+10*sin(n/10)"
...
...
libavfilter/vf_crop.c
浏览文件 @
fba0156a
...
...
@@ -37,6 +37,7 @@
#include "libavutil/libm.h"
#include "libavutil/imgutils.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
static
const
char
*
const
var_names
[]
=
{
"E"
,
...
...
@@ -70,6 +71,7 @@ enum var_name {
};
typedef
struct
{
const
AVClass
*
class
;
int
x
;
///< x offset of the non-cropped area with respect to the input area
int
y
;
///< y offset of the non-cropped area with respect to the input area
int
w
;
///< width of the cropped area
...
...
@@ -77,7 +79,7 @@ typedef struct {
int
max_step
[
4
];
///< max pixel step for each plane, expressed as a number of bytes
int
hsub
,
vsub
;
///< chroma subsampling
char
x_expr
[
256
],
y_expr
[
256
],
ow_expr
[
256
],
oh_expr
[
256
]
;
char
*
x_expr
,
*
y_expr
,
*
ow_expr
,
*
oh_expr
;
AVExpr
*
x_pexpr
,
*
y_pexpr
;
/* parsed expressions for x and y */
double
var_values
[
VAR_VARS_NB
];
}
CropContext
;
...
...
@@ -115,21 +117,6 @@ static int query_formats(AVFilterContext *ctx)
return
0
;
}
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
{
CropContext
*
crop
=
ctx
->
priv
;
av_strlcpy
(
crop
->
ow_expr
,
"iw"
,
sizeof
(
crop
->
ow_expr
));
av_strlcpy
(
crop
->
oh_expr
,
"ih"
,
sizeof
(
crop
->
oh_expr
));
av_strlcpy
(
crop
->
x_expr
,
"(in_w-out_w)/2"
,
sizeof
(
crop
->
x_expr
));
av_strlcpy
(
crop
->
y_expr
,
"(in_h-out_h)/2"
,
sizeof
(
crop
->
y_expr
));
if
(
args
)
sscanf
(
args
,
"%255[^:]:%255[^:]:%255[^:]:%255[^:]"
,
crop
->
ow_expr
,
crop
->
oh_expr
,
crop
->
x_expr
,
crop
->
y_expr
);
return
0
;
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
CropContext
*
crop
=
ctx
->
priv
;
...
...
@@ -294,6 +281,25 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
return
ff_filter_frame
(
link
->
dst
->
outputs
[
0
],
frame
);
}
#define OFFSET(x) offsetof(CropContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
static
const
AVOption
options
[]
=
{
{
"out_w"
,
"Output video width"
,
OFFSET
(
ow_expr
),
AV_OPT_TYPE_STRING
,
{
.
str
=
"iw"
},
.
flags
=
FLAGS
},
{
"out_h"
,
"Output video height"
,
OFFSET
(
oh_expr
),
AV_OPT_TYPE_STRING
,
{
.
str
=
"ih"
},
.
flags
=
FLAGS
},
{
"x"
,
"Horizontal position in the input video of the left edge of the cropped output video"
,
OFFSET
(
x_expr
),
AV_OPT_TYPE_STRING
,
{
.
str
=
"(in_w - out_w) / 2"
},
.
flags
=
FLAGS
},
{
"y"
,
"Vertical position in the input video of the top edge of the cropped output video"
,
OFFSET
(
y_expr
),
AV_OPT_TYPE_STRING
,
{
.
str
=
"(in_h - out_h) / 2"
},
.
flags
=
FLAGS
},
{
NULL
},
};
static
const
AVClass
crop_class
=
{
.
class_name
=
"crop"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
const
AVFilterPad
avfilter_vf_crop_inputs
[]
=
{
{
.
name
=
"default"
,
...
...
@@ -319,9 +325,9 @@ AVFilter avfilter_vf_crop = {
.
description
=
NULL_IF_CONFIG_SMALL
(
"Crop the input video to width:height:x:y."
),
.
priv_size
=
sizeof
(
CropContext
),
.
priv_class
=
&
crop_class
,
.
query_formats
=
query_formats
,
.
init
=
init
,
.
uninit
=
uninit
,
.
inputs
=
avfilter_vf_crop_inputs
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录