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
973051e3
Commit
973051e3
authored
Sep 08, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add stereographic output projection
parent
a13b61b7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+37
-0
No files found.
libavfilter/v360.h
View file @
973051e3
...
...
@@ -31,6 +31,7 @@ enum Projections {
DUAL_FISHEYE
,
BARREL
,
CUBEMAP_1_6
,
STEREOGRAPHIC
,
NB_PROJECTIONS
,
};
...
...
libavfilter/vf_v360.c
View file @
973051e3
...
...
@@ -74,6 +74,7 @@ static const AVOption v360_options[] = {
{
"barrel"
,
"barrel facebook's 360 format"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BARREL
},
0
,
0
,
FLAGS
,
"out"
},
{
"fb"
,
"barrel facebook's 360 format"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BARREL
},
0
,
0
,
FLAGS
,
"out"
},
{
"c1x6"
,
"cubemap 1x6"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CUBEMAP_1_6
},
0
,
0
,
FLAGS
,
"out"
},
{
"sg"
,
"stereographic"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
STEREOGRAPHIC
},
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"
},
...
...
@@ -1377,6 +1378,36 @@ static void equirect_to_xyz(const V360Context *s,
vec
[
2
]
=
-
cos_theta
*
cos_phi
;
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in stereographic format.
*
* @param s filter context
* @param i horizontal position on frame [0, height)
* @param j vertical position on frame [0, width)
* @param width frame width
* @param height frame height
* @param vec coordinates on sphere
*/
static
void
stereographic_to_xyz
(
const
V360Context
*
s
,
int
i
,
int
j
,
int
width
,
int
height
,
float
*
vec
)
{
const
float
z
=
0
.
5
f
*
s
->
h_fov
*
M_PI
/
180
.
f
;
const
float
x
=
z
*
(
2
.
f
*
i
/
width
-
1
.
f
);
const
float
y
=
z
*
(
2
.
f
*
j
/
height
-
1
.
f
);
const
float
xy
=
x
*
x
+
y
*
y
;
float
norm
;
vec
[
0
]
=
2
.
f
*
x
/
(
1
.
f
+
xy
);
vec
[
1
]
=
(
-
1
.
f
+
xy
)
/
(
1
.
f
+
xy
);
vec
[
2
]
=
2
.
f
*
y
/
(
1
.
f
+
xy
);
norm
=
sqrtf
(
vec
[
0
]
*
vec
[
0
]
+
vec
[
1
]
*
vec
[
1
]
+
vec
[
2
]
*
vec
[
2
]);
vec
[
0
]
/=
norm
;
vec
[
1
]
/=
norm
;
vec
[
2
]
/=
norm
;
}
/**
* Calculate frame position in equirectangular format for corresponding 3D coordinates on sphere.
*
...
...
@@ -2194,6 +2225,12 @@ static int config_output(AVFilterLink *outlink)
w
=
roundf
(
wf
/
4
.
f
*
5
.
f
);
h
=
roundf
(
hf
);
break
;
case
STEREOGRAPHIC
:
out_transform
=
stereographic_to_xyz
;
err
=
0
;
w
=
FFMAX
(
roundf
(
wf
),
roundf
(
hf
));
h
=
w
;
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