From 9fe6a8c5f54ad89b962e3d88c641b352308beacd Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 29 May 2015 14:17:51 +0200 Subject: vd_lavc: fix a hw decoding fallback case On hw decoder reinit failure we did not actually always return a sw format, because the first format (fmt[0]) is not always a sw format. This broke some cases of fallback. We must go through the trouble to determine the first actual sw format. --- video/decode/vd_lavc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index de917a7820..bbe6734c19 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -538,7 +538,12 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, } ctx->hwdec_failed = true; - return fmt[0]; + for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) { + const AVPixFmtDescriptor *d = av_pix_fmt_desc_get(fmt[i]); + if (d && !(d->flags & AV_PIX_FMT_FLAG_HWACCEL)) + return fmt[i]; + } + return AV_PIX_FMT_NONE; } static void free_mpi(void *opaque, uint8_t *data) -- cgit v1.2.3