diff --git a/libmpcodecs/sws_utils.c b/libmpcodecs/sws_utils.c index 65b079dd84..d7500efe2e 100644 --- a/libmpcodecs/sws_utils.c +++ b/libmpcodecs/sws_utils.c @@ -131,6 +131,14 @@ struct SwsContext *sws_getContextFromCmdLine_hq(int srcW, int srcH, SWS_ACCURATE_RND | SWS_BITEXACT); } +bool mp_sws_supported_format(int imgfmt) +{ + enum PixelFormat av_format = imgfmt2pixfmt(imgfmt); + + return av_format != PIX_FMT_NONE && sws_isSupportedInput(av_format) + && sws_isSupportedOutput(av_format); +} + void mp_image_swscale(struct mp_image *dst, const struct mp_image *src, struct mp_csp_details *csp, diff --git a/libmpcodecs/sws_utils.h b/libmpcodecs/sws_utils.h index b2c55eb407..70b7d0b7fb 100644 --- a/libmpcodecs/sws_utils.h +++ b/libmpcodecs/sws_utils.h @@ -1,6 +1,7 @@ #ifndef MPLAYER_SWS_UTILS_H #define MPLAYER_SWS_UTILS_H +#include #include struct mp_image; @@ -22,8 +23,12 @@ struct SwsContext *sws_getContextFromCmdLine_hq(int srcW, int srcH, int dstFormat); int mp_sws_set_colorspace(struct SwsContext *sws, struct mp_csp_details *csp); -void mp_image_swscale(struct mp_image *dst, const struct mp_image *src, - struct mp_csp_details *csp, int my_sws_flags); +bool mp_sws_supported_format(int imgfmt); + +void mp_image_swscale(struct mp_image *dst, + const struct mp_image *src, + struct mp_csp_details *csp, + int my_sws_flags); #endif /* MP_SWS_UTILS_H */ diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index 315e52dfdd..9945a8fc89 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -464,6 +464,9 @@ void mp_draw_sub_bitmaps(struct mp_draw_sub_cache **cache, struct mp_image *dst, float yuv2rgb[3][4]; float rgb2yuv[3][4]; + if (!mp_sws_supported_format(dst->imgfmt)) + return; + if (cache && !*cache) *cache = talloc_zero(NULL, struct mp_draw_sub_cache);