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
103a29b8
Commit
103a29b8
authored
Jan 21, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add support for fisheye input format
parent
39b60359
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
3 deletions
+74
-3
filters.texi
doc/filters.texi
+9
-2
vf_v360.c
libavfilter/vf_v360.c
+65
-1
No files found.
doc/filters.texi
View file @
103a29b8
...
...
@@ -18986,14 +18986,21 @@ Hammer-Aitoff map projection format.
Sinusoidal map projection format.
@item fisheye
Fisheye projection.
@i{(output only)}
Fisheye projection.
Format specific options:
@table @option
@item h_fov
@item v_fov
@item d_fov
Set horizontal/vertical/diagonal field of view. Values in degrees.
Set output 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.
@end table
...
...
libavfilter/vf_v360.c
View file @
103a29b8
...
...
@@ -72,6 +72,7 @@ static const AVOption v360_options[] = {
{
"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"
},
{
"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"
},
{
"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"
},
...
...
@@ -2345,6 +2346,64 @@ static void fisheye_to_xyz(const V360Context *s,
normalize_vector
(
vec
);
}
/**
* Prepare data for processing fisheye input format.
*
* @param ctx filter context
*
* @return error code
*/
static
int
prepare_fisheye_in
(
AVFilterContext
*
ctx
)
{
V360Context
*
s
=
ctx
->
priv
;
s
->
iflat_range
[
0
]
=
s
->
ih_fov
/
180
.
f
;
s
->
iflat_range
[
1
]
=
s
->
iv_fov
/
180
.
f
;
return
0
;
}
/**
* Calculate frame position in fisheye 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_fisheye
(
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
h
=
hypotf
(
vec
[
0
],
vec
[
1
]);
const
float
lh
=
h
>
0
.
f
?
h
:
1
.
f
;
const
float
theta
=
acosf
(
fabsf
(
vec
[
2
]))
/
M_PI
;
const
float
uf
=
(
theta
*
(
vec
[
0
]
/
lh
)
*
s
->
input_mirror_modifier
[
0
]
/
s
->
iflat_range
[
0
]
+
0
.
5
f
)
*
width
;
const
float
vf
=
(
theta
*
(
-
vec
[
1
]
/
lh
)
*
s
->
input_mirror_modifier
[
1
]
/
s
->
iflat_range
[
1
]
+
0
.
5
f
)
*
height
;
int
visible
,
ui
,
vi
;
ui
=
floorf
(
uf
);
vi
=
floorf
(
vf
);
visible
=
vec
[
2
]
<
0
.
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 pannini format.
*
...
...
@@ -3090,7 +3149,6 @@ static int config_output(AVFilterLink *outlink)
break
;
case
PERSPECTIVE
:
case
PANNINI
:
case
FISHEYE
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Supplied format is not accepted as input.
\n
"
);
return
AVERROR
(
EINVAL
);
case
DUAL_FISHEYE
:
...
...
@@ -3135,6 +3193,12 @@ static int config_output(AVFilterLink *outlink)
wf
=
w
;
hf
=
h
;
break
;
case
FISHEYE
:
s
->
in_transform
=
xyz_to_fisheye
;
err
=
prepare_fisheye_in
(
ctx
);
wf
=
w
*
2
;
hf
=
h
;
break
;
case
CYLINDRICAL
:
s
->
in_transform
=
xyz_to_cylindrical
;
err
=
prepare_cylindrical_in
(
ctx
);
...
...
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