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
3dd81be8
Commit
3dd81be8
authored
Mar 02, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add truncated square pyramid output format
parent
12813991
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
1 deletion
+71
-1
filters.texi
doc/filters.texi
+4
-0
v360.h
libavfilter/v360.h
+1
-0
vf_v360.c
libavfilter/vf_v360.c
+66
-1
No files found.
doc/filters.texi
View file @
3dd81be8
...
...
@@ -19027,6 +19027,10 @@ Set perspective parameter.
@
item
tetrahedron
Tetrahedron
projection
.
@
item
tsp
Truncated
square
pyramid
projection
.
@
i
{(
output
only
)}
@
end
table
@
item
interp
...
...
libavfilter/v360.h
View file @
3dd81be8
...
...
@@ -49,6 +49,7 @@ enum Projections {
PERSPECTIVE
,
TETRAHEDRON
,
BARREL_SPLIT
,
TSPYRAMID
,
NB_PROJECTIONS
,
};
...
...
libavfilter/vf_v360.c
View file @
3dd81be8
...
...
@@ -101,6 +101,7 @@ static const AVOption v360_options[] = {
{
"perspective"
,
"perspective"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
PERSPECTIVE
},
0
,
0
,
FLAGS
,
"out"
},
{
"tetrahedron"
,
"tetrahedron"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
TETRAHEDRON
},
0
,
0
,
FLAGS
,
"out"
},
{
"barrelsplit"
,
"barrel split facebook's 360 format"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BARREL_SPLIT
},
0
,
0
,
FLAGS
,
"out"
},
{
"tsp"
,
"truncated square pyramid"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
TSPYRAMID
},
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"
},
...
...
@@ -3227,6 +3228,64 @@ static int barrelsplit_to_xyz(const V360Context *s,
return
1
;
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in tspyramid 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
int
tspyramid_to_xyz
(
const
V360Context
*
s
,
int
i
,
int
j
,
int
width
,
int
height
,
float
*
vec
)
{
const
float
x
=
(
i
+
0
.
5
f
)
/
width
;
const
float
y
=
(
j
+
0
.
5
f
)
/
height
;
if
(
x
<
0
.
5
f
)
{
vec
[
0
]
=
x
*
4
.
f
-
1
.
f
;
vec
[
1
]
=
-
(
y
*
2
.
f
-
1
.
f
);
vec
[
2
]
=
-
1
.
f
;
}
else
if
(
x
>=
0
.
6875
f
&&
x
<
0
.
8125
f
&&
y
>=
0
.
375
f
&&
y
<
0
.
625
f
)
{
vec
[
0
]
=
-
(
x
-
0
.
6875
f
)
*
16
.
f
+
1
.
f
;
vec
[
1
]
=
-
(
y
-
0
.
375
f
)
*
8
.
f
+
1
.
f
;
vec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
=
-
2
.
f
*
(
0
.
375
f
-
y
)
/
0
.
375
f
+
1
.
f
;
}
else
{
vec
[
0
]
=
2
.
f
*
(
0
.
5
f
-
x
+
0
.
5
f
*
y
)
/
(
y
-
0
.
5
f
)
-
1
.
f
;
vec
[
1
]
=
-
1
.
f
;
vec
[
2
]
=
2
.
f
*
(
1
.
f
-
y
)
/
0
.
375
f
-
1
.
f
;
}
normalize_vector
(
vec
);
return
1
;
}
static
void
multiply_matrix
(
float
c
[
3
][
3
],
const
float
a
[
3
][
3
],
const
float
b
[
3
][
3
])
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
...
...
@@ -3350,7 +3409,7 @@ static void fov_from_dfov(int format, float d_fov, float w, float h, float *h_fo
case
FLAT
:
default
:
{
const
float
da
=
tanf
(
0
.
5
*
FFMIN
(
d_fov
,
359
.
f
)
*
M_PI
/
180
.
f
);
const
float
da
=
tanf
(
0
.
5
f
*
FFMIN
(
d_fov
,
359
.
f
)
*
M_PI
/
180
.
f
);
const
float
d
=
hypotf
(
w
,
h
);
*
h_fov
=
atan2f
(
da
*
w
,
d
)
*
360
.
f
/
M_PI
;
...
...
@@ -3792,6 +3851,12 @@ static int config_output(AVFilterLink *outlink)
w
=
lrintf
(
wf
/
4
.
f
*
3
.
f
);
h
=
lrintf
(
hf
);
break
;
case
TSPYRAMID
:
s
->
out_transform
=
tspyramid_to_xyz
;
prepare_out
=
NULL
;
w
=
lrintf
(
wf
);
h
=
lrintf
(
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