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
bde96422
Commit
bde96422
authored
Feb 10, 2017
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mkv: Export bounds and padding from spherical metadata
Update the fate test as needed.
parent
022b4ea5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
4 deletions
+66
-4
matroskadec.c
libavformat/matroskadec.c
+61
-3
matroska-spherical-mono
tests/ref/fate/matroska-spherical-mono
+5
-1
No files found.
libavformat/matroskadec.c
View file @
bde96422
...
@@ -1913,16 +1913,67 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
...
@@ -1913,16 +1913,67 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
AVSphericalMapping
*
spherical
;
AVSphericalMapping
*
spherical
;
enum
AVSphericalProjection
projection
;
enum
AVSphericalProjection
projection
;
size_t
spherical_size
;
size_t
spherical_size
;
size_t
l
=
0
,
t
=
0
,
r
=
0
,
b
=
0
;
size_t
padding
=
0
;
int
ret
;
int
ret
;
GetByteContext
gb
;
bytestream2_init
(
&
gb
,
track
->
video
.
projection
.
private
.
data
,
track
->
video
.
projection
.
private
.
size
);
if
(
bytestream2_get_byte
(
&
gb
)
!=
0
)
{
av_log
(
NULL
,
AV_LOG_WARNING
,
"Unknown spherical metadata
\n
"
);
return
0
;
}
bytestream2_skip
(
&
gb
,
3
);
// flags
switch
(
track
->
video
.
projection
.
type
)
{
switch
(
track
->
video
.
projection
.
type
)
{
case
MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR
:
case
MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR
:
projection
=
AV_SPHERICAL_EQUIRECTANGULAR
;
if
(
track
->
video
.
projection
.
private
.
size
==
0
)
projection
=
AV_SPHERICAL_EQUIRECTANGULAR
;
else
if
(
track
->
video
.
projection
.
private
.
size
==
20
)
{
t
=
bytestream2_get_be32
(
&
gb
);
b
=
bytestream2_get_be32
(
&
gb
);
l
=
bytestream2_get_be32
(
&
gb
);
r
=
bytestream2_get_be32
(
&
gb
);
if
(
b
>=
UINT_MAX
-
t
||
r
>=
UINT_MAX
-
l
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Invalid bounding rectangle coordinates "
"%"
SIZE_SPECIFIER
",%"
SIZE_SPECIFIER
","
"%"
SIZE_SPECIFIER
",%"
SIZE_SPECIFIER
"
\n
"
,
l
,
t
,
r
,
b
);
return
AVERROR_INVALIDDATA
;
}
if
(
l
||
t
||
r
||
b
)
projection
=
AV_SPHERICAL_EQUIRECTANGULAR_TILE
;
else
projection
=
AV_SPHERICAL_EQUIRECTANGULAR
;
}
else
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Unknown spherical metadata
\n
"
);
return
AVERROR_INVALIDDATA
;
}
break
;
break
;
case
MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP
:
case
MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP
:
if
(
track
->
video
.
projection
.
private
.
size
<
4
)
if
(
track
->
video
.
projection
.
private
.
size
<
4
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Missing projection private properties
\n
"
);
return
AVERROR_INVALIDDATA
;
}
else
if
(
track
->
video
.
projection
.
private
.
size
==
12
)
{
uint32_t
layout
=
bytestream2_get_be32
(
&
gb
);
if
(
layout
==
0
)
{
projection
=
AV_SPHERICAL_CUBEMAP
;
}
else
{
av_log
(
NULL
,
AV_LOG_WARNING
,
"Unknown spherical cubemap layout %"
PRIu32
"
\n
"
,
layout
);
return
0
;
}
padding
=
bytestream2_get_be32
(
&
gb
);
}
else
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Unknown spherical metadata
\n
"
);
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
projection
=
AV_SPHERICAL_CUBEMAP
;
}
break
;
break
;
default:
default:
return
0
;
return
0
;
...
@@ -1937,6 +1988,13 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
...
@@ -1937,6 +1988,13 @@ static int mkv_parse_video_projection(AVStream *st, const MatroskaTrack *track)
spherical
->
pitch
=
(
int32_t
)(
track
->
video
.
projection
.
pitch
*
(
1
<<
16
));
spherical
->
pitch
=
(
int32_t
)(
track
->
video
.
projection
.
pitch
*
(
1
<<
16
));
spherical
->
roll
=
(
int32_t
)(
track
->
video
.
projection
.
roll
*
(
1
<<
16
));
spherical
->
roll
=
(
int32_t
)(
track
->
video
.
projection
.
roll
*
(
1
<<
16
));
spherical
->
padding
=
padding
;
spherical
->
bound_left
=
l
;
spherical
->
bound_top
=
t
;
spherical
->
bound_right
=
r
;
spherical
->
bound_bottom
=
b
;
ret
=
av_stream_add_side_data
(
st
,
AV_PKT_DATA_SPHERICAL
,
(
uint8_t
*
)
spherical
,
ret
=
av_stream_add_side_data
(
st
,
AV_PKT_DATA_SPHERICAL
,
(
uint8_t
*
)
spherical
,
spherical_size
);
spherical_size
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
...
tests/ref/fate/matroska-spherical-mono
View file @
bde96422
...
@@ -8,7 +8,11 @@ inverted=0
...
@@ -8,7 +8,11 @@ inverted=0
[SIDE_DATA]
[SIDE_DATA]
side_data_type=Spherical Mapping
side_data_type=Spherical Mapping
side_data_size=56
side_data_size=56
projection=equirectangular
projection=tiled equirectangular
bound_left=148
bound_top=73
bound_right=147
bound_bottom=72
yaw=45
yaw=45
pitch=30
pitch=30
roll=15
roll=15
...
...
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