mirror of https://github.com/mpv-player/mpv
draw_bmp: don't try to call swscale if image format not supported
If that happens, we silently fail.
This commit is contained in:
parent
bf68634d15
commit
a4f9077f6c
|
@ -131,6 +131,14 @@ struct SwsContext *sws_getContextFromCmdLine_hq(int srcW, int srcH,
|
||||||
SWS_ACCURATE_RND | SWS_BITEXACT);
|
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,
|
void mp_image_swscale(struct mp_image *dst,
|
||||||
const struct mp_image *src,
|
const struct mp_image *src,
|
||||||
struct mp_csp_details *csp,
|
struct mp_csp_details *csp,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef MPLAYER_SWS_UTILS_H
|
#ifndef MPLAYER_SWS_UTILS_H
|
||||||
#define MPLAYER_SWS_UTILS_H
|
#define MPLAYER_SWS_UTILS_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
|
|
||||||
struct mp_image;
|
struct mp_image;
|
||||||
|
@ -22,8 +23,12 @@ struct SwsContext *sws_getContextFromCmdLine_hq(int srcW, int srcH,
|
||||||
int dstFormat);
|
int dstFormat);
|
||||||
int mp_sws_set_colorspace(struct SwsContext *sws, struct mp_csp_details *csp);
|
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,
|
bool mp_sws_supported_format(int imgfmt);
|
||||||
struct mp_csp_details *csp, int my_sws_flags);
|
|
||||||
|
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 */
|
#endif /* MP_SWS_UTILS_H */
|
||||||
|
|
||||||
|
|
|
@ -464,6 +464,9 @@ void mp_draw_sub_bitmaps(struct mp_draw_sub_cache **cache, struct mp_image *dst,
|
||||||
float yuv2rgb[3][4];
|
float yuv2rgb[3][4];
|
||||||
float rgb2yuv[3][4];
|
float rgb2yuv[3][4];
|
||||||
|
|
||||||
|
if (!mp_sws_supported_format(dst->imgfmt))
|
||||||
|
return;
|
||||||
|
|
||||||
if (cache && !*cache)
|
if (cache && !*cache)
|
||||||
*cache = talloc_zero(NULL, struct mp_draw_sub_cache);
|
*cache = talloc_zero(NULL, struct mp_draw_sub_cache);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue