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
330b157c
Commit
330b157c
authored
Jan 16, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add pannini output projection
parent
6e082f9f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
filters.texi
doc/filters.texi
+10
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+40
-0
No files found.
doc/filters.texi
View file @
330b157c
...
@@ -18980,6 +18980,16 @@ Set horizontal/vertical/diagonal field of view. Values in degrees.
...
@@ -18980,6 +18980,16 @@ 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 pannini
Pannini projection. @i{(output only)}
Format specific options:
@table @option
@item h_fov
Set pannini parameter.
@end table
@end table
@end table
@item interp
@item interp
...
...
libavfilter/v360.h
View file @
330b157c
...
@@ -44,6 +44,7 @@ enum Projections {
...
@@ -44,6 +44,7 @@ enum Projections {
HAMMER
,
HAMMER
,
SINUSOIDAL
,
SINUSOIDAL
,
FISHEYE
,
FISHEYE
,
PANNINI
,
NB_PROJECTIONS
,
NB_PROJECTIONS
,
};
};
...
...
libavfilter/vf_v360.c
View file @
330b157c
...
@@ -88,6 +88,7 @@ static const AVOption v360_options[] = {
...
@@ -88,6 +88,7 @@ static const AVOption v360_options[] = {
{
"hammer"
,
"hammer"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
HAMMER
},
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"
},
{
"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"
},
{
"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"
},
...
@@ -2150,6 +2151,38 @@ static void fisheye_to_xyz(const V360Context *s,
...
@@ -2150,6 +2151,38 @@ static void fisheye_to_xyz(const V360Context *s,
normalize_vector
(
vec
);
normalize_vector
(
vec
);
}
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in pannini 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
pannini_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
d
=
s
->
h_fov
;
float
k
=
uf
*
uf
/
((
d
+
1
.
f
)
*
(
d
+
1
.
f
));
float
dscr
=
k
*
k
*
d
*
d
-
(
k
+
1
)
*
(
k
*
d
*
d
-
1
.
f
);
float
clon
=
(
-
k
*
d
+
sqrtf
(
dscr
))
/
(
k
+
1
.
f
);
float
S
=
(
d
+
1
.
f
)
/
(
d
+
clon
);
float
lon
=
-
(
M_PI
+
atan2f
(
uf
,
S
*
clon
));
float
lat
=
-
atan2f
(
vf
,
S
);
vec
[
0
]
=
sinf
(
lon
)
*
cosf
(
lat
);
vec
[
1
]
=
sinf
(
lat
);
vec
[
2
]
=
cosf
(
lon
)
*
cosf
(
lat
);
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.
*
*
...
@@ -2686,6 +2719,7 @@ static int config_output(AVFilterLink *outlink)
...
@@ -2686,6 +2719,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
PANNINI
:
case
FISHEYE
:
case
FISHEYE
:
case
FLAT
:
case
FLAT
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Supplied format is not accepted as input.
\n
"
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Supplied format is not accepted as input.
\n
"
);
...
@@ -2826,6 +2860,12 @@ static int config_output(AVFilterLink *outlink)
...
@@ -2826,6 +2860,12 @@ static int config_output(AVFilterLink *outlink)
w
=
roundf
(
wf
*
0
.
5
f
);
w
=
roundf
(
wf
*
0
.
5
f
);
h
=
roundf
(
hf
);
h
=
roundf
(
hf
);
break
;
break
;
case
PANNINI
:
s
->
out_transform
=
pannini_to_xyz
;
prepare_out
=
prepare_fisheye_out
;
w
=
roundf
(
wf
);
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