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
6f3d2fb1
Commit
6f3d2fb1
authored
Nov 29, 2012
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/vf_tile: switch to filter_frame.
Also add error check on buffer allocation.
parent
8be18ffd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
50 deletions
+33
-50
vf_tile.c
libavfilter/vf_tile.c
+33
-50
No files found.
libavfilter/vf_tile.c
View file @
6f3d2fb1
...
...
@@ -126,32 +126,6 @@ static int config_props(AVFilterLink *outlink)
return
0
;
}
/* Note: direct rendering is not possible since there is no guarantee that
* buffers are fed to start_frame in the order they were obtained from
* get_buffer (think B-frames). */
static
int
start_frame
(
AVFilterLink
*
inlink
,
AVFilterBufferRef
*
picref
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
TileContext
*
tile
=
ctx
->
priv
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
if
(
tile
->
current
)
return
0
;
outlink
->
out_buf
=
ff_get_video_buffer
(
outlink
,
AV_PERM_WRITE
,
outlink
->
w
,
outlink
->
h
);
avfilter_copy_buffer_ref_props
(
outlink
->
out_buf
,
picref
);
outlink
->
out_buf
->
video
->
w
=
outlink
->
w
;
outlink
->
out_buf
->
video
->
h
=
outlink
->
h
;
/* fill surface once for margin/padding */
if
(
tile
->
margin
||
tile
->
padding
)
ff_fill_rectangle
(
&
tile
->
draw
,
&
tile
->
blank
,
outlink
->
out_buf
->
data
,
outlink
->
out_buf
->
linesize
,
0
,
0
,
outlink
->
w
,
outlink
->
h
);
return
0
;
}
static
void
get_current_tile_pos
(
AVFilterContext
*
ctx
,
unsigned
*
x
,
unsigned
*
y
)
{
TileContext
*
tile
=
ctx
->
priv
;
...
...
@@ -163,23 +137,6 @@ static void get_current_tile_pos(AVFilterContext *ctx, unsigned *x, unsigned *y)
*
y
=
tile
->
margin
+
(
inlink
->
h
+
tile
->
padding
)
*
ty
;
}
static
int
draw_slice
(
AVFilterLink
*
inlink
,
int
y
,
int
h
,
int
slice_dir
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
TileContext
*
tile
=
ctx
->
priv
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
unsigned
x0
,
y0
;
get_current_tile_pos
(
ctx
,
&
x0
,
&
y0
);
ff_copy_rectangle2
(
&
tile
->
draw
,
outlink
->
out_buf
->
data
,
outlink
->
out_buf
->
linesize
,
inlink
->
cur_buf
->
data
,
inlink
->
cur_buf
->
linesize
,
x0
,
y0
+
y
,
0
,
y
,
inlink
->
cur_buf
->
video
->
w
,
h
);
/* TODO if tile->w == 1 && slice_dir is always 1, we could draw_slice
* immediately. */
return
0
;
}
static
void
draw_blank_frame
(
AVFilterContext
*
ctx
,
AVFilterBufferRef
*
out_buf
)
{
TileContext
*
tile
=
ctx
->
priv
;
...
...
@@ -199,22 +156,50 @@ static void end_last_frame(AVFilterContext *ctx)
AVFilterBufferRef
*
out_buf
=
outlink
->
out_buf
;
outlink
->
out_buf
=
NULL
;
ff_start_frame
(
outlink
,
out_buf
);
while
(
tile
->
current
<
tile
->
nb_frames
)
draw_blank_frame
(
ctx
,
out_buf
);
ff_draw_slice
(
outlink
,
0
,
out_buf
->
video
->
h
,
1
);
ff_end_frame
(
outlink
);
ff_filter_frame
(
outlink
,
out_buf
);
tile
->
current
=
0
;
}
static
int
end_frame
(
AVFilterLink
*
inlink
)
/* Note: direct rendering is not possible since there is no guarantee that
* buffers are fed to filter_frame in the order they were obtained from
* get_buffer (think B-frames). */
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFilterBufferRef
*
picref
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
TileContext
*
tile
=
ctx
->
priv
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
unsigned
x0
,
y0
;
if
(
!
tile
->
current
)
{
outlink
->
out_buf
=
ff_get_video_buffer
(
outlink
,
AV_PERM_WRITE
,
outlink
->
w
,
outlink
->
h
);
if
(
!
outlink
->
out_buf
)
return
AVERROR
(
ENOMEM
);
avfilter_copy_buffer_ref_props
(
outlink
->
out_buf
,
picref
);
outlink
->
out_buf
->
video
->
w
=
outlink
->
w
;
outlink
->
out_buf
->
video
->
h
=
outlink
->
h
;
/* fill surface once for margin/padding */
if
(
tile
->
margin
||
tile
->
padding
)
ff_fill_rectangle
(
&
tile
->
draw
,
&
tile
->
blank
,
outlink
->
out_buf
->
data
,
outlink
->
out_buf
->
linesize
,
0
,
0
,
outlink
->
w
,
outlink
->
h
);
}
get_current_tile_pos
(
ctx
,
&
x0
,
&
y0
);
ff_copy_rectangle2
(
&
tile
->
draw
,
outlink
->
out_buf
->
data
,
outlink
->
out_buf
->
linesize
,
inlink
->
cur_buf
->
data
,
inlink
->
cur_buf
->
linesize
,
x0
,
y0
,
0
,
0
,
inlink
->
w
,
inlink
->
h
);
avfilter_unref_bufferp
(
&
inlink
->
cur_buf
);
if
(
++
tile
->
current
==
tile
->
nb_frames
)
end_last_frame
(
ctx
);
return
0
;
}
...
...
@@ -244,9 +229,7 @@ static const AVFilterPad tile_inputs[] = {
{
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
start_frame
=
start_frame
,
.
draw_slice
=
draw_slice
,
.
end_frame
=
end_frame
,
.
filter_frame
=
filter_frame
,
.
min_perms
=
AV_PERM_READ
,
},
{
NULL
}
...
...
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