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
fdddc0d6
Commit
fdddc0d6
authored
Jan 18, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add perspective output projection
parent
6ae84e7b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
filters.texi
doc/filters.texi
+9
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+53
-0
No files found.
doc/filters.texi
View file @
fdddc0d6
...
@@ -19003,6 +19003,15 @@ Set horizontal/vertical/diagonal field of view. Values in degrees.
...
@@ -19003,6 +19003,15 @@ 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.
If diagonal field of view is set it overrides horizontal and vertical field of view.
@end table
@end table
@item perspective
Perspective projection. @i{(output only)}
Format specific options:
@table @option
@item v_fov
Set perspective parameter.
@end table
@end table
@end table
@item interp
@item interp
...
...
libavfilter/v360.h
View file @
fdddc0d6
...
@@ -46,6 +46,7 @@ enum Projections {
...
@@ -46,6 +46,7 @@ enum Projections {
FISHEYE
,
FISHEYE
,
PANNINI
,
PANNINI
,
CYLINDRICAL
,
CYLINDRICAL
,
PERSPECTIVE
,
NB_PROJECTIONS
,
NB_PROJECTIONS
,
};
};
...
...
libavfilter/vf_v360.c
View file @
fdddc0d6
...
@@ -90,6 +90,7 @@ static const AVOption v360_options[] = {
...
@@ -90,6 +90,7 @@ static const AVOption v360_options[] = {
{
"fisheye"
,
"fisheye"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
FISHEYE
},
0
,
0
,
FLAGS
,
"out"
},
{
"fisheye"
,
"fisheye"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
FISHEYE
},
0
,
0
,
FLAGS
,
"out"
},
{
"pannini"
,
"pannini"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
PANNINI
},
0
,
0
,
FLAGS
,
"out"
},
{
"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"
},
{
"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"
},
{
"interp"
,
"set interpolation method"
,
OFFSET
(
interp
),
AV_OPT_TYPE_INT
,
{.
i64
=
BILINEAR
},
0
,
NB_INTERP_METHODS
-
1
,
FLAGS
,
"interp"
},
{
"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"
},
{
"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"
},
{
"nearest"
,
"nearest neighbour"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
NEAREST
},
0
,
0
,
FLAGS
,
"interp"
},
...
@@ -2334,6 +2335,51 @@ static void cylindrical_to_xyz(const V360Context *s,
...
@@ -2334,6 +2335,51 @@ static void cylindrical_to_xyz(const V360Context *s,
normalize_vector
(
vec
);
normalize_vector
(
vec
);
}
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in perspective 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
perspective_to_xyz
(
const
V360Context
*
s
,
int
i
,
int
j
,
int
width
,
int
height
,
float
*
vec
)
{
const
float
uf
=
((
2
.
f
*
i
)
/
width
-
1
.
f
);
const
float
vf
=
((
2
.
f
*
j
)
/
height
-
1
.
f
);
const
float
rh
=
hypotf
(
uf
,
vf
);
const
float
sinzz
=
1
.
f
-
rh
*
rh
;
const
float
h
=
1
.
f
+
s
->
v_fov
;
const
float
sinz
=
(
h
-
sqrtf
(
sinzz
))
/
(
h
/
rh
+
rh
/
h
);
const
float
sinz2
=
sinz
*
sinz
;
if
(
sinz2
<=
1
.
f
)
{
const
float
cosz
=
sqrtf
(
1
.
f
-
sinz2
);
const
float
theta
=
asinf
(
cosz
);
const
float
phi
=
atan2f
(
uf
,
vf
);
const
float
sin_phi
=
sinf
(
phi
);
const
float
cos_phi
=
cosf
(
phi
);
const
float
sin_theta
=
sinf
(
theta
);
const
float
cos_theta
=
cosf
(
theta
);
vec
[
0
]
=
cos_theta
*
sin_phi
;
vec
[
1
]
=
sin_theta
;
vec
[
2
]
=
-
cos_theta
*
cos_phi
;
}
else
{
vec
[
0
]
=
0
.
f
;
vec
[
1
]
=
-
1
.
f
;
vec
[
2
]
=
0
.
f
;
}
normalize_vector
(
vec
);
}
/**
/**
* Calculate 3D coordinates on sphere for corresponding frame position in dual fisheye format.
* Calculate 3D coordinates on sphere for corresponding frame position in dual fisheye format.
*
*
...
@@ -2884,6 +2930,7 @@ static int config_output(AVFilterLink *outlink)
...
@@ -2884,6 +2930,7 @@ static int config_output(AVFilterLink *outlink)
wf
=
w
;
wf
=
w
;
hf
=
h
/
9
.
f
*
8
.
f
;
hf
=
h
/
9
.
f
*
8
.
f
;
break
;
break
;
case
PERSPECTIVE
:
case
CYLINDRICAL
:
case
CYLINDRICAL
:
case
PANNINI
:
case
PANNINI
:
case
FISHEYE
:
case
FISHEYE
:
...
@@ -3038,6 +3085,12 @@ static int config_output(AVFilterLink *outlink)
...
@@ -3038,6 +3085,12 @@ static int config_output(AVFilterLink *outlink)
w
=
roundf
(
wf
);
w
=
roundf
(
wf
);
h
=
roundf
(
hf
*
0
.
5
f
);
h
=
roundf
(
hf
*
0
.
5
f
);
break
;
break
;
case
PERSPECTIVE
:
s
->
out_transform
=
perspective_to_xyz
;
prepare_out
=
NULL
;
w
=
roundf
(
wf
/
2
.
f
);
h
=
roundf
(
hf
);
break
;
default
:
default
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Specified output format is not handled.
\n
"
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Specified output 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