From 8d004f07a459fc390e243d486419c23197dedbf8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 12 Oct 2015 21:24:25 +0200 Subject: vd_lavc: work around libavcodec nonsense causing hwdec init failure The libavcodec h264 decoder contains some idiotic code with unknown purpose (no sample or explanation known that necessitates its existence), that causes the AVCodecContext.get_format callback to be invoked at a time when hwaccels can't be initialized. By definition, the get_format callback is supposed to initialize hwaccels (another idiotic thing now part of the API, but different story). This causes hwdec initialization sometimes to fail (WolfensteinTwitch.mp4): the first get_format callback will mark it as failed, so the second get_format (the "proper" normal one) will not bother restoring the state, and hwdec init fails. While this should be fixed in libavcodec (good luck with that), it's quite easy to workaround. --- video/decode/vd_lavc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'video/decode') diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index d501f75fdd..3d00fa6c41 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -519,6 +519,9 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, assert(ctx->hwdec); + ctx->hwdec_request_reinit |= ctx->hwdec_failed; + ctx->hwdec_failed = false; + if (ctx->hwdec->image_format) { for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) { if (ctx->hwdec->image_format == pixfmt2imgfmt(fmt[i])) { -- cgit v1.2.3