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
5b5746b1
Commit
5b5746b1
authored
Aug 08, 2019
by
Jarek Samic
Committed by
Mark Thompson
Aug 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi: modify avfilter_get_matrix to support separate scale factors
parent
d3cd33ab
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
16 deletions
+34
-16
transform.c
libavfilter/transform.c
+10
-3
transform.h
libavfilter/transform.h
+19
-11
vf_deshake.c
libavfilter/vf_deshake.c
+5
-2
No files found.
libavfilter/transform.c
View file @
5b5746b1
...
@@ -103,12 +103,19 @@ INTERPOLATE_METHOD(interpolate_biquadratic)
...
@@ -103,12 +103,19 @@ INTERPOLATE_METHOD(interpolate_biquadratic)
}
}
}
}
void
avfilter_get_matrix
(
float
x_shift
,
float
y_shift
,
float
angle
,
float
zoom
,
float
*
matrix
)
{
void
ff_get_matrix
(
matrix
[
0
]
=
zoom
*
cos
(
angle
);
float
x_shift
,
float
y_shift
,
float
angle
,
float
scale_x
,
float
scale_y
,
float
*
matrix
)
{
matrix
[
0
]
=
scale_x
*
cos
(
angle
);
matrix
[
1
]
=
-
sin
(
angle
);
matrix
[
1
]
=
-
sin
(
angle
);
matrix
[
2
]
=
x_shift
;
matrix
[
2
]
=
x_shift
;
matrix
[
3
]
=
-
matrix
[
1
];
matrix
[
3
]
=
-
matrix
[
1
];
matrix
[
4
]
=
matrix
[
0
]
;
matrix
[
4
]
=
scale_y
*
cos
(
angle
)
;
matrix
[
5
]
=
y_shift
;
matrix
[
5
]
=
y_shift
;
matrix
[
6
]
=
0
;
matrix
[
6
]
=
0
;
matrix
[
7
]
=
0
;
matrix
[
7
]
=
0
;
...
...
libavfilter/transform.h
View file @
5b5746b1
...
@@ -60,20 +60,28 @@ enum FillMethod {
...
@@ -60,20 +60,28 @@ enum FillMethod {
#define FILL_DEFAULT FILL_ORIGINAL
#define FILL_DEFAULT FILL_ORIGINAL
/**
/**
* Get an affine transformation matrix from
a
given translation, rotation, and
* Get an affine transformation matrix from given translation, rotation, and
* zoom factor. The matrix will look like:
* zoom factor
s
. The matrix will look like:
*
*
* [
zoom
* cos(angle), -sin(angle), x_shift,
* [
scale_x
* cos(angle), -sin(angle), x_shift,
*
sin(angle), zoom
* cos(angle), y_shift,
*
sin(angle), scale_y
* cos(angle), y_shift,
* 0, 0, 1 ]
* 0, 0, 1 ]
*
*
* @param x_shift horizontal translation
* @param x_shift horizontal translation
* @param y_shift vertical translation
* @param y_shift vertical translation
* @param angle rotation in radians
* @param angle rotation in radians
* @param zoom scale percent (1.0 = 100%)
* @param scale_x x scale percent (1.0 = 100%)
* @param scale_y y scale percent (1.0 = 100%)
* @param matrix 9-item affine transformation matrix
* @param matrix 9-item affine transformation matrix
*/
*/
void
avfilter_get_matrix
(
float
x_shift
,
float
y_shift
,
float
angle
,
float
zoom
,
float
*
matrix
);
void
ff_get_matrix
(
float
x_shift
,
float
y_shift
,
float
angle
,
float
scale_x
,
float
scale_y
,
float
*
matrix
);
/**
/**
* Add two matrices together. result = m1 + m2.
* Add two matrices together. result = m1 + m2.
...
...
libavfilter/vf_deshake.c
View file @
5b5746b1
...
@@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
...
@@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
const
int
chroma_width
=
AV_CEIL_RSHIFT
(
link
->
w
,
desc
->
log2_chroma_w
);
const
int
chroma_width
=
AV_CEIL_RSHIFT
(
link
->
w
,
desc
->
log2_chroma_w
);
const
int
chroma_height
=
AV_CEIL_RSHIFT
(
link
->
h
,
desc
->
log2_chroma_h
);
const
int
chroma_height
=
AV_CEIL_RSHIFT
(
link
->
h
,
desc
->
log2_chroma_h
);
int
aligned
;
int
aligned
;
float
transform_zoom
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
if
(
!
out
)
{
...
@@ -505,10 +506,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
...
@@ -505,10 +506,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
deshake
->
last
.
angle
=
t
.
angle
;
deshake
->
last
.
angle
=
t
.
angle
;
deshake
->
last
.
zoom
=
t
.
zoom
;
deshake
->
last
.
zoom
=
t
.
zoom
;
transform_zoom
=
1
.
0
+
t
.
zoom
/
100
.
0
;
// Generate a luma transformation matrix
// Generate a luma transformation matrix
avfilter_get_matrix
(
t
.
vec
.
x
,
t
.
vec
.
y
,
t
.
angle
,
1
.
0
+
t
.
zoom
/
100
.
0
,
matrix_y
);
ff_get_matrix
(
t
.
vec
.
x
,
t
.
vec
.
y
,
t
.
angle
,
transform_zoom
,
transform_zoom
,
matrix_y
);
// Generate a chroma transformation matrix
// Generate a chroma transformation matrix
avfilter_get_matrix
(
t
.
vec
.
x
/
(
link
->
w
/
chroma_width
),
t
.
vec
.
y
/
(
link
->
h
/
chroma_height
),
t
.
angle
,
1
.
0
+
t
.
zoom
/
100
.
0
,
matrix_uv
);
ff_get_matrix
(
t
.
vec
.
x
/
(
link
->
w
/
chroma_width
),
t
.
vec
.
y
/
(
link
->
h
/
chroma_height
),
t
.
angle
,
transform_zoom
,
transform_zoom
,
matrix_uv
);
// Transform the luma and chroma planes
// Transform the luma and chroma planes
ret
=
deshake
->
transform
(
link
->
dst
,
link
->
w
,
link
->
h
,
chroma_width
,
chroma_height
,
ret
=
deshake
->
transform
(
link
->
dst
,
link
->
w
,
link
->
h
,
chroma_width
,
chroma_height
,
matrix_y
,
matrix_uv
,
INTERPOLATE_BILINEAR
,
deshake
->
edge
,
in
,
out
);
matrix_y
,
matrix_uv
,
INTERPOLATE_BILINEAR
,
deshake
->
edge
,
in
,
out
);
...
...
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