summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-21 13:07:22 +0200
committerwm4 <wm4@nowhere>2012-10-12 10:10:31 +0200
commitd7207b4cbca3bb2335e87c899d978e56e22dc1a5 (patch)
tree5ccc06ce8d5f97c9d4e391430fb1874377547ee4 /command.c
parented8e738e0f7da90597732965fe4e8cd1feb9099a (diff)
downloadmpv-d7207b4cbca3bb2335e87c899d978e56e22dc1a5.tar.bz2
mpv-d7207b4cbca3bb2335e87c899d978e56e22dc1a5.tar.xz
commands: don't replicate mapping to option in levels_property_helper
This should be done by mp_property_generic_option() only. Also reindent levels_property_helper() to make it a little bit more readable. Remove the m_option_get_ptr() function, which doesn't really make sense anymore.
Diffstat (limited to 'command.c')
-rw-r--r--command.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/command.c b/command.c
index 1b61846205..f1e11d3a7d 100644
--- a/command.c
+++ b/command.c
@@ -915,39 +915,41 @@ static int mp_property_colormatrix(m_option_t *prop, int action, void *arg,
static int levels_property_helper(int offset, m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- char *optname = prop->priv;
- const struct m_option *opt = m_config_get_option(mpctx->mconfig,
- bstr0(optname));
- int *valptr = (int *)m_option_get_ptr(opt, &mpctx->opts);
-
- if (action == M_PROPERTY_PRINT) {
- struct mp_csp_details actual = {0};
- int actual_level = -1;
- char *req_level = m_option_print(opt, valptr);
- char *real_level = NULL;
- if (mpctx->sh_video) {
- struct vf_instance *vf = mpctx->sh_video->vfilter;
- if (vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, &actual) == true) {
- actual_level = *(enum mp_csp_levels *)(((char *)&actual) + offset);
- real_level = m_option_print(opt, &actual_level);
- } else {
- real_level = talloc_strdup(NULL, "Unknown");
- }
+ if (action != M_PROPERTY_PRINT)
+ return colormatrix_property_helper(prop, action, arg, mpctx);
+
+ const struct m_option *opt = NULL;
+ mp_property_generic_option(prop, M_PROPERTY_GET_TYPE, &opt, mpctx);
+ assert(opt);
+
+ int requested = 0;
+ mp_property_generic_option(prop, M_PROPERTY_GET, &requested, mpctx);
+
+ struct mp_csp_details actual = {0};
+ int actual_level = -1;
+ char *req_level = m_option_print(opt, &requested);
+ char *real_level = NULL;
+ if (mpctx->sh_video) {
+ struct vf_instance *vf = mpctx->sh_video->vfilter;
+ if (vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, &actual) == true) {
+ actual_level = *(enum mp_csp_levels *)(((char *)&actual) + offset);
+ real_level = m_option_print(opt, &actual_level);
+ } else {
+ real_level = talloc_strdup(NULL, "Unknown");
}
- char *res;
- if (*valptr == MP_CSP_LEVELS_AUTO && real_level) {
- res = talloc_asprintf(NULL, "Auto (%s)", real_level);
- } else if (*valptr == actual_level || !real_level) {
- res = talloc_strdup(NULL, real_level);
- } else
- res = talloc_asprintf(NULL, mp_gtext("%s, but %s used"),
- req_level, real_level);
- talloc_free(req_level);
- talloc_free(real_level);
- *(char **)arg = res;
- return M_PROPERTY_OK;
}
- return colormatrix_property_helper(prop, action, arg, mpctx);
+ char *res;
+ if (requested == MP_CSP_LEVELS_AUTO && real_level) {
+ res = talloc_asprintf(NULL, "Auto (%s)", real_level);
+ } else if (requested == actual_level || !real_level) {
+ res = talloc_strdup(NULL, real_level);
+ } else
+ res = talloc_asprintf(NULL, mp_gtext("%s, but %s used"),
+ req_level, real_level);
+ talloc_free(req_level);
+ talloc_free(real_level);
+ *(char **)arg = res;
+ return M_PROPERTY_OK;
}
static int mp_property_colormatrix_input_range(m_option_t *prop, int action,