summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-10-12 21:24:25 +0200
committerwm4 <wm4@nowhere>2015-10-12 21:24:25 +0200
commit8d004f07a459fc390e243d486419c23197dedbf8 (patch)
treeee398578c81687c5b412a7488922f1392b40137e /video/decode
parent14a2993796c4f6ab0cb65e656a9b06c0672c79d2 (diff)
downloadmpv-8d004f07a459fc390e243d486419c23197dedbf8.tar.bz2
mpv-8d004f07a459fc390e243d486419c23197dedbf8.tar.xz
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.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/vd_lavc.c3
1 files changed, 3 insertions, 0 deletions
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])) {