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
71f82c38
Commit
71f82c38
authored
Nov 28, 2012
by
Anton Khirnov
Committed by
Michael Niedermayer
Nov 28, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_crop: switch to filter_frame
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
a42b8991
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
48 deletions
+17
-48
vf_crop.c
libavfilter/vf_crop.c
+17
-48
No files found.
libavfilter/vf_crop.c
View file @
71f82c38
...
...
@@ -262,24 +262,19 @@ static int config_output(AVFilterLink *link)
return
0
;
}
static
int
start_frame
(
AVFilterLink
*
link
,
AVFilterBufferRef
*
picref
)
static
int
filter_frame
(
AVFilterLink
*
link
,
AVFilterBufferRef
*
frame
)
{
AVFilterContext
*
ctx
=
link
->
dst
;
CropContext
*
crop
=
ctx
->
priv
;
AVFilterBufferRef
*
ref2
;
const
AVPixFmtDescriptor
*
desc
=
av_pix_fmt_desc_get
(
link
->
format
);
int
i
;
ref2
=
avfilter_ref_buffer
(
picref
,
~
0
);
if
(
!
ref2
)
return
AVERROR
(
ENOMEM
);
frame
->
video
->
w
=
crop
->
w
;
frame
->
video
->
h
=
crop
->
h
;
ref2
->
video
->
w
=
crop
->
w
;
ref2
->
video
->
h
=
crop
->
h
;
crop
->
var_values
[
VAR_T
]
=
picref
->
pts
==
AV_NOPTS_VALUE
?
NAN
:
picref
->
pts
*
av_q2d
(
link
->
time_base
);
crop
->
var_values
[
VAR_POS
]
=
picref
->
pos
==
-
1
?
NAN
:
picref
->
pos
;
crop
->
var_values
[
VAR_T
]
=
frame
->
pts
==
AV_NOPTS_VALUE
?
NAN
:
frame
->
pts
*
av_q2d
(
link
->
time_base
);
crop
->
var_values
[
VAR_POS
]
=
frame
->
pos
==
-
1
?
NAN
:
frame
->
pos
;
crop
->
var_values
[
VAR_X
]
=
av_expr_eval
(
crop
->
x_pexpr
,
crop
->
var_values
,
NULL
);
crop
->
var_values
[
VAR_Y
]
=
av_expr_eval
(
crop
->
y_pexpr
,
crop
->
var_values
,
NULL
);
crop
->
var_values
[
VAR_X
]
=
av_expr_eval
(
crop
->
x_pexpr
,
crop
->
var_values
,
NULL
);
...
...
@@ -298,60 +293,34 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
(
int
)
crop
->
var_values
[
VAR_N
],
crop
->
var_values
[
VAR_T
],
crop
->
x
,
crop
->
y
,
crop
->
x
+
crop
->
w
,
crop
->
y
+
crop
->
h
);
ref2
->
data
[
0
]
+=
crop
->
y
*
ref2
->
linesize
[
0
];
ref2
->
data
[
0
]
+=
crop
->
x
*
crop
->
max_step
[
0
];
frame
->
data
[
0
]
+=
crop
->
y
*
frame
->
linesize
[
0
];
frame
->
data
[
0
]
+=
crop
->
x
*
crop
->
max_step
[
0
];
if
(
!
(
desc
->
flags
&
PIX_FMT_PAL
||
desc
->
flags
&
PIX_FMT_PSEUDOPAL
))
{
for
(
i
=
1
;
i
<
3
;
i
++
)
{
if
(
ref2
->
data
[
i
])
{
ref2
->
data
[
i
]
+=
(
crop
->
y
>>
crop
->
vsub
)
*
ref2
->
linesize
[
i
];
ref2
->
data
[
i
]
+=
(
crop
->
x
*
crop
->
max_step
[
i
])
>>
crop
->
hsub
;
if
(
frame
->
data
[
i
])
{
frame
->
data
[
i
]
+=
(
crop
->
y
>>
crop
->
vsub
)
*
frame
->
linesize
[
i
];
frame
->
data
[
i
]
+=
(
crop
->
x
*
crop
->
max_step
[
i
])
>>
crop
->
hsub
;
}
}
}
/* alpha plane */
if
(
ref2
->
data
[
3
])
{
ref2
->
data
[
3
]
+=
crop
->
y
*
ref2
->
linesize
[
3
];
ref2
->
data
[
3
]
+=
crop
->
x
*
crop
->
max_step
[
3
];
if
(
frame
->
data
[
3
])
{
frame
->
data
[
3
]
+=
crop
->
y
*
frame
->
linesize
[
3
];
frame
->
data
[
3
]
+=
crop
->
x
*
crop
->
max_step
[
3
];
}
return
ff_start_frame
(
link
->
dst
->
outputs
[
0
],
ref2
);
}
static
int
draw_slice
(
AVFilterLink
*
link
,
int
y
,
int
h
,
int
slice_dir
)
{
AVFilterContext
*
ctx
=
link
->
dst
;
CropContext
*
crop
=
ctx
->
priv
;
if
(
y
>=
crop
->
y
+
crop
->
h
||
y
+
h
<=
crop
->
y
)
return
0
;
if
(
y
<
crop
->
y
)
{
h
-=
crop
->
y
-
y
;
y
=
crop
->
y
;
}
if
(
y
+
h
>
crop
->
y
+
crop
->
h
)
h
=
crop
->
y
+
crop
->
h
-
y
;
return
ff_draw_slice
(
ctx
->
outputs
[
0
],
y
-
crop
->
y
,
h
,
slice_dir
);
}
static
int
end_frame
(
AVFilterLink
*
link
)
{
CropContext
*
crop
=
link
->
dst
->
priv
;
crop
->
var_values
[
VAR_N
]
+=
1
.
0
;
return
ff_end_frame
(
link
->
dst
->
outputs
[
0
]);
return
ff_filter_frame
(
link
->
dst
->
outputs
[
0
],
frame
);
}
static
const
AVFilterPad
avfilter_vf_crop_inputs
[]
=
{
{
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
start_frame
=
start_frame
,
.
draw_slice
=
draw_slice
,
.
end_frame
=
end_frame
,
.
filter_frame
=
filter_frame
,
.
get_video_buffer
=
ff_null_get_video_buffer
,
.
config_props
=
config_input
,
},
...
...
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