1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 14:52:43 +00:00

draw_bmp: don't try to call swscale if image format not supported

If that happens, we silently fail.
This commit is contained in:
wm4 2012-10-19 19:11:58 +02:00
parent bf68634d15
commit a4f9077f6c
3 changed files with 18 additions and 2 deletions

View File

@ -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,

View File

@ -1,6 +1,7 @@
#ifndef MPLAYER_SWS_UTILS_H
#define MPLAYER_SWS_UTILS_H
#include <stdbool.h>
#include <libswscale/swscale.h>
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 */

View File

@ -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);