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
9b222543
Commit
9b222543
authored
Feb 26, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_v360: add initial barrel split format input support
parent
a2c97a83
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
20 deletions
+128
-20
vf_v360.c
libavfilter/vf_v360.c
+128
-20
No files found.
libavfilter/vf_v360.c
View file @
9b222543
...
...
@@ -76,6 +76,7 @@ static const AVOption v360_options[] = {
{
"fisheye"
,
"fisheye"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
FISHEYE
},
0
,
0
,
FLAGS
,
"in"
},
{
"cylindrical"
,
"cylindrical"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
CYLINDRICAL
},
0
,
0
,
FLAGS
,
"in"
},
{
"tetrahedron"
,
"tetrahedron"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
TETRAHEDRON
},
0
,
0
,
FLAGS
,
"in"
},
{
"barrelsplit"
,
"barrel split facebook's 360 format"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
BARREL_SPLIT
},
0
,
0
,
FLAGS
,
"in"
},
{
"output"
,
"set output projection"
,
OFFSET
(
out
),
AV_OPT_TYPE_INT
,
{.
i64
=
CUBEMAP_3_2
},
0
,
NB_PROJECTIONS
-
1
,
FLAGS
,
"out"
},
{
"e"
,
"equirectangular"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EQUIRECTANGULAR
},
0
,
0
,
FLAGS
,
"out"
},
{
"equirect"
,
"equirectangular"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EQUIRECTANGULAR
},
0
,
0
,
FLAGS
,
"out"
},
...
...
@@ -2892,7 +2893,7 @@ static int barrel_to_xyz(const V360Context *s,
float
uf
,
vf
;
if
(
j
<
eh
)
{
// UP
uf
=
2
.
f
*
(
i
-
4
*
ew
)
/
ew
-
1
.
f
;
uf
=
2
.
f
*
(
i
-
4
*
ew
)
/
ew
-
1
.
f
;
vf
=
2
.
f
*
(
j
)
/
eh
-
1
.
f
;
uf
/=
scale
;
...
...
@@ -2998,6 +2999,105 @@ static int xyz_to_barrel(const V360Context *s,
return
1
;
}
/**
* Calculate frame position in barrel split facebook's format for corresponding 3D coordinates on sphere.
*
* @param s filter private context
* @param vec coordinates on sphere
* @param width frame width
* @param height frame height
* @param us horizontal coordinates for interpolation window
* @param vs vertical coordinates for interpolation window
* @param du horizontal relative coordinate
* @param dv vertical relative coordinate
*/
static
int
xyz_to_barrelsplit
(
const
V360Context
*
s
,
const
float
*
vec
,
int
width
,
int
height
,
int16_t
us
[
4
][
4
],
int16_t
vs
[
4
][
4
],
float
*
du
,
float
*
dv
)
{
const
float
phi
=
atan2f
(
vec
[
0
],
-
vec
[
2
])
*
s
->
input_mirror_modifier
[
0
];
const
float
theta
=
asinf
(
-
vec
[
1
])
*
s
->
input_mirror_modifier
[
1
];
const
float
theta_range
=
M_PI_4
;
int
ew
,
eh
;
int
u_shift
,
v_shift
;
float
uf
,
vf
;
int
ui
,
vi
;
if
(
theta
>=
-
theta_range
&&
theta
<=
theta_range
)
{
const
float
scalew
=
s
->
fin_pad
>
0
?
1
.
f
-
s
->
fin_pad
/
(
width
*
2
.
f
/
3
.
f
)
:
1
.
f
-
s
->
in_pad
;
const
float
scaleh
=
s
->
fin_pad
>
0
?
1
.
f
-
s
->
fin_pad
/
(
height
/
2
.
f
)
:
1
.
f
-
s
->
in_pad
;
ew
=
width
/
3
*
2
;
eh
=
height
/
2
;
u_shift
=
s
->
ih_flip
?
width
/
3
:
0
;
v_shift
=
phi
>=
M_PI_2
||
phi
<
-
M_PI_2
?
eh
:
0
;
uf
=
fmodf
(
phi
,
M_PI_2
)
/
M_PI_2
;
vf
=
theta
/
M_PI_4
;
if
(
v_shift
)
uf
=
uf
>=
0
.
f
?
fmodf
(
uf
-
1
.
f
,
1
.
f
)
:
fmodf
(
uf
+
1
.
f
,
1
.
f
);
uf
=
(
uf
*
scalew
+
1
.
f
)
*
width
/
3
.
f
;
vf
=
(
vf
*
scaleh
+
1
.
f
)
*
height
/
4
.
f
;
}
else
{
const
float
scalew
=
s
->
fin_pad
>
0
?
1
.
f
-
s
->
fin_pad
/
(
width
/
3
.
f
)
:
1
.
f
-
s
->
in_pad
;
const
float
scaleh
=
s
->
fin_pad
>
0
?
1
.
f
-
s
->
fin_pad
/
(
height
/
4
.
f
)
:
1
.
f
-
s
->
in_pad
;
int
v_offset
=
0
;
ew
=
width
/
3
;
eh
=
height
/
4
;
u_shift
=
s
->
ih_flip
?
0
:
2
*
ew
;
if
(
theta
<=
0
.
f
&&
theta
>=
-
M_PI_2
&&
phi
<=
M_PI_2
&&
phi
>=
-
M_PI_2
)
{
uf
=
vec
[
0
]
/
vec
[
1
];
vf
=
-
vec
[
2
]
/
vec
[
1
];
v_shift
=
0
;
v_offset
=
-
eh
;
}
else
if
(
theta
>=
0
.
f
&&
theta
<=
M_PI_2
&&
phi
<=
M_PI_2
&&
phi
>=
-
M_PI_2
)
{
uf
=
-
vec
[
0
]
/
vec
[
1
];
vf
=
-
vec
[
2
]
/
vec
[
1
];
v_shift
=
height
*
0
.
25
f
;
}
else
if
(
theta
<=
0
.
f
&&
theta
>=
-
M_PI_2
)
{
uf
=
-
vec
[
0
]
/
vec
[
1
];
vf
=
vec
[
2
]
/
vec
[
1
];
v_shift
=
height
*
0
.
5
f
;
v_offset
=
-
eh
;
}
else
{
uf
=
vec
[
0
]
/
vec
[
1
];
vf
=
vec
[
2
]
/
vec
[
1
];
v_shift
=
height
*
0
.
75
f
;
}
uf
*=
s
->
input_mirror_modifier
[
0
]
*
s
->
input_mirror_modifier
[
1
];
vf
*=
s
->
input_mirror_modifier
[
1
];
uf
=
0
.
5
f
*
width
/
3
.
f
*
(
uf
*
scalew
+
1
.
f
);
vf
=
height
*
0
.
25
f
*
(
vf
*
scaleh
+
1
.
f
)
+
v_offset
;
}
ui
=
floorf
(
uf
);
vi
=
floorf
(
vf
);
*
du
=
uf
-
ui
;
*
dv
=
vf
-
vi
;
for
(
int
i
=
-
1
;
i
<
3
;
i
++
)
{
for
(
int
j
=
-
1
;
j
<
3
;
j
++
)
{
us
[
i
+
1
][
j
+
1
]
=
u_shift
+
av_clip
(
ui
+
j
,
0
,
ew
-
1
);
vs
[
i
+
1
][
j
+
1
]
=
v_shift
+
av_clip
(
vi
+
i
,
0
,
eh
-
1
);
}
}
return
1
;
}
/**
* Calculate 3D coordinates on sphere for corresponding frame position in barrel split facebook's format.
*
...
...
@@ -3012,16 +3112,18 @@ static int barrelsplit_to_xyz(const V360Context *s,
int
i
,
int
j
,
int
width
,
int
height
,
float
*
vec
)
{
const
float
scale
=
1
.
01
f
;
const
float
x
=
(
i
+
0
.
5
f
)
/
width
;
const
float
y
=
(
j
+
0
.
5
f
)
/
height
;
float
l_x
,
l_y
,
l_z
;
if
(
x
<=
2
.
f
/
3
.
f
)
{
if
(
x
<
2
.
f
/
3
.
f
)
{
const
float
scalew
=
s
->
fout_pad
>
0
?
1
.
f
-
s
->
fout_pad
/
(
width
*
2
.
f
/
3
.
f
)
:
1
.
f
-
s
->
out_pad
;
const
float
scaleh
=
s
->
fout_pad
>
0
?
1
.
f
-
s
->
fout_pad
/
(
height
/
2
.
f
)
:
1
.
f
-
s
->
out_pad
;
const
float
back
=
floorf
(
y
*
2
.
f
);
const
float
phi
=
((
3
.
f
/
2
.
f
*
x
-
0
.
5
f
)
*
scale
-
back
+
1
.
f
)
*
M_PI
;
const
float
theta
=
(
y
-
0
.
25
f
-
0
.
5
f
*
back
)
*
scale
*
M_PI
;
const
float
phi
=
((
3
.
f
/
2
.
f
*
x
-
0
.
5
f
)
/
scalew
-
back
+
1
.
f
)
*
M_PI
;
const
float
theta
=
(
y
-
0
.
25
f
-
0
.
5
f
*
back
)
/
scaleh
*
M_PI
;
const
float
sin_phi
=
sinf
(
phi
);
const
float
cos_phi
=
cosf
(
phi
);
...
...
@@ -3032,46 +3134,47 @@ static int barrelsplit_to_xyz(const V360Context *s,
l_y
=
-
sin_theta
;
l_z
=
cos_theta
*
cos_phi
;
}
else
{
const
float
scalew
=
s
->
fout_pad
>
0
?
1
.
f
-
s
->
fout_pad
/
(
width
/
3
.
f
)
:
1
.
f
-
s
->
out_pad
;
const
float
scaleh
=
s
->
fout_pad
>
0
?
1
.
f
-
s
->
fout_pad
/
(
height
/
4
.
f
)
:
1
.
f
-
s
->
out_pad
;
const
int
face
=
floorf
(
y
*
4
.
f
);
float
uf
,
vf
;
uf
=
x
*
3
.
f
-
2
.
f
;
uf
=
(
uf
-
0
.
5
f
)
*
scale
+
0
.
5
f
;
switch
(
face
)
{
case
0
:
vf
=
y
*
2
.
f
;
uf
=
1
.
f
-
uf
;
vf
=
(
0
.
5
f
-
vf
)
*
scale
;
vf
=
0
.
5
f
-
vf
;
l_x
=
0
.
5
f
-
uf
;
l_x
=
(
0
.
5
f
-
uf
)
/
scalew
;
l_y
=
0
.
5
f
;
l_z
=
-
0
.
5
f
+
vf
;
l_z
=
(
-
0
.
5
f
+
vf
)
/
scaleh
;
break
;
case
1
:
vf
=
y
*
2
.
f
;
uf
=
1
.
f
-
uf
;
vf
=
1
.
f
-
(
vf
-
0
.
5
f
)
*
scale
;
vf
=
1
.
f
-
(
vf
-
0
.
5
f
);
l_x
=
0
.
5
f
-
uf
;
l_x
=
(
0
.
5
f
-
uf
)
/
scalew
;
l_y
=
-
0
.
5
f
;
l_z
=
0
.
5
f
-
vf
;
l_z
=
(
0
.
5
f
-
vf
)
/
scaleh
;
break
;
case
2
:
vf
=
y
*
2
.
f
-
0
.
5
f
;
vf
=
1
.
f
-
(
1
.
f
-
vf
)
*
scale
;
vf
=
1
.
f
-
(
1
.
f
-
vf
);
l_x
=
0
.
5
f
-
uf
;
l_y
=
0
.
5
f
;
l_z
=
-
0
.
5
f
+
vf
;
l_x
=
(
0
.
5
f
-
uf
)
/
scalew
;
l_y
=
0
.
5
f
;
l_z
=
(
-
0
.
5
f
+
vf
)
/
scaleh
;
break
;
case
3
:
vf
=
y
*
2
.
f
-
1
.
5
f
;
vf
=
vf
*
scale
;
l_x
=
0
.
5
f
-
uf
;
l_x
=
(
0
.
5
f
-
uf
)
/
scalew
;
l_y
=
-
0
.
5
f
;
l_z
=
0
.
5
f
-
vf
;
l_z
=
(
0
.
5
f
-
vf
)
/
scaleh
;
break
;
}
}
...
...
@@ -3456,7 +3559,6 @@ static int config_output(AVFilterLink *outlink)
wf
=
w
;
hf
=
h
;
break
;
case
BARREL_SPLIT
:
case
PERSPECTIVE
:
case
PANNINI
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Supplied format is not accepted as input.
\n
"
);
...
...
@@ -3521,6 +3623,12 @@ static int config_output(AVFilterLink *outlink)
wf
=
w
;
hf
=
h
;
break
;
case
BARREL_SPLIT
:
s
->
in_transform
=
xyz_to_barrelsplit
;
err
=
0
;
wf
=
w
*
4
.
f
/
3
.
f
;
hf
=
h
;
break
;
default
:
av_log
(
ctx
,
AV_LOG_ERROR
,
"Specified input 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