mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
sws_utils: provide function to check whether a format pair is supported
Normally, input and output are orthogonal. But zimg may gain image formats not supported by FFmpeg, which means the conversion will only work if zimg is used at all. This on the other hand, depends on whether the other format is also supported by zimg. (For example, a later commit adds RGB30 output to zimg. libswscale does not support this format. But if you have P010 as input, which the zimg wrapper does not support at all, the conversion won't work.) This makes such a function needed; so add it.
This commit is contained in:
parent
a495bfe373
commit
62bd8da490
@ -121,6 +121,21 @@ bool mp_sws_supported_format(int imgfmt)
|
||||
&& sws_isSupportedOutput(av_format);
|
||||
}
|
||||
|
||||
bool mp_sws_supports_formats(struct mp_sws_context *ctx,
|
||||
int imgfmt_out, int imgfmt_in)
|
||||
{
|
||||
#if HAVE_ZIMG
|
||||
if (ctx->allow_zimg && ctx->opts_allow_zimg) {
|
||||
if (mp_zimg_supports_in_format(imgfmt_in) &&
|
||||
mp_zimg_supports_out_format(imgfmt_out))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return sws_isSupportedInput(imgfmt2pixfmt(imgfmt_in)) &&
|
||||
sws_isSupportedOutput(imgfmt2pixfmt(imgfmt_out));
|
||||
}
|
||||
|
||||
static int mp_csp_to_sws_colorspace(enum mp_csp csp)
|
||||
{
|
||||
// The SWS_CS_* macros are just convenience redefinitions of the
|
||||
|
@ -59,6 +59,9 @@ void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct mpv_global *g);
|
||||
int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst,
|
||||
struct mp_image *src);
|
||||
|
||||
bool mp_sws_supports_formats(struct mp_sws_context *ctx,
|
||||
int imgfmt_out, int imgfmt_in);
|
||||
|
||||
struct mp_image *mp_img_swap_to_native(struct mp_image *img);
|
||||
|
||||
#endif /* MP_SWS_UTILS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user