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
b00b935d
Commit
b00b935d
authored
Mar 31, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add lagrange9 interpolation
parent
7039045c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
0 deletions
+59
-0
filters.texi
doc/filters.texi
+2
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+56
-0
No files found.
doc/filters.texi
View file @
b00b935d
...
...
@@ -19105,6 +19105,8 @@ Nearest neighbour.
@
item
line
@
item
linear
Bilinear
interpolation
.
@
item
lagrange9
Lagrange9
interpolation
.
@
item
cube
@
item
cubic
Bicubic
interpolation
.
...
...
libavfilter/v360.h
View file @
b00b935d
...
...
@@ -57,6 +57,7 @@ enum Projections {
enum
InterpMethod
{
NEAREST
,
BILINEAR
,
LAGRANGE9
,
BICUBIC
,
LANCZOS
,
SPLINE16
,
...
...
libavfilter/vf_v360.c
View file @
b00b935d
...
...
@@ -112,6 +112,7 @@ static const AVOption v360_options[] = {
{
"nearest"
,
"nearest neighbour"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NEAREST
},
0
,
0
,
FLAGS
,
"interp"
},
{
"line"
,
"bilinear interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BILINEAR
},
0
,
0
,
FLAGS
,
"interp"
},
{
"linear"
,
"bilinear interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BILINEAR
},
0
,
0
,
FLAGS
,
"interp"
},
{
"lagrange9"
,
"lagrange9 interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
LAGRANGE9
},
0
,
0
,
FLAGS
,
"interp"
},
{
"cube"
,
"bicubic interpolation"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BICUBIC
},
0
,
0
,
FLAGS
,
"interp"
},
{
"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"
},
...
...
@@ -313,9 +314,11 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo
DEFINE_REMAP
(
1
,
8
)
DEFINE_REMAP
(
2
,
8
)
DEFINE_REMAP
(
3
,
8
)
DEFINE_REMAP
(
4
,
8
)
DEFINE_REMAP
(
1
,
16
)
DEFINE_REMAP
(
2
,
16
)
DEFINE_REMAP
(
3
,
16
)
DEFINE_REMAP
(
4
,
16
)
#define DEFINE_REMAP_LINE(ws, bits, div) \
...
...
@@ -346,8 +349,10 @@ static void remap##ws##_##bits##bit_line_c(uint8_t *dst, int width, const uint8_
}
DEFINE_REMAP_LINE
(
2
,
8
,
1
)
DEFINE_REMAP_LINE
(
3
,
8
,
1
)
DEFINE_REMAP_LINE
(
4
,
8
,
1
)
DEFINE_REMAP_LINE
(
2
,
16
,
2
)
DEFINE_REMAP_LINE
(
3
,
16
,
2
)
DEFINE_REMAP_LINE
(
4
,
16
,
2
)
void
ff_v360_init
(
V360Context
*
s
,
int
depth
)
...
...
@@ -359,6 +364,9 @@ void ff_v360_init(V360Context *s, int depth)
case
BILINEAR
:
s
->
remap_line
=
depth
<=
8
?
remap2_8bit_line_c
:
remap2_16bit_line_c
;
break
;
case
LAGRANGE9
:
s
->
remap_line
=
depth
<=
8
?
remap3_8bit_line_c
:
remap3_16bit_line_c
;
break
;
case
BICUBIC
:
case
LANCZOS
:
case
SPLINE16
:
...
...
@@ -417,6 +425,47 @@ static void bilinear_kernel(float du, float dv, const XYRemap *rmap,
ker
[
3
]
=
lrintf
(
du
*
dv
*
16385
.
f
);
}
/**
* Calculate 1-dimensional lagrange coefficients.
*
* @param t relative coordinate
* @param coeffs coefficients
*/
static
inline
void
calculate_lagrange_coeffs
(
float
t
,
float
*
coeffs
)
{
coeffs
[
0
]
=
(
t
-
1
.
f
)
*
(
t
-
2
.
f
)
*
0
.
5
f
;
coeffs
[
1
]
=
-
t
*
(
t
-
2
.
f
);
coeffs
[
2
]
=
t
*
(
t
-
1
.
f
)
*
0
.
5
f
;
}
/**
* Calculate kernel for lagrange 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
lagrange_kernel
(
float
du
,
float
dv
,
const
XYRemap
*
rmap
,
int16_t
*
u
,
int16_t
*
v
,
int16_t
*
ker
)
{
float
du_coeffs
[
3
];
float
dv_coeffs
[
3
];
calculate_lagrange_coeffs
(
du
,
du_coeffs
);
calculate_lagrange_coeffs
(
dv
,
dv_coeffs
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
u
[
i
*
3
+
j
]
=
rmap
->
u
[
i
+
1
][
j
+
1
];
v
[
i
*
3
+
j
]
=
rmap
->
v
[
i
+
1
][
j
+
1
];
ker
[
i
*
3
+
j
]
=
lrintf
(
du_coeffs
[
j
]
*
dv_coeffs
[
i
]
*
16385
.
f
);
}
}
}
/**
* Calculate 1-dimensional cubic coefficients.
*
...
...
@@ -3689,6 +3738,13 @@ static int config_output(AVFilterLink *outlink)
sizeof_uv
=
sizeof
(
int16_t
)
*
s
->
elements
;
sizeof_ker
=
sizeof
(
int16_t
)
*
s
->
elements
;
break
;
case
LAGRANGE9
:
s
->
calculate_kernel
=
lagrange_kernel
;
s
->
remap_slice
=
depth
<=
8
?
remap3_8bit_slice
:
remap3_16bit_slice
;
s
->
elements
=
3
*
3
;
sizeof_uv
=
sizeof
(
int16_t
)
*
s
->
elements
;
sizeof_ker
=
sizeof
(
int16_t
)
*
s
->
elements
;
break
;
case
BICUBIC
:
s
->
calculate_kernel
=
bicubic_kernel
;
s
->
remap_slice
=
depth
<=
8
?
remap4_8bit_slice
:
remap4_16bit_slice
;
...
...
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