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
ec4f7642
Commit
ec4f7642
authored
Jan 22, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add tetrahedron format
parent
5f7727e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
0 deletions
+99
-0
filters.texi
doc/filters.texi
+2
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+96
-0
No files found.
doc/filters.texi
View file @
ec4f7642
...
...
@@ -19043,6 +19043,8 @@ Format specific options:
Set perspective parameter.
@end table
@item tetrahedron
Tetrahedron projection.
@end table
@item interp
...
...
libavfilter/v360.h
View file @
ec4f7642
...
...
@@ -47,6 +47,7 @@ enum Projections {
PANNINI
,
CYLINDRICAL
,
PERSPECTIVE
,
TETRAHEDRON
,
NB_PROJECTIONS
,
};
...
...
libavfilter/vf_v360.c
View file @
ec4f7642
...
...
@@ -74,6 +74,7 @@ static const AVOption v360_options[] = {
{
"sinusoidal"
,
"sinusoidal"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SINUSOIDAL
},
0
,
0
,
FLAGS
,
"in"
},
{
"fisheye"
,
"fisheye"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
FISHEYE
},
0
,
0
,
FLAGS
,
"in"
},
{
"cylindrical"
,
"cylindrical"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CYLINDRICAL
},
0
,
0
,
FLAGS
,
"in"
},
{
"tetrahedron"
,
"tetrahedron"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
TETRAHEDRON
},
0
,
0
,
FLAGS
,
"in"
},
{
"output"
,
"set output projection"
,
OFFSET
(
out
),
AV_OPT_TYPE_INT
,
{.
i64
=
CUBEMAP_3_2
},
0
,
NB_PROJECTIONS
-
1
,
FLAGS
,
"out"
},
{
"e"
,
"equirectangular"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EQUIRECTANGULAR
},
0
,
0
,
FLAGS
,
"out"
},
{
"equirect"
,
"equirectangular"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EQUIRECTANGULAR
},
0
,
0
,
FLAGS
,
"out"
},
...
...
@@ -96,6 +97,7 @@ static const AVOption v360_options[] = {
{
"pannini"
,
"pannini"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
PANNINI
},
0
,
0
,
FLAGS
,
"out"
},
{
"cylindrical"
,
"cylindrical"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CYLINDRICAL
},
0
,
0
,
FLAGS
,
"out"
},
{
"perspective"
,
"perspective"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
PERSPECTIVE
},
0
,
0
,
FLAGS
,
"out"
},
{
"tetrahedron"
,
"tetrahedron"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
TETRAHEDRON
},
0
,
0
,
FLAGS
,
"out"
},
{
"interp"
,
"set interpolation method"
,
OFFSET
(
interp
),
AV_OPT_TYPE_INT
,
{.
i64
=
BILINEAR
},
0
,
NB_INTERP_METHODS
-
1
,
FLAGS
,
"interp"
},
{
"near"
,
"nearest neighbour"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NEAREST
},
0
,
0
,
FLAGS
,
"interp"
},
{
"nearest"
,
"nearest neighbour"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NEAREST
},
0
,
0
,
FLAGS
,
"interp"
},
...
...
@@ -2589,6 +2591,88 @@ static void perspective_to_xyz(const V360Context *s,
normalize_vector
(
vec
);
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in tetrahedron format.
*
* @param s filter private context
* @param i horizontal position on frame [0, width)
* @param j vertical position on frame [0, height)
* @param width frame width
* @param height frame height
* @param vec coordinates on sphere
*/
static
void
tetrahedron_to_xyz
(
const
V360Context
*
s
,
int
i
,
int
j
,
int
width
,
int
height
,
float
*
vec
)
{
const
float
uf
=
(
float
)
i
/
width
;
const
float
vf
=
(
float
)
j
/
height
;
vec
[
0
]
=
uf
<
0
.
5
f
?
uf
*
4
.
f
-
1
.
f
:
3
.
f
-
uf
*
4
.
f
;
vec
[
1
]
=
1
.
f
-
vf
*
2
.
f
;
vec
[
2
]
=
2
.
f
*
fabsf
(
1
.
f
-
fabsf
(
1
.
f
-
uf
*
2
.
f
+
vf
))
-
1
.
f
;
normalize_vector
(
vec
);
}
/**
* Calculate frame position in tetrahedron format for corresponding 3D coordinates on sphere.
*
* @param s filter private context
* @param vec coordinates on sphere
* @param width frame width
* @param height frame height
* @param us horizontal coordinates for interpolation window
* @param vs vertical coordinates for interpolation window
* @param du horizontal relative coordinate
* @param dv vertical relative coordinate
*/
static
void
xyz_to_tetrahedron
(
const
V360Context
*
s
,
const
float
*
vec
,
int
width
,
int
height
,
int16_t
us
[
4
][
4
],
int16_t
vs
[
4
][
4
],
float
*
du
,
float
*
dv
)
{
float
d
=
0
.
5
f
*
(
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]
+
vec
[
2
]
*
vec
[
2
]);
const
float
d0
=
(
vec
[
0
]
*
0
.
5
f
+
vec
[
1
]
*
0
.
5
f
+
vec
[
2
]
*-
0
.
5
f
)
/
d
;
const
float
d1
=
(
vec
[
0
]
*-
0
.
5
f
+
vec
[
1
]
*-
0
.
5
f
+
vec
[
2
]
*-
0
.
5
f
)
/
d
;
const
float
d2
=
(
vec
[
0
]
*
0
.
5
f
+
vec
[
1
]
*-
0
.
5
f
+
vec
[
2
]
*
0
.
5
f
)
/
d
;
const
float
d3
=
(
vec
[
0
]
*-
0
.
5
f
+
vec
[
1
]
*
0
.
5
f
+
vec
[
2
]
*
0
.
5
f
)
/
d
;
float
uf
,
vf
,
x
,
y
,
z
;
int
ui
,
vi
;
d
=
FFMAX
(
d0
,
FFMAX3
(
d1
,
d2
,
d3
));
x
=
vec
[
0
]
/
d
;
y
=
vec
[
1
]
/
d
;
z
=
-
vec
[
2
]
/
d
;
vf
=
0
.
5
f
-
y
*
0
.
5
f
;
if
((
x
+
y
>=
0
.
f
&&
y
+
z
>=
0
.
f
&&
-
z
-
x
<=
0
.
f
)
||
(
x
+
y
<=
0
.
f
&&
-
y
+
z
>=
0
.
f
&&
z
-
x
>=
0
.
f
))
{
uf
=
0
.
25
f
*
x
+
0
.
25
f
;
}
else
{
uf
=
0
.
75
f
-
0
.
25
f
*
x
;
}
uf
*=
width
-
1
;
vf
*=
height
-
1
;
ui
=
floorf
(
uf
);
vi
=
floorf
(
vf
);
*
du
=
uf
-
ui
;
*
dv
=
vf
-
vi
;
for
(
int
i
=
-
1
;
i
<
3
;
i
++
)
{
for
(
int
j
=
-
1
;
j
<
3
;
j
++
)
{
us
[
i
+
1
][
j
+
1
]
=
av_clip
(
ui
+
j
,
0
,
width
-
1
);
vs
[
i
+
1
][
j
+
1
]
=
av_clip
(
vi
+
i
,
0
,
height
-
1
);
}
}
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in dual fisheye format.
*
...
...
@@ -3206,6 +3290,12 @@ static int config_output(AVFilterLink *outlink)
wf
=
w
;
hf
=
h
*
2
.
f
;
break
;
case
TETRAHEDRON
:
s
->
in_transform
=
xyz_to_tetrahedron
;
err
=
0
;
wf
=
w
;
hf
=
h
;
break
;
default
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Specified input format is not handled.
\n
"
);
return
AVERROR_BUG
;
...
...
@@ -3318,6 +3408,12 @@ static int config_output(AVFilterLink *outlink)
w
=
lrintf
(
wf
/
2
.
f
);
h
=
lrintf
(
hf
);
break
;
case
TETRAHEDRON
:
s
->
out_transform
=
tetrahedron_to_xyz
;
prepare_out
=
NULL
;
w
=
lrintf
(
wf
);
h
=
lrintf
(
hf
);
break
;
default
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Specified output format is not handled.
\n
"
);
return
AVERROR_BUG
;
...
...
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