diff options
author | wm4 <wm4@nowhere> | 2015-01-15 20:10:08 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-15 20:10:08 +0100 |
commit | c118d8f6cc9950ef74d6b5c24bc3a3e56c4b7d42 (patch) | |
tree | 56f9e96739380c8b03ec425dd42ee7eac18d6fd1 | |
parent | a6997be61b6449117edf4e5aee0b10206a3bce67 (diff) | |
download | mpv-c118d8f6cc9950ef74d6b5c24bc3a3e56c4b7d42.tar.bz2 mpv-c118d8f6cc9950ef74d6b5c24bc3a3e56c4b7d42.tar.xz |
image_writer: check for conversion errors
This can happen when e.g. a VO returns a screenshot in an unsupported
format.
-rw-r--r-- | video/image_writer.c | 6 | ||||
-rw-r--r-- | video/sws_utils.c | 14 | ||||
-rw-r--r-- | video/sws_utils.h | 8 |
3 files changed, 17 insertions, 11 deletions
diff --git a/video/image_writer.c b/video/image_writer.c index 03f164bf91..ff321cfd1f 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -296,7 +296,11 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts, } mp_image_copy_attributes(dst, image); - mp_image_swscale(dst, image, mp_sws_hq_flags); + if (mp_image_swscale(dst, image, mp_sws_hq_flags) < 0) { + mp_err(log, "Error when converting image.\n"); + talloc_free(dst); + return 0; + } allocated_image = dst; image = dst; diff --git a/video/sws_utils.c b/video/sws_utils.c index a7fcc0469c..8937799f09 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -268,24 +268,26 @@ int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst, return 0; } -void mp_image_swscale(struct mp_image *dst, struct mp_image *src, - int my_sws_flags) +int mp_image_swscale(struct mp_image *dst, struct mp_image *src, + int my_sws_flags) { struct mp_sws_context *ctx = mp_sws_alloc(NULL); ctx->flags = my_sws_flags; - mp_sws_scale(ctx, dst, src); + int res = mp_sws_scale(ctx, dst, src); talloc_free(ctx); + return res; } -void mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src, - float gblur) +int mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src, + float gblur) { struct mp_sws_context *ctx = mp_sws_alloc(NULL); ctx->flags = mp_sws_hq_flags; ctx->src_filter = sws_getDefaultFilter(gblur, gblur, 0, 0, 0, 0, 0); ctx->force_reload = true; - mp_sws_scale(ctx, dst, src); + int res = mp_sws_scale(ctx, dst, src); talloc_free(ctx); + return res; } int mp_sws_get_vf_equalizer(struct mp_sws_context *sws, struct vf_seteq *eq) diff --git a/video/sws_utils.h b/video/sws_utils.h index cf9aa827b2..7c7c1af34b 100644 --- a/video/sws_utils.h +++ b/video/sws_utils.h @@ -18,11 +18,11 @@ extern const int mp_sws_fast_flags; bool mp_sws_supported_format(int imgfmt); -void mp_image_swscale(struct mp_image *dst, struct mp_image *src, - int my_sws_flags); +int mp_image_swscale(struct mp_image *dst, struct mp_image *src, + int my_sws_flags); -void mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src, - float gblur); +int 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. |