summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-08-30 23:24:46 +0200
committerwm4 <wm4@nowhere>2014-08-30 23:24:46 +0200
commit8599c959fe9334bc4d226faf813166ef8bc8efd5 (patch)
tree433530a09dd4b22173092b10452d7a35325de570 /options
parentc80adac07772f5b3c7a6c31e3e05480252f84171 (diff)
downloadmpv-8599c959fe9334bc4d226faf813166ef8bc8efd5.tar.bz2
mpv-8599c959fe9334bc4d226faf813166ef8bc8efd5.tar.xz
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 'options')
-rw-r--r--options/m_option.c53
-rw-r--r--options/m_option.h6
-rw-r--r--options/options.c1
-rw-r--r--options/options.h1
4 files changed, 60 insertions, 1 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 6ab1fc1f7a..a84d7e4d41 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -1983,6 +1983,59 @@ const m_option_type_t m_option_type_imgfmt = {
.copy = copy_opt,
};
+#include "video/csputils.h"
+
+static int parse_stereo_mode(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
+{
+ if (param.len == 0)
+ return M_OPT_MISSING_PARAM;
+
+ if (!bstrcmp0(param, "help")) {
+ mp_info(log, "Available modes:");
+ for (int n = 0; n < MP_STEREO3D_COUNT; n++) {
+ if (mp_stereo3d_names[n])
+ mp_info(log, " %s\n", mp_stereo3d_names[n]);
+ }
+ mp_info(log, " none\n");
+ return M_OPT_EXIT - 1;
+ }
+
+ int mode = -1;
+
+ for (int n = 0; n < MP_STEREO3D_COUNT; n++) {
+ if (bstr_equals(param, bstr0(mp_stereo3d_names[n]))) {
+ mode = n;
+ break;
+ }
+ }
+
+ if (mode < 0 && !bstr_equals0(param, "none")) {
+ mp_err(log, "Option %.*s: unknown parameter: '%.*s'\n",
+ BSTR_P(name), BSTR_P(param));
+ return M_OPT_INVALID;
+ }
+
+ if (dst)
+ *((int *)dst) = mode;
+
+ return 1;
+}
+
+static char *print_stereo_mode(const m_option_t *opt, const void *val)
+{
+ int mode = *(int *)val;
+ const char *name = mode >= 0 ? MP_STEREO3D_NAME(mode) : "none";
+ return talloc_strdup(NULL, name);
+}
+
+const m_option_type_t m_option_vid_stereo_mode = {
+ .name = "Stereo 3D mode",
+ .size = sizeof(int),
+ .parse = parse_stereo_mode,
+ .print = print_stereo_mode,
+};
+
static int parse_fourcc(struct mp_log *log, const m_option_t *opt,
struct bstr name, struct bstr param, void *dst)
{
diff --git a/options/m_option.h b/options/m_option.h
index d0ca211aa1..d7541a5c73 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -56,6 +56,7 @@ extern const m_option_type_t m_option_type_msglevels;
extern const m_option_type_t m_option_type_print_fn;
extern const m_option_type_t m_option_type_subconfig;
extern const m_option_type_t m_option_type_imgfmt;
+extern const m_option_type_t m_option_vid_stereo_mode;
extern const m_option_type_t m_option_type_fourcc;
extern const m_option_type_t m_option_type_afmt;
extern const m_option_type_t m_option_type_color;
@@ -648,8 +649,11 @@ extern const char m_option_path_separator;
#define OPT_TRACKCHOICE(name, var) \
OPT_CHOICE_OR_INT(name, var, 0, 1, 8190, ({"no", -2}, {"auto", -1}))
+#define OPT_VID_STEREO_MODE(...) \
+ OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_vid_stereo_mode)
+
#define OPT_STRING_VALIDATE_(optname, varname, flags, validate_fn, ...) \
- OPT_GENERAL(char*, optname, varname, flags, __VA_ARGS__, \
+ OPT_GENERAL(char*, optname, varname, flags, __VA_ARGS__, \
.priv = MP_EXPECT_TYPE(m_opt_string_validate_fn, validate_fn))
#define OPT_STRING_VALIDATE(...) \
OPT_STRING_VALIDATE_(__VA_ARGS__, .type = &m_option_type_string)
diff --git a/options/options.c b/options/options.c
index 0f97528ba1..00c8c0fbb5 100644
--- a/options/options.c
+++ b/options/options.c
@@ -415,6 +415,7 @@ const m_option_t mp_opts[] = {
{"BT.2020", MP_CSP_PRIM_BT_2020})),
OPT_CHOICE_OR_INT("video-rotate", video_rotate, 0, 0, 359,
({"no", -1})),
+ OPT_VID_STEREO_MODE("video-stereo-mode", video_stereo_mode, 0),
OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0,
0, 30000, ({"no", -1}, {"always", -2})),
diff --git a/options/options.h b/options/options.h
index 4468d2abbd..701c9e236b 100644
--- a/options/options.h
+++ b/options/options.h
@@ -98,6 +98,7 @@ typedef struct MPOpts {
int requested_primaries;
int video_rotate;
+ int video_stereo_mode;
char *audio_decoders;
char *video_decoders;