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.
This commit is contained in:
wm4 2015-05-29 14:17:51 +02:00
parent 6a5cbe7802
commit 9fe6a8c5f5
1 changed files with 6 additions and 1 deletions

View File

@ -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)