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
6e082f9f
Commit
6e082f9f
authored
Jan 16, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add fisheye output projection
parent
e7c04eaf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
filters.texi
doc/filters.texi
+12
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+53
-1
No files found.
doc/filters.texi
View file @
6e082f9f
...
...
@@ -18968,6 +18968,18 @@ Hammer-Aitoff map projection format.
@item sinusoidal
Sinusoidal map projection format.
@item fisheye
Fisheye projection. @i{(output only)}
Format specific options:
@table @option
@item h_fov
@item v_fov
@item d_fov
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.
@end table
@end table
@item interp
...
...
libavfilter/v360.h
View file @
6e082f9f
...
...
@@ -43,6 +43,7 @@ enum Projections {
BALL
,
HAMMER
,
SINUSOIDAL
,
FISHEYE
,
NB_PROJECTIONS
,
};
...
...
libavfilter/vf_v360.c
View file @
6e082f9f
...
...
@@ -87,6 +87,7 @@ static const AVOption v360_options[] = {
{
"ball"
,
"ball"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BALL
},
0
,
0
,
FLAGS
,
"out"
},
{
"hammer"
,
"hammer"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HAMMER
},
0
,
0
,
FLAGS
,
"out"
},
{
"sinusoidal"
,
"sinusoidal"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SINUSOIDAL
},
0
,
0
,
FLAGS
,
"out"
},
{
"fisheye"
,
"fisheye"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
FISHEYE
},
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"
},
...
...
@@ -2105,6 +2106,50 @@ static void flat_to_xyz(const V360Context *s,
normalize_vector
(
vec
);
}
/**
* Prepare data for processing fisheye output format.
*
* @param ctx filter context
*
* @return error code
*/
static
int
prepare_fisheye_out
(
AVFilterContext
*
ctx
)
{
V360Context
*
s
=
ctx
->
priv
;
s
->
flat_range
[
0
]
=
FFMIN
(
s
->
h_fov
,
359
.
f
)
/
180
.
f
;
s
->
flat_range
[
1
]
=
FFMIN
(
s
->
v_fov
,
359
.
f
)
/
180
.
f
;
return
0
;
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in fisheye 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
fisheye_to_xyz
(
const
V360Context
*
s
,
int
i
,
int
j
,
int
width
,
int
height
,
float
*
vec
)
{
const
float
uf
=
s
->
flat_range
[
0
]
*
((
2
.
f
*
i
)
/
width
-
1
.
f
);
const
float
vf
=
s
->
flat_range
[
1
]
*
((
2
.
f
*
j
)
/
height
-
1
.
f
);
const
float
phi
=
-
atan2f
(
vf
,
uf
);
const
float
theta
=
-
M_PI_2
*
(
1
.
f
-
hypotf
(
uf
,
vf
));
vec
[
0
]
=
cosf
(
theta
)
*
cosf
(
phi
);
vec
[
1
]
=
cosf
(
theta
)
*
sinf
(
phi
);
vec
[
2
]
=
sinf
(
theta
);
normalize_vector
(
vec
);
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in dual fisheye format.
*
...
...
@@ -2641,8 +2686,9 @@ static int config_output(AVFilterLink *outlink)
wf
=
w
;
hf
=
h
/
9
.
f
*
8
.
f
;
break
;
case
FISHEYE
:
case
FLAT
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"
Flat
format is not accepted as input.
\n
"
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"
Supplied
format is not accepted as input.
\n
"
);
return
AVERROR
(
EINVAL
);
case
DUAL_FISHEYE
:
s
->
in_transform
=
xyz_to_dfisheye
;
...
...
@@ -2774,6 +2820,12 @@ static int config_output(AVFilterLink *outlink)
w
=
roundf
(
wf
);
h
=
roundf
(
hf
);
break
;
case
FISHEYE
:
s
->
out_transform
=
fisheye_to_xyz
;
prepare_out
=
prepare_fisheye_out
;
w
=
roundf
(
wf
*
0
.
5
f
);
h
=
roundf
(
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