summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-24 19:37:34 +0200
committerwm4 <wm4@nowhere>2013-08-24 19:40:18 +0200
commit47e92b2f884d4dd831e3e59ae9c692b460ef8dc3 (patch)
tree545d089a4a1be158c135fd43eaa33d4d93538925 /video
parentba4654b72977b915e5f09d23ce02e099c2bd9d0f (diff)
downloadmpv-47e92b2f884d4dd831e3e59ae9c692b460ef8dc3.tar.bz2
mpv-47e92b2f884d4dd831e3e59ae9c692b460ef8dc3.tar.xz
video: handle video output levels with mp_image_params
Until now, video output levels (obscure feature, like using TV screens that require RGB output in limited range, similar to YUY) still required handling of VOCTRL_SET_YUV_COLORSPACE. Simplify this, and use the new mp_image_params code. This gets rid of some code. VOCTRL_SET_YUV_COLORSPACE is not needed at all anymore in VOs that use the reconfig callback. The result of VOCTRL_GET_YUV_COLORSPACE is now used only used for the colormatrix related properties (basically, for display on OSD). For other VOs, VOCTRL_SET_YUV_COLORSPACE will be sent only once after config instead of twice.
Diffstat (limited to 'video')
-rw-r--r--video/decode/dec_video.c28
-rw-r--r--video/decode/dec_video.h3
-rw-r--r--video/decode/vd.c3
-rw-r--r--video/filter/vf.c1
-rw-r--r--video/filter/vf.h2
-rw-r--r--video/filter/vf_vo.c4
-rw-r--r--video/mp_image.h7
-rw-r--r--video/out/gl_video.c16
-rw-r--r--video/out/gl_video.h1
-rw-r--r--video/out/vo.c1
-rw-r--r--video/out/vo_opengl.c7
-rw-r--r--video/sws_utils.c11
12 files changed, 24 insertions, 60 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 22aa8f3e75..c16dc57eda 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -101,34 +101,6 @@ int get_video_colors(sh_video_t *sh_video, const char *item, int *value)
return 0;
}
-// Return the effective video image parameters. Might be different from VO,
-// and might be different from actual video bitstream/container params.
-// This is affected by user-specified overrides (aspect, colorspace...).
-bool get_video_params(struct sh_video *sh, struct mp_image_params *p)
-{
- if (!sh->vf_input)
- return false;
-
- *p = *sh->vf_input;
- return true;
-}
-
-void set_video_output_levels(struct sh_video *sh)
-{
- struct MPOpts *opts = sh->opts;
-
- if (!sh->vfilter)
- return;
-
- struct mp_csp_details csp;
- if (vf_control(sh->vfilter, VFCTRL_GET_YUV_COLORSPACE, &csp) > 0) {
- csp.levels_out = opts->requested_output_range;
- if (csp.levels_out == MP_CSP_LEVELS_AUTO)
- csp.levels_out = MP_CSP_LEVELS_PC;
- vf_control(sh->vfilter, VFCTRL_SET_YUV_COLORSPACE, &csp);
- }
-}
-
void resync_video_stream(sh_video_t *sh_video)
{
vd_control(sh_video, VDCTRL_RESYNC_STREAM, NULL);
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index 021abaaf22..339de7e860 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -37,9 +37,6 @@ int get_video_quality_max(sh_video_t *sh_video);
int get_video_colors(sh_video_t *sh_video, const char *item, int *value);
int set_video_colors(sh_video_t *sh_video, const char *item, int value);
-struct mp_image_params;
-bool get_video_params(struct sh_video *sh, struct mp_image_params *p);
-void set_video_output_levels(struct sh_video *sh);
void resync_video_stream(sh_video_t *sh_video);
void video_reinit_vo(struct sh_video *sh_video);
int get_current_video_decoder_lag(sh_video_t *sh_video);
diff --git a/video/decode/vd.c b/video/decode/vd.c
index 1518d78695..fad9adbdf7 100644
--- a/video/decode/vd.c
+++ b/video/decode/vd.c
@@ -157,6 +157,7 @@ int mpcodecs_reconfig_vo(sh_video_t *sh, const struct mp_image_params *params)
p.colorspace = opts->requested_colorspace;
if (opts->requested_input_range != MP_CSP_LEVELS_AUTO)
p.colorlevels = opts->requested_input_range;
+ p.outputlevels = opts->requested_output_range;
// Detect colorspace from resolution.
// Make sure the user-overrides are consistent (no RGB csp for YUV, etc.).
@@ -184,8 +185,6 @@ int mpcodecs_reconfig_vo(sh_video_t *sh, const struct mp_image_params *params)
sh->vf_input = talloc(sh, struct mp_image_params);
*sh->vf_input = p;
- set_video_output_levels(sh);
-
if (opts->gamma_gamma != 1000)
set_video_colors(sh, "gamma", opts->gamma_gamma);
if (opts->gamma_brightness != 1000)
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 85a03cfa85..a8469c9203 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -499,6 +499,7 @@ int vf_next_config(struct vf_instance *vf,
.colorspace = vf->fmt_in.params.colorspace,
.colorlevels = vf->fmt_in.params.colorlevels,
.chroma_location = vf->fmt_in.params.chroma_location,
+ .outputlevels = vf->fmt_in.params.outputlevels,
};
// Fix csp in case of pixel format change
mp_image_params_guess_csp(&p);
diff --git a/video/filter/vf.h b/video/filter/vf.h
index 29ce051869..730b0e0da0 100644
--- a/video/filter/vf.h
+++ b/video/filter/vf.h
@@ -106,8 +106,6 @@ typedef struct vf_seteq {
/* Hack to make the OSD state object available to vf_sub which
* access OSD/subtitle state outside of normal OSD draw time. */
#define VFCTRL_SET_OSD_OBJ 20
-#define VFCTRL_SET_YUV_COLORSPACE 22 // arg is struct mp_csp_details*
-#define VFCTRL_GET_YUV_COLORSPACE 23 // arg is struct mp_csp_details*
int vf_control(struct vf_instance *vf, int cmd, void *arg);
diff --git a/video/filter/vf_vo.c b/video/filter/vf_vo.c
index b3e7b7bd60..05f835d5fd 100644
--- a/video/filter/vf_vo.c
+++ b/video/filter/vf_vo.c
@@ -65,10 +65,6 @@ static int control(struct vf_instance *vf, int request, void *data)
return vo_control(video_out, VOCTRL_GET_DEINTERLACE, data) == VO_TRUE;
case VFCTRL_SET_DEINTERLACE:
return vo_control(video_out, VOCTRL_SET_DEINTERLACE, data) == VO_TRUE;
- case VFCTRL_GET_YUV_COLORSPACE:
- return vo_control(video_out, VOCTRL_GET_YUV_COLORSPACE, data) == true;
- case VFCTRL_SET_YUV_COLORSPACE:
- return vo_control(video_out, VOCTRL_SET_YUV_COLORSPACE, data) == true;
case VFCTRL_SET_EQUALIZER: {
vf_equalizer_t *eq = data;
if (!video_out->config_ok)
diff --git a/video/mp_image.h b/video/mp_image.h
index 7a70ec6a35..ac981533a0 100644
--- a/video/mp_image.h
+++ b/video/mp_image.h
@@ -37,6 +37,9 @@
#define MP_IMGFIELD_BOTTOM 0x10
#define MP_IMGFIELD_INTERLACED 0x20
+// Describes image parameters that usually stay constant.
+// New fields can be added in the future. Code changing the parameters should
+// usually copy the whole struct, so that fields added later will be preserved.
struct mp_image_params {
enum mp_imgfmt imgfmt; // pixel format
int w, h; // image dimensions
@@ -44,6 +47,10 @@ struct mp_image_params {
enum mp_csp colorspace;
enum mp_csp_levels colorlevels;
enum mp_chroma_location chroma_location;
+ // The image should be converted to these levels. Unlike colorlevels, it
+ // does not describe the current state of the image. (Somewhat similar to
+ // d_w/d_h vs. w/h.)
+ enum mp_csp_levels outputlevels;
};
/* Memory management:
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 6fb41e5814..e285be252a 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1973,6 +1973,12 @@ void gl_video_config(struct gl_video *p, struct mp_image_params *params)
p->image_dw = params->d_w;
p->image_dh = params->d_h;
p->image_params = *params;
+
+ struct mp_csp_details csp = MP_CSP_DETAILS_DEFAULTS;
+ csp.levels_in = params->colorlevels;
+ csp.levels_out = params->outputlevels;
+ csp.format = params->colorspace;
+ p->colorspace = csp;
}
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b)
@@ -2046,16 +2052,6 @@ bool gl_video_get_csp_override(struct gl_video *p, struct mp_csp_details *csp)
return true;
}
-bool gl_video_set_csp_override(struct gl_video *p, struct mp_csp_details *csp)
-{
- if (p->is_yuv) {
- p->colorspace = *csp;
- update_all_uniforms(p);
- return true;
- }
- return false;
-}
-
bool gl_video_set_equalizer(struct gl_video *p, const char *name, int val)
{
if (mp_csp_equalizer_set(&p->video_eq, name, val) >= 0) {
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index 2ed8507a9c..bc21310498 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -66,7 +66,6 @@ void gl_video_resize(struct gl_video *p, struct mp_rect *window,
struct mp_rect *src, struct mp_rect *dst,
struct mp_osd_res *osd);
bool gl_video_get_csp_override(struct gl_video *p, struct mp_csp_details *csp);
-bool gl_video_set_csp_override(struct gl_video *p, struct mp_csp_details *csp);
bool gl_video_set_equalizer(struct gl_video *p, const char *name, int val);
bool gl_video_get_equalizer(struct gl_video *p, const char *name, int *val);
diff --git a/video/out/vo.c b/video/out/vo.c
index f3fc4aca4d..014fcf03ad 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -430,6 +430,7 @@ int vo_reconfig(struct vo *vo, struct mp_image_params *params, int flags)
struct mp_csp_details csp;
if (vo_control(vo, VOCTRL_GET_YUV_COLORSPACE, &csp) > 0) {
csp.levels_in = params->colorlevels;
+ csp.levels_out = params->outputlevels;
csp.format = params->colorspace;
vo_control(vo, VOCTRL_SET_YUV_COLORSPACE, &csp);
}
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index a6950c8d11..9253920049 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -245,13 +245,6 @@ static int control(struct vo *vo, uint32_t request, void *data)
vo->want_redraw = true;
return r ? VO_TRUE : VO_NOTIMPL;
}
- case VOCTRL_SET_YUV_COLORSPACE: {
- mpgl_lock(p->glctx);
- gl_video_set_csp_override(p->renderer, data);
- mpgl_unlock(p->glctx);
- vo->want_redraw = true;
- return VO_TRUE;
- }
case VOCTRL_GET_YUV_COLORSPACE:
mpgl_lock(p->glctx);
gl_video_get_csp_override(p->renderer, data);
diff --git a/video/sws_utils.c b/video/sws_utils.c
index db91434553..7adecc49fc 100644
--- a/video/sws_utils.c
+++ b/video/sws_utils.c
@@ -179,6 +179,14 @@ struct mp_sws_context *mp_sws_alloc(void *talloc_parent)
// Optional, but possibly useful to avoid having to handle mp_sws_scale errors.
int mp_sws_reinit(struct mp_sws_context *ctx)
{
+ struct mp_image_params *src = &ctx->src;
+ struct mp_image_params *dst = &ctx->dst;
+
+ // Neutralize unsupported or ignored parameters.
+ src->d_w = dst->d_w = 0;
+ src->d_h = dst->d_h = 0;
+ src->outputlevels = dst->outputlevels = MP_CSP_LEVELS_AUTO;
+
if (cache_valid(ctx))
return 0;
@@ -187,9 +195,6 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
if (!ctx->sws)
return -1;
- struct mp_image_params *src = &ctx->src;
- struct mp_image_params *dst = &ctx->dst;
-
mp_image_params_guess_csp(src); // sanitize colorspace/colorlevels
mp_image_params_guess_csp(dst);