summaryrefslogtreecommitdiffstats
path: root/demux/demux_mkv.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-21 14:56:07 +0200
committerwm4 <wm4@nowhere>2017-08-21 14:56:07 +0200
commit028faacff56d7f90f6b119b0b0ac686fd614825f (patch)
tree33d77aa61946f3bebfdb28fa8670065fdb79aed8 /demux/demux_mkv.c
parent82d9419f62c90cecc13c492e3b68feebe0229daa (diff)
downloadmpv-028faacff56d7f90f6b119b0b0ac686fd614825f.tar.bz2
mpv-028faacff56d7f90f6b119b0b0ac686fd614825f.tar.xz
video: add metadata handling for spherical video
This adds handling of spherical video metadata: retrieving it from demux_lavf and demux_mkv, passing it through filters, and adjusting it with vf_format. This does not include support for rendering this type of video. We don't expect we need/want to support the other projection types like cube maps, so we don't include that for now. They can be added later as needed. Also raise the maximum sizes of stringified image params, since they can get really long.
Diffstat (limited to 'demux/demux_mkv.c')
-rw-r--r--demux/demux_mkv.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 9f670e2aa5..4b9551adae 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -109,6 +109,7 @@ typedef struct mkv_track {
uint32_t colorspace;
int stereo_mode;
struct mp_colorspace color;
+ struct mp_spherical_params spherical;
uint32_t a_channels, a_bps;
float a_sfreq;
@@ -584,6 +585,49 @@ static void parse_trackcolour(struct demuxer *demuxer, struct mkv_track *track,
}
}
+static void parse_trackprojection(struct demuxer *demuxer, struct mkv_track *track,
+ struct ebml_projection *projection)
+{
+ if (projection->n_projection_type) {
+ const char *name;
+ switch (projection->projection_type) {
+ case 0:
+ name = "rectangular";
+ track->spherical.type = MP_SPHERICAL_NONE;
+ break;
+ case 1:
+ name = "equirectangular";
+ track->spherical.type = MP_SPHERICAL_EQUIRECTANGULAR;
+ break;
+ default:
+ name = "unknown";
+ track->spherical.type = MP_SPHERICAL_UNKNOWN;
+ }
+ MP_VERBOSE(demuxer, "| + ProjectionType: %s (%"PRIu64")\n", name,
+ projection->projection_type);
+ }
+ if (projection->n_projection_private) {
+ MP_VERBOSE(demuxer, "| + ProjectionPrivate: %zd bytes\n",
+ projection->projection_private.len);
+ MP_WARN(demuxer, "Unknown ProjectionPrivate element.\n");
+ }
+ if (projection->n_projection_pose_yaw) {
+ track->spherical.ref_angles[0] = projection->projection_pose_yaw;
+ MP_VERBOSE(demuxer, "| + ProjectionPoseYaw: %f\n",
+ projection->projection_pose_yaw);
+ }
+ if (projection->n_projection_pose_pitch) {
+ track->spherical.ref_angles[1] = projection->projection_pose_pitch;
+ MP_VERBOSE(demuxer, "| + ProjectionPosePitch: %f\n",
+ projection->projection_pose_pitch);
+ }
+ if (projection->n_projection_pose_roll) {
+ track->spherical.ref_angles[2] = projection->projection_pose_roll;
+ MP_VERBOSE(demuxer, "| + ProjectionPoseRoll: %f\n",
+ projection->projection_pose_roll);
+ }
+}
+
static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
struct ebml_video *video)
{
@@ -628,6 +672,8 @@ static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
}
if (video->n_colour)
parse_trackcolour(demuxer, track, &video->colour);
+ if (video->n_projection)
+ parse_trackprojection(demuxer, track, &video->projection);
}
/**
@@ -1454,6 +1500,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
sh_v->stereo_mode = track->stereo_mode;
sh_v->color = track->color;
+ sh_v->spherical = track->spherical;
done:
demux_add_sh_stream(demuxer, sh);