Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
7fc28465
Commit
7fc28465
authored
Jan 17, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add cylindrical output projection
parent
ab962722
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
3 deletions
+74
-3
filters.texi
doc/filters.texi
+13
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+60
-3
No files found.
doc/filters.texi
View file @
7fc28465
...
@@ -18990,6 +18990,19 @@ Format specific options:
...
@@ -18990,6 +18990,19 @@ Format specific options:
Set pannini parameter.
Set pannini parameter.
@end table
@end table
@item cylindrical
Cylindrical 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
@end table
@item interp
@item interp
...
...
libavfilter/v360.h
View file @
7fc28465
...
@@ -45,6 +45,7 @@ enum Projections {
...
@@ -45,6 +45,7 @@ enum Projections {
SINUSOIDAL
,
SINUSOIDAL
,
FISHEYE
,
FISHEYE
,
PANNINI
,
PANNINI
,
CYLINDRICAL
,
NB_PROJECTIONS
,
NB_PROJECTIONS
,
};
};
...
...
libavfilter/vf_v360.c
View file @
7fc28465
...
@@ -89,6 +89,7 @@ static const AVOption v360_options[] = {
...
@@ -89,6 +89,7 @@ static const AVOption v360_options[] = {
{
"sinusoidal"
,
"sinusoidal"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
SINUSOIDAL
},
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"
},
{
"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"
},
{
"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"
},
...
@@ -2118,8 +2119,8 @@ static int prepare_fisheye_out(AVFilterContext *ctx)
...
@@ -2118,8 +2119,8 @@ static int prepare_fisheye_out(AVFilterContext *ctx)
{
{
V360Context
*
s
=
ctx
->
priv
;
V360Context
*
s
=
ctx
->
priv
;
s
->
flat_range
[
0
]
=
FFMIN
(
s
->
h_fov
,
359
.
f
)
/
180
.
f
;
s
->
flat_range
[
0
]
=
s
->
h_fov
/
180
.
f
;
s
->
flat_range
[
1
]
=
FFMIN
(
s
->
v_fov
,
359
.
f
)
/
180
.
f
;
s
->
flat_range
[
1
]
=
s
->
v_fov
/
180
.
f
;
return
0
;
return
0
;
}
}
...
@@ -2183,6 +2184,55 @@ static void pannini_to_xyz(const V360Context *s,
...
@@ -2183,6 +2184,55 @@ static void pannini_to_xyz(const V360Context *s,
normalize_vector
(
vec
);
normalize_vector
(
vec
);
}
}
/**
* Prepare data for processing cylindrical output format.
*
* @param ctx filter context
*
* @return error code
*/
static
int
prepare_cylindrical_out
(
AVFilterContext
*
ctx
)
{
V360Context
*
s
=
ctx
->
priv
;
s
->
flat_range
[
0
]
=
M_PI
*
s
->
h_fov
/
360
.
f
;
s
->
flat_range
[
1
]
=
tanf
(
0
.
5
f
*
s
->
v_fov
*
M_PI
/
180
.
f
);
return
0
;
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in cylindrical 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
cylindrical_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
=
uf
;
const
float
theta
=
atanf
(
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
;
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.
*
*
...
@@ -2719,6 +2769,7 @@ static int config_output(AVFilterLink *outlink)
...
@@ -2719,6 +2769,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
CYLINDRICAL
:
case
PANNINI
:
case
PANNINI
:
case
FISHEYE
:
case
FISHEYE
:
case
FLAT
:
case
FLAT
:
...
@@ -2862,10 +2913,16 @@ static int config_output(AVFilterLink *outlink)
...
@@ -2862,10 +2913,16 @@ static int config_output(AVFilterLink *outlink)
break
;
break
;
case
PANNINI
:
case
PANNINI
:
s
->
out_transform
=
pannini_to_xyz
;
s
->
out_transform
=
pannini_to_xyz
;
prepare_out
=
prepare_fisheye_out
;
prepare_out
=
NULL
;
w
=
roundf
(
wf
);
w
=
roundf
(
wf
);
h
=
roundf
(
hf
);
h
=
roundf
(
hf
);
break
;
break
;
case
CYLINDRICAL
:
s
->
out_transform
=
cylindrical_to_xyz
;
prepare_out
=
prepare_cylindrical_out
;
w
=
roundf
(
wf
);
h
=
roundf
(
hf
*
0
.
5
f
);
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