mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
hwcontext_vaapi: Do not assume that sw_format is transferable
Drivers can support a format for surfaces without also supporting it for images, so we can't assume that sw_format is usable for transfer. This would previously hit an assert in cases where it isn't.
This commit is contained in:
parent
52a44d50be
commit
6e0e3e1d8d
@ -627,24 +627,31 @@ static int vaapi_transfer_get_formats(AVHWFramesContext *hwfc,
|
||||
enum AVPixelFormat **formats)
|
||||
{
|
||||
VAAPIDeviceContext *ctx = hwfc->device_ctx->internal->priv;
|
||||
enum AVPixelFormat *pix_fmts, preferred_format;
|
||||
int i, k;
|
||||
enum AVPixelFormat *pix_fmts;
|
||||
int i, k, sw_format_available;
|
||||
|
||||
preferred_format = hwfc->sw_format;
|
||||
sw_format_available = 0;
|
||||
for (i = 0; i < ctx->nb_formats; i++) {
|
||||
if (ctx->formats[i].pix_fmt == hwfc->sw_format)
|
||||
sw_format_available = 1;
|
||||
}
|
||||
|
||||
pix_fmts = av_malloc((ctx->nb_formats + 1) * sizeof(*pix_fmts));
|
||||
if (!pix_fmts)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
pix_fmts[0] = preferred_format;
|
||||
k = 1;
|
||||
if (sw_format_available) {
|
||||
pix_fmts[0] = hwfc->sw_format;
|
||||
k = 1;
|
||||
} else {
|
||||
k = 0;
|
||||
}
|
||||
for (i = 0; i < ctx->nb_formats; i++) {
|
||||
if (ctx->formats[i].pix_fmt == preferred_format)
|
||||
if (ctx->formats[i].pix_fmt == hwfc->sw_format)
|
||||
continue;
|
||||
av_assert0(k < ctx->nb_formats);
|
||||
pix_fmts[k++] = ctx->formats[i].pix_fmt;
|
||||
}
|
||||
av_assert0(k == ctx->nb_formats);
|
||||
pix_fmts[k] = AV_PIX_FMT_NONE;
|
||||
|
||||
*formats = pix_fmts;
|
||||
|
Loading…
Reference in New Issue
Block a user