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
f49cb8e6
Commit
f49cb8e6
authored
Mar 10, 2012
by
Baptiste Coudurier
Committed by
Michael Niedermayer
Mar 11, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_crop: keepaspect support
parent
84b9b4aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
vf_crop.c
libavfilter/vf_crop.c
+13
-1
No files found.
libavfilter/vf_crop.c
View file @
f49cb8e6
...
...
@@ -74,6 +74,9 @@ typedef struct {
int
w
;
///< width of the cropped area
int
h
;
///< height of the cropped area
AVRational
out_sar
;
///< output sample aspect ratio
int
keep_aspect
;
///< keep display aspect ratio when cropping
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
];
...
...
@@ -124,7 +127,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
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
);
sscanf
(
args
,
"%255[^:]:%255[^:]:%255[^:]:%255[^:]
:%d"
,
crop
->
ow_expr
,
crop
->
oh_expr
,
crop
->
x_expr
,
crop
->
y_expr
,
&
crop
->
keep_aspect
);
return
0
;
}
...
...
@@ -210,6 +213,14 @@ static int config_input(AVFilterLink *link)
NULL
,
NULL
,
NULL
,
NULL
,
0
,
ctx
))
<
0
)
return
AVERROR
(
EINVAL
);
if
(
crop
->
keep_aspect
)
{
AVRational
dar
=
av_mul_q
(
link
->
sample_aspect_ratio
,
(
AVRational
){
link
->
w
,
link
->
h
});
av_reduce
(
&
crop
->
out_sar
.
num
,
&
crop
->
out_sar
.
den
,
dar
.
num
*
crop
->
h
,
dar
.
den
*
crop
->
w
,
INT_MAX
);
}
else
crop
->
out_sar
=
link
->
sample_aspect_ratio
;
av_log
(
ctx
,
AV_LOG_INFO
,
"w:%d h:%d -> w:%d h:%d
\n
"
,
link
->
w
,
link
->
h
,
crop
->
w
,
crop
->
h
);
...
...
@@ -239,6 +250,7 @@ static int config_output(AVFilterLink *link)
link
->
w
=
crop
->
w
;
link
->
h
=
crop
->
h
;
link
->
sample_aspect_ratio
=
crop
->
out_sar
;
return
0
;
}
...
...
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