path: root/demux/demux_mkv.c
diff options
authorwm4 <wm4@nowhere>2014-08-30 23:24:46 +0200
committerwm4 <wm4@nowhere>2014-08-30 23:24:46 +0200
commit8599c959fe9334bc4d226faf813166ef8bc8efd5 (patch)
tree433530a09dd4b22173092b10452d7a35325de570 /demux/demux_mkv.c
parentc80adac07772f5b3c7a6c31e3e05480252f84171 (diff)
video: initial Matroska 3D support
This inserts an automatic conversion filter if a Matroska file is marked as 3D (StereoMode element). The basic idea is similar to video rotation and colorspace handling: the 3D mode is added as a property to the video params. Depending on this property, a video filter can be inserted. As of this commit, extending mp_image_params is actually completely unnecessary - but the idea is that it will make it easier to integrate with VOs supporting stereo 3D mogrification. Although vo_opengl does support some stereo rendering, it didn't support the mode my sample file used, so I'll leave that part for later. Not that most mappings from Matroska mode to vf_stereo3d mode are probably wrong, and some are missing. Assuming that Matroska modes, and vf_stereo3d in modes, and out modes are all the same might be an oversimplification - we'll see. See issue #1045.
Diffstat (limited to 'demux/demux_mkv.c')
1 files changed, 12 insertions, 0 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 02efcb2a0a..1f4ef89e34 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -46,6 +46,7 @@
#include "options/options.h"
#include "misc/bstr.h"
#include "stream/stream.h"
+#include "video/csputils.h"
#include "demux.h"
#include "stheader.h"
#include "ebml.h"
@@ -102,6 +103,7 @@ typedef struct mkv_track {
bool v_dwidth_set, v_dheight_set;
double v_frate;
uint32_t colorspace;
+ int stereo_mode;
uint32_t a_formattag;
uint32_t a_channels, a_bps;
@@ -504,6 +506,15 @@ static void parse_trackvideo(struct demuxer *demuxer, struct mkv_track *track,
MP_VERBOSE(demuxer, "| + Colorspace: %#x\n",
(unsigned int)track->colorspace);
+ if (video->n_stereo_mode) {
+ const char *name = MP_STEREO3D_NAME(video->stereo_mode);
+ if (name) {
+ track->stereo_mode = video->stereo_mode;
+ MP_VERBOSE(demuxer, "| + StereoMode: %s\n", name);
+ } else {
+ MP_WARN(demuxer, "Unknown StereoMode: %d\n", (int)video->stereo_mode);
+ }
+ }
@@ -1276,6 +1287,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
MP_VERBOSE(demuxer, "Aspect: %f\n", sh_v->aspect);
sh_v->avi_dts = track->ms_compat;
+ sh_v->stereo_mode = track->stereo_mode;
return 0;