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
19f75e77
Commit
19f75e77
authored
Jan 20, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add support for cylindrical input format
parent
e57b9aa8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
1 deletion
+72
-1
filters.texi
doc/filters.texi
+7
-0
vf_v360.c
libavfilter/vf_v360.c
+65
-1
No files found.
doc/filters.texi
View file @
19f75e77
...
@@ -19010,6 +19010,13 @@ Format specific options:
...
@@ -19010,6 +19010,13 @@ Format specific options:
@item d_fov
@item d_fov
Set horizontal/vertical/diagonal field of view. Values in degrees.
Set horizontal/vertical/diagonal field of view. Values in degrees.
If diagonal field of view is set it overrides horizontal and vertical field of view.
@item ih_fov
@item iv_fov
@item id_fov
Set input horizontal/vertical/diagonal field of view. Values in degrees.
If diagonal field of view is set it overrides horizontal and vertical field of view.
If diagonal field of view is set it overrides horizontal and vertical field of view.
@end table
@end table
...
...
libavfilter/vf_v360.c
View file @
19f75e77
...
@@ -72,6 +72,7 @@ static const AVOption v360_options[] = {
...
@@ -72,6 +72,7 @@ static const AVOption v360_options[] = {
{
"ball"
,
"ball"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BALL
},
0
,
0
,
FLAGS
,
"in"
},
{
"ball"
,
"ball"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BALL
},
0
,
0
,
FLAGS
,
"in"
},
{
"hammer"
,
"hammer"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HAMMER
},
0
,
0
,
FLAGS
,
"in"
},
{
"hammer"
,
"hammer"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HAMMER
},
0
,
0
,
FLAGS
,
"in"
},
{
"sinusoidal"
,
"sinusoidal"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SINUSOIDAL
},
0
,
0
,
FLAGS
,
"in"
},
{
"sinusoidal"
,
"sinusoidal"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SINUSOIDAL
},
0
,
0
,
FLAGS
,
"in"
},
{
"cylindrical"
,
"cylindrical"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CYLINDRICAL
},
0
,
0
,
FLAGS
,
"in"
},
{
"output"
,
"set output projection"
,
OFFSET
(
out
),
AV_OPT_TYPE_INT
,
{.
i64
=
CUBEMAP_3_2
},
0
,
NB_PROJECTIONS
-
1
,
FLAGS
,
"out"
},
{
"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"
},
{
"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"
},
{
"equirect"
,
"equirectangular"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EQUIRECTANGULAR
},
0
,
0
,
FLAGS
,
"out"
},
...
@@ -2406,6 +2407,64 @@ static void cylindrical_to_xyz(const V360Context *s,
...
@@ -2406,6 +2407,64 @@ static void cylindrical_to_xyz(const V360Context *s,
normalize_vector
(
vec
);
normalize_vector
(
vec
);
}
}
/**
* Prepare data for processing cylindrical input format.
*
* @param ctx filter context
*
* @return error code
*/
static
int
prepare_cylindrical_in
(
AVFilterContext
*
ctx
)
{
V360Context
*
s
=
ctx
->
priv
;
s
->
iflat_range
[
0
]
=
M_PI
*
s
->
ih_fov
/
360
.
f
;
s
->
iflat_range
[
1
]
=
tanf
(
0
.
5
f
*
s
->
iv_fov
*
M_PI
/
180
.
f
);
return
0
;
}
/**
* Calculate frame position in cylindrical 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_cylindrical
(
const
V360Context
*
s
,
const
float
*
vec
,
int
width
,
int
height
,
int16_t
us
[
4
][
4
],
int16_t
vs
[
4
][
4
],
float
*
du
,
float
*
dv
)
{
const
float
phi
=
atan2f
(
vec
[
0
],
-
vec
[
2
])
*
s
->
input_mirror_modifier
[
0
]
/
s
->
iflat_range
[
0
];
const
float
theta
=
atan2f
(
-
vec
[
1
],
hypotf
(
vec
[
0
],
vec
[
2
]))
*
s
->
input_mirror_modifier
[
1
]
/
s
->
iflat_range
[
1
];
int
visible
,
ui
,
vi
;
float
uf
,
vf
;
uf
=
(
phi
+
1
.
f
)
*
(
width
-
1
)
/
2
.
f
;
vf
=
(
tanf
(
theta
)
+
1
.
f
)
*
height
/
2
.
f
;
ui
=
floorf
(
uf
);
vi
=
floorf
(
vf
);
visible
=
vi
>=
0
&&
vi
<
height
&&
ui
>=
0
&&
ui
<
width
&&
theta
<=
M_PI
*
s
->
iv_fov
/
180
.
f
&&
theta
>=
-
M_PI
*
s
->
iv_fov
/
180
.
f
;
*
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
]
=
visible
?
av_clip
(
ui
+
j
,
0
,
width
-
1
)
:
0
;
vs
[
i
+
1
][
j
+
1
]
=
visible
?
av_clip
(
vi
+
i
,
0
,
height
-
1
)
:
0
;
}
}
}
/**
/**
* Calculate 3D coordinates on sphere for corresponding frame position in perspective format.
* Calculate 3D coordinates on sphere for corresponding frame position in perspective format.
*
*
...
@@ -3011,7 +3070,6 @@ static int config_output(AVFilterLink *outlink)
...
@@ -3011,7 +3070,6 @@ static int config_output(AVFilterLink *outlink)
hf
=
h
;
hf
=
h
;
break
;
break
;
case
PERSPECTIVE
:
case
PERSPECTIVE
:
case
CYLINDRICAL
:
case
PANNINI
:
case
PANNINI
:
case
FISHEYE
:
case
FISHEYE
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Supplied format is not accepted as input.
\n
"
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Supplied format is not accepted as input.
\n
"
);
...
@@ -3058,6 +3116,12 @@ static int config_output(AVFilterLink *outlink)
...
@@ -3058,6 +3116,12 @@ static int config_output(AVFilterLink *outlink)
wf
=
w
;
wf
=
w
;
hf
=
h
;
hf
=
h
;
break
;
break
;
case
CYLINDRICAL
:
s
->
in_transform
=
xyz_to_cylindrical
;
err
=
prepare_cylindrical_in
(
ctx
);
wf
=
w
;
hf
=
h
*
2
.
f
;
break
;
default
:
default
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Specified input format is not handled.
\n
"
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Specified input format is not handled.
\n
"
);
return
AVERROR_BUG
;
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