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
c47b48c0
Commit
c47b48c0
authored
Nov 10, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_lut3d: add spline 1D interpolation
parent
0bc2326b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
filters.texi
doc/filters.texi
+4
-0
vf_lut3d.c
libavfilter/vf_lut3d.c
+32
-0
No files found.
doc/filters.texi
View file @
c47b48c0
...
...
@@ -11442,8 +11442,12 @@ Available values are:
Use values from the nearest defined point.
@item linear
Interpolate values using the linear interpolation.
@item cosine
Interpolate values using the cosine interpolation.
@item cubic
Interpolate values using the cubic interpolation.
@item spline
Interpolate values using the spline interpolation.
@end table
@end table
...
...
libavfilter/vf_lut3d.c
View file @
c47b48c0
...
...
@@ -986,6 +986,7 @@ enum interp_1d_mode {
INTERPOLATE_1D_LINEAR
,
INTERPOLATE_1D_CUBIC
,
INTERPOLATE_1D_COSINE
,
INTERPOLATE_1D_SPLINE
,
NB_INTERP_1D_MODE
};
...
...
@@ -1077,6 +1078,7 @@ static const AVOption lut1d_options[] = {
{
"linear"
,
"use values from the linear interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
INTERPOLATE_1D_LINEAR
},
INT_MIN
,
INT_MAX
,
FLAGS
,
"interp_mode"
},
{
"cosine"
,
"use values from the cosine interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
INTERPOLATE_1D_COSINE
},
INT_MIN
,
INT_MAX
,
FLAGS
,
"interp_mode"
},
{
"cubic"
,
"use values from the cubic interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
INTERPOLATE_1D_CUBIC
},
INT_MIN
,
INT_MAX
,
FLAGS
,
"interp_mode"
},
{
"spline"
,
"use values from the spline interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
INTERPOLATE_1D_SPLINE
},
INT_MIN
,
INT_MAX
,
FLAGS
,
"interp_mode"
},
{
NULL
}
};
...
...
@@ -1138,6 +1140,27 @@ static inline float interp_1d_cubic(const LUT1DContext *lut1d,
return
a0
*
mu
*
mu2
+
a1
*
mu2
+
a2
*
mu
+
a3
;
}
static
inline
float
interp_1d_spline
(
const
LUT1DContext
*
lut1d
,
int
idx
,
const
float
s
)
{
const
int
prev
=
PREV
(
s
);
const
int
next
=
NEXT1D
(
s
);
const
float
x
=
s
-
prev
;
float
c0
,
c1
,
c2
,
c3
;
float
y0
=
lut1d
->
lut
[
idx
][
FFMAX
(
prev
-
1
,
0
)];
float
y1
=
lut1d
->
lut
[
idx
][
prev
];
float
y2
=
lut1d
->
lut
[
idx
][
next
];
float
y3
=
lut1d
->
lut
[
idx
][
FFMIN
(
next
+
1
,
lut1d
->
lutsize
-
1
)];
c0
=
y1
;
c1
=
.
5
f
*
(
y2
-
y0
);
c2
=
y0
-
2
.
5
f
*
y1
+
2
.
f
*
y2
-
.
5
f
*
y3
;
c3
=
.
5
f
*
(
y3
-
y0
)
+
1
.
5
f
*
(
y1
-
y2
);
return
((
c3
*
x
+
c2
)
*
x
+
c1
)
*
x
+
c0
;
}
#define DEFINE_INTERP_FUNC_PLANAR_1D(name, nbits, depth) \
static int interp_1d_##nbits##_##name##_p##depth(AVFilterContext *ctx, \
void *arg, int jobnr, \
...
...
@@ -1200,31 +1223,37 @@ DEFINE_INTERP_FUNC_PLANAR_1D(nearest, 8, 8)
DEFINE_INTERP_FUNC_PLANAR_1D
(
linear
,
8
,
8
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cosine
,
8
,
8
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cubic
,
8
,
8
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
spline
,
8
,
8
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
nearest
,
16
,
9
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
linear
,
16
,
9
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cosine
,
16
,
9
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cubic
,
16
,
9
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
spline
,
16
,
9
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
nearest
,
16
,
10
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
linear
,
16
,
10
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cosine
,
16
,
10
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cubic
,
16
,
10
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
spline
,
16
,
10
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
nearest
,
16
,
12
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
linear
,
16
,
12
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cosine
,
16
,
12
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cubic
,
16
,
12
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
spline
,
16
,
12
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
nearest
,
16
,
14
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
linear
,
16
,
14
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cosine
,
16
,
14
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cubic
,
16
,
14
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
spline
,
16
,
14
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
nearest
,
16
,
16
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
linear
,
16
,
16
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cosine
,
16
,
16
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
cubic
,
16
,
16
)
DEFINE_INTERP_FUNC_PLANAR_1D
(
spline
,
16
,
16
)
#define DEFINE_INTERP_FUNC_1D(name, nbits) \
static int interp_1d_##nbits##_##name(AVFilterContext *ctx, void *arg, \
...
...
@@ -1274,11 +1303,13 @@ DEFINE_INTERP_FUNC_1D(nearest, 8)
DEFINE_INTERP_FUNC_1D
(
linear
,
8
)
DEFINE_INTERP_FUNC_1D
(
cosine
,
8
)
DEFINE_INTERP_FUNC_1D
(
cubic
,
8
)
DEFINE_INTERP_FUNC_1D
(
spline
,
8
)
DEFINE_INTERP_FUNC_1D
(
nearest
,
16
)
DEFINE_INTERP_FUNC_1D
(
linear
,
16
)
DEFINE_INTERP_FUNC_1D
(
cosine
,
16
)
DEFINE_INTERP_FUNC_1D
(
cubic
,
16
)
DEFINE_INTERP_FUNC_1D
(
spline
,
16
)
static
int
config_input_1d
(
AVFilterLink
*
inlink
)
{
...
...
@@ -1332,6 +1363,7 @@ static int config_input_1d(AVFilterLink *inlink)
case
INTERPOLATE_1D_LINEAR
:
SET_FUNC_1D
(
linear
);
break
;
case
INTERPOLATE_1D_COSINE
:
SET_FUNC_1D
(
cosine
);
break
;
case
INTERPOLATE_1D_CUBIC
:
SET_FUNC_1D
(
cubic
);
break
;
case
INTERPOLATE_1D_SPLINE
:
SET_FUNC_1D
(
spline
);
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