summaryrefslogtreecommitdiffstats
path: root/video/decode/dec_video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-16 23:22:55 +0200
committerwm4 <wm4@nowhere>2013-07-16 23:22:55 +0200
commit18b6c01d921c1dea0986bba4bcd867da5605a3d8 (patch)
tree3489728f82c0270a72005f64590781118b02540f /video/decode/dec_video.c
parenta98aad61f854d9a216675dc54096aa39767c4a35 (diff)
downloadmpv-18b6c01d921c1dea0986bba4bcd867da5605a3d8.tar.bz2
mpv-18b6c01d921c1dea0986bba4bcd867da5605a3d8.tar.xz
video: redo how colorspaces are handled
Instead of handling colorspaces with VFCTRLs/VOCTRLs, make them part of the normal video format negotiation. The colorspace is passed down like other video params with config/reconfig calls. Forcing colorspaces (via the --colormatrix options and properties) is handled differently too: if it's changed, completely reinit the video chain. This is slower and requires a precise seek to the same position to perform an update, but it's simpler and less bug-prone. Considering switching the colorspace at runtime by user-interaction is a rather obscure feature, this is a good change. The colorspace VFCTRLs and VOCTRLs are still kept. The VOs rely on it, and would have to be changed to get rid of them. We'll do that later, and convert them incrementally instead of in one go. Note that controlling the output range now always works on VO level. Basically, this means you can't get vf_scale to output full-range YUV for whatever reason. If that is really wanted, it should be a vf_scale option. the previous behavior didn't make too much sense anyway. This commit fixes a few bugs (such as playing RGB video and converting that to YUV with vf_scale - a recent commit broke this and forced the VO to display YUV as RGB if possible), and might introduce some new ones.
Diffstat (limited to 'video/decode/dec_video.c')
-rw-r--r--video/decode/dec_video.c51
1 files changed, 8 insertions, 43 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index cd9e8be1e5..595ffb0e16 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -106,62 +106,27 @@ int get_video_colors(sh_video_t *sh_video, const char *item, int *value)
// This is affected by user-specified overrides (aspect, colorspace...).
bool get_video_params(struct sh_video *sh, struct mp_image_params *p)
{
- struct MPOpts *opts = sh->opts;
-
if (!sh->vf_input)
return false;
*p = *sh->vf_input;
-
- // Apply user overrides
- if (opts->requested_colorspace != MP_CSP_AUTO)
- p->colorspace = opts->requested_colorspace;
- if (opts->requested_input_range != MP_CSP_LEVELS_AUTO)
- p->colorlevels = opts->requested_input_range;
-
- // Make sure the user-overrides are consistent (no RGB csp for YUV, etc.)
- mp_image_params_guess_csp(p);
-
return true;
}
-void set_video_colorspace(struct sh_video *sh)
+void set_video_output_levels(struct sh_video *sh)
{
struct MPOpts *opts = sh->opts;
- struct vf_instance *vf = sh->vfilter;
- struct mp_image_params params;
- if (!get_video_params(sh, &params))
+ if (!sh->vfilter)
return;
- struct mp_csp_details requested = {
- .format = params.colorspace,
- .levels_in = params.colorlevels,
- .levels_out = opts->requested_output_range,
- };
- if (requested.levels_out == MP_CSP_LEVELS_AUTO)
- requested.levels_out = MP_CSP_LEVELS_PC;
-
- vf_control(vf, VFCTRL_SET_YUV_COLORSPACE, &requested);
-
- struct mp_csp_details actual = MP_CSP_DETAILS_DEFAULTS;
- vf_control(vf, VFCTRL_GET_YUV_COLORSPACE, &actual);
-
- int success = actual.format == requested.format
- && actual.levels_in == requested.levels_in
- && actual.levels_out == requested.levels_out;
-
- if (!success)
- mp_tmsg(MSGT_DECVIDEO, MSGL_WARN,
- "Colorspace details not fully supported by selected vo.\n");
-
- if (actual.format != requested.format
- && requested.format == MP_CSP_SMPTE_240M) {
- // BT.709 is pretty close, much better than BT.601
- requested.format = MP_CSP_BT_709;
- vf_control(vf, VFCTRL_SET_YUV_COLORSPACE, &requested);
+ 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)