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
aa42a1e6
Commit
aa42a1e6
authored
Jan 17, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add spline16 interpolation
parent
b3cfbd71
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
filters.texi
doc/filters.texi
+3
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+52
-0
No files found.
doc/filters.texi
View file @
aa42a1e6
...
...
@@ -19024,6 +19024,9 @@ Bicubic interpolation.
@item lanc
@item lanczos
Lanczos interpolation.
@item sp16
@item spline16
Spline16 interpolation.
@end table
Default value is @b{@samp{line}}.
...
...
libavfilter/v360.h
View file @
aa42a1e6
...
...
@@ -54,6 +54,7 @@ enum InterpMethod {
BILINEAR
,
BICUBIC
,
LANCZOS
,
SPLINE16
,
NB_INTERP_METHODS
,
};
...
...
libavfilter/vf_v360.c
View file @
aa42a1e6
...
...
@@ -99,6 +99,8 @@ static const AVOption v360_options[] = {
{
"cubic"
,
"bicubic interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BICUBIC
},
0
,
0
,
FLAGS
,
"interp"
},
{
"lanc"
,
"lanczos interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LANCZOS
},
0
,
0
,
FLAGS
,
"interp"
},
{
"lanczos"
,
"lanczos interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LANCZOS
},
0
,
0
,
FLAGS
,
"interp"
},
{
"sp16"
,
"spline16 interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SPLINE16
},
0
,
0
,
FLAGS
,
"interp"
},
{
"spline16"
,
"spline16 interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SPLINE16
},
0
,
0
,
FLAGS
,
"interp"
},
{
"w"
,
"output width"
,
OFFSET
(
width
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
INT16_MAX
,
FLAGS
,
"w"
},
{
"h"
,
"output height"
,
OFFSET
(
height
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
INT16_MAX
,
FLAGS
,
"h"
},
{
"in_stereo"
,
"input stereo format"
,
OFFSET
(
in_stereo
),
AV_OPT_TYPE_INT
,
{.
i64
=
STEREO_2D
},
0
,
NB_STEREO_FMTS
-
1
,
FLAGS
,
"stereo"
},
...
...
@@ -314,6 +316,7 @@ void ff_v360_init(V360Context *s, int depth)
break
;
case
BICUBIC
:
case
LANCZOS
:
case
SPLINE16
:
s
->
remap_line
=
depth
<=
8
?
remap4_8bit_line_c
:
remap4_16bit_line_c
;
break
;
}
...
...
@@ -466,6 +469,48 @@ static void lanczos_kernel(float du, float dv, const XYRemap *rmap,
}
}
/**
* Calculate 1-dimensional spline16 coefficients.
*
* @param t relative coordinate
* @param coeffs coefficients
*/
static
void
calculate_spline16_coeffs
(
float
t
,
float
*
coeffs
)
{
coeffs
[
0
]
=
((
-
1
.
f
/
3
.
f
*
t
+
0
.
8
f
)
*
t
-
7
.
f
/
15
.
f
)
*
t
;
coeffs
[
1
]
=
((
t
-
9
.
f
/
5
.
f
)
*
t
-
0
.
2
f
)
*
t
+
1
.
f
;
coeffs
[
2
]
=
((
6
.
f
/
5
.
f
-
t
)
*
t
+
0
.
8
f
)
*
t
;
coeffs
[
3
]
=
((
1
.
f
/
3
.
f
*
t
-
0
.
2
f
)
*
t
-
2
.
f
/
15
.
f
)
*
t
;
}
/**
* Calculate kernel for spline16 interpolation.
*
* @param du horizontal relative coordinate
* @param dv vertical relative coordinate
* @param rmap calculated 4x4 window
* @param u u remap data
* @param v v remap data
* @param ker ker remap data
*/
static
void
spline16_kernel
(
float
du
,
float
dv
,
const
XYRemap
*
rmap
,
uint16_t
*
u
,
uint16_t
*
v
,
int16_t
*
ker
)
{
float
du_coeffs
[
4
];
float
dv_coeffs
[
4
];
calculate_spline16_coeffs
(
du
,
du_coeffs
);
calculate_spline16_coeffs
(
dv
,
dv_coeffs
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
u
[
i
*
4
+
j
]
=
rmap
->
u
[
i
][
j
];
v
[
i
*
4
+
j
]
=
rmap
->
v
[
i
][
j
];
ker
[
i
*
4
+
j
]
=
lrintf
(
du_coeffs
[
j
]
*
dv_coeffs
[
i
]
*
16385
.
f
);
}
}
}
/**
* Modulo operation with only positive remainders.
*
...
...
@@ -2681,6 +2726,13 @@ static int config_output(AVFilterLink *outlink)
sizeof_uv
=
sizeof
(
uint16_t
)
*
s
->
elements
;
sizeof_ker
=
sizeof
(
uint16_t
)
*
s
->
elements
;
break
;
case
SPLINE16
:
s
->
calculate_kernel
=
spline16_kernel
;
s
->
remap_slice
=
depth
<=
8
?
remap4_8bit_slice
:
remap4_16bit_slice
;
s
->
elements
=
4
*
4
;
sizeof_uv
=
sizeof
(
uint16_t
)
*
s
->
elements
;
sizeof_ker
=
sizeof
(
uint16_t
)
*
s
->
elements
;
break
;
default
:
av_assert0
(
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