From 38342436cd59afd345595d83b329bc7c6ac3616f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Dec 2013 17:57:10 +0100 Subject: sws_utils: mp_msg conversions This requires the caller to provide a mp_log in order to see error messages. Unfortunately we don't do this in most places, but I guess we have to live with it. --- video/filter/vf_scale.c | 1 + video/sws_utils.c | 13 ++++++++++--- video/sws_utils.h | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index 2096292e68..bcb4cae2f2 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -393,6 +393,7 @@ static int vf_open(vf_instance_t *vf) vf->control = control; vf->uninit = uninit; vf->priv->sws = mp_sws_alloc(vf); + vf->priv->sws->log = vf->log; vf->priv->sws->params[0] = vf->priv->param[0]; vf->priv->sws->params[1] = vf->priv->param[1]; diff --git a/video/sws_utils.c b/video/sws_utils.c index 28ec10cb6a..4a6814b986 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -167,6 +167,7 @@ struct mp_sws_context *mp_sws_alloc(void *talloc_ctx) { struct mp_sws_context *ctx = talloc_ptrtype(talloc_ctx, ctx); *ctx = (struct mp_sws_context) { + .log = mp_null_log, .flags = SWS_BILINEAR, .contrast = 1 << 16, // 1.0 in 16.16 fixed point .saturation = 1 << 16, @@ -207,12 +208,18 @@ int mp_sws_reinit(struct mp_sws_context *ctx) return -1; enum AVPixelFormat s_fmt = imgfmt2pixfmt(src->imgfmt); - if (s_fmt == AV_PIX_FMT_NONE || sws_isSupportedInput(s_fmt) < 1) + if (s_fmt == AV_PIX_FMT_NONE || sws_isSupportedInput(s_fmt) < 1) { + MP_ERR(ctx, "Input image format %s not supported by libswscale.\n", + mp_imgfmt_to_name(src->imgfmt)); return -1; + } enum AVPixelFormat d_fmt = imgfmt2pixfmt(dst->imgfmt); - if (d_fmt == AV_PIX_FMT_NONE || sws_isSupportedOutput(d_fmt) < 1) + if (d_fmt == AV_PIX_FMT_NONE || sws_isSupportedOutput(d_fmt) < 1) { + MP_ERR(ctx, "Output image format %s not supported by libswscale.\n", + mp_imgfmt_to_name(dst->imgfmt)); return -1; + } int s_csp = mp_csp_to_sws_colorspace(src->colorspace); int s_range = src->colorlevels == MP_CSP_LEVELS_PC; @@ -283,7 +290,7 @@ int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst, int r = mp_sws_reinit(ctx); if (r < 0) { - mp_msg(MSGT_VFILTER, MSGL_ERR, "libswscale initialization failed.\n"); + MP_ERR(ctx, "libswscale initialization failed.\n"); return r; } diff --git a/video/sws_utils.h b/video/sws_utils.h index d6ea4b15b3..d20e197197 100644 --- a/video/sws_utils.h +++ b/video/sws_utils.h @@ -25,6 +25,8 @@ void mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src, float gblur); struct mp_sws_context { + // Can be set for verbose error printing. + struct mp_log *log; // User configuration. These can be changed freely, at any time. // mp_sws_scale() will handle the changes transparently. int flags; -- cgit v1.2.3