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
ecfaff35
Commit
ecfaff35
authored
Nov 11, 2012
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/tile: add margin and padding options.
parent
aa5a0290
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
8 deletions
+33
-8
vf_tile.c
libavfilter/vf_tile.c
+33
-8
No files found.
libavfilter/vf_tile.c
View file @
ecfaff35
...
...
@@ -34,6 +34,8 @@
typedef
struct
{
const
AVClass
*
class
;
unsigned
w
,
h
;
unsigned
margin
;
unsigned
padding
;
unsigned
current
;
FFDrawContext
draw
;
FFDrawColor
blank
;
...
...
@@ -47,6 +49,10 @@ typedef struct {
static
const
AVOption
tile_options
[]
=
{
{
"layout"
,
"set grid size"
,
OFFSET
(
w
),
AV_OPT_TYPE_IMAGE_SIZE
,
{.
str
=
"6x5"
},
0
,
0
,
FLAGS
},
{
"margin"
,
"set outer border margin in pixels"
,
OFFSET
(
margin
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1024
,
FLAGS
},
{
"padding"
,
"set inner border thickness in pixels"
,
OFFSET
(
padding
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
1024
,
FLAGS
},
{
NULL
},
};
...
...
@@ -83,19 +89,21 @@ static int config_props(AVFilterLink *outlink)
AVFilterContext
*
ctx
=
outlink
->
src
;
TileContext
*
tile
=
ctx
->
priv
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
const
unsigned
total_margin_w
=
(
tile
->
w
-
1
)
*
tile
->
padding
+
2
*
tile
->
margin
;
const
unsigned
total_margin_h
=
(
tile
->
h
-
1
)
*
tile
->
padding
+
2
*
tile
->
margin
;
if
(
inlink
->
w
>
INT_MAX
/
tile
->
w
)
{
if
(
inlink
->
w
>
(
INT_MAX
-
total_margin_w
)
/
tile
->
w
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Total width %ux%u is too much.
\n
"
,
tile
->
w
,
inlink
->
w
);
return
AVERROR
(
EINVAL
);
}
if
(
inlink
->
h
>
INT_MAX
/
tile
->
h
)
{
if
(
inlink
->
h
>
(
INT_MAX
-
total_margin_h
)
/
tile
->
h
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Total height %ux%u is too much.
\n
"
,
tile
->
h
,
inlink
->
h
);
return
AVERROR
(
EINVAL
);
}
outlink
->
w
=
tile
->
w
*
inlink
->
w
;
outlink
->
h
=
tile
->
h
*
inlink
->
h
;
outlink
->
w
=
tile
->
w
*
inlink
->
w
+
total_margin_w
;
outlink
->
h
=
tile
->
h
*
inlink
->
h
+
total_margin_h
;
outlink
->
sample_aspect_ratio
=
inlink
->
sample_aspect_ratio
;
outlink
->
frame_rate
=
av_mul_q
(
inlink
->
frame_rate
,
(
AVRational
){
1
,
tile
->
w
*
tile
->
h
});
...
...
@@ -123,17 +131,34 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
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
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
const
unsigned
tx
=
tile
->
current
%
tile
->
w
;
const
unsigned
ty
=
tile
->
current
/
tile
->
w
;
*
x
=
tile
->
margin
+
(
inlink
->
w
+
tile
->
padding
)
*
tx
;
*
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
=
inlink
->
w
*
(
tile
->
current
%
tile
->
w
);
unsigned
y0
=
inlink
->
h
*
(
tile
->
current
/
tile
->
w
);
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
,
...
...
@@ -147,9 +172,9 @@ static void draw_blank_frame(AVFilterContext *ctx, AVFilterBufferRef *out_buf)
{
TileContext
*
tile
=
ctx
->
priv
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
unsigned
x0
=
inlink
->
w
*
(
tile
->
current
%
tile
->
w
);
unsigned
y0
=
inlink
->
h
*
(
tile
->
current
/
tile
->
w
);
unsigned
x0
,
y0
;
get_current_tile_pos
(
ctx
,
&
x0
,
&
y0
);
ff_fill_rectangle
(
&
tile
->
draw
,
&
tile
->
blank
,
out_buf
->
data
,
out_buf
->
linesize
,
x0
,
y0
,
inlink
->
w
,
inlink
->
h
);
...
...
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