diff options
author | Mark Thompson <sw@jkqxz.net> | 2017-11-24 00:21:26 +0000 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2017-11-26 15:40:24 +0000 |
commit | 6e0e3e1d8ddc83984876ed0e534fef42e7870b41 (patch) | |
tree | a59bb1e2895cad8d57b4a6648cca2817c8f846fd /libavutil/hwcontext_vaapi.c | |
parent | 52a44d50beb2ecf77213c9445649dcfd7ef44e92 (diff) | |
download | ffmpeg-6e0e3e1d8ddc83984876ed0e534fef42e7870b41.tar.gz |
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.
Diffstat (limited to 'libavutil/hwcontext_vaapi.c')
-rw-r--r-- | libavutil/hwcontext_vaapi.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index fcff25dc9b..29698d1b27 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -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; |