summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-23 14:01:45 +0200
committerwm4 <wm4@nowhere>2015-09-23 14:20:50 +0200
commit4d6c1be7b69e99534cb6ac37daf8a22e7b2b153d (patch)
tree91e3804dba0c206845130e0a220f9cdb8667af0b
parent79f8ee2808ebdf100d1a3aba9a853f801698a2ad (diff)
downloadmpv-4d6c1be7b69e99534cb6ac37daf8a22e7b2b153d.tar.bz2
mpv-4d6c1be7b69e99534cb6ac37daf8a22e7b2b153d.tar.xz
vd_lavc: minor cleanup to hwdec fallback code
The comment was largely outdated, and described the old situation when we used a "violent" fallback by making get_buffer2 fail completely. Also, for the case when the hw decoder initialization succeeded (in get_format), but get_buffer2 for some reason requests something unexpected, we also can fallback more gracefully and in the same way.
-rw-r--r--video/decode/vd_lavc.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index d9974e2531..375014e541 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -568,23 +568,16 @@ static int get_buffer2_hwdec(AVCodecContext *avctx, AVFrame *pic, int flags)
struct dec_video *vd = avctx->opaque;
vd_ffmpeg_ctx *ctx = vd->priv;
- if (ctx->hwdec_failed)
- return avcodec_default_get_buffer2(avctx, pic, flags);
-
- /* Decoders using ffmpeg's hwaccel architecture (everything except vdpau)
- * can fall back to software decoding automatically. However, we don't
- * want that: multithreading was already disabled. ffmpeg's fallback
- * isn't really useful, and causes more trouble than it helps.
- *
- * Instead of trying to "adjust" the thread_count fields in avctx, let
- * decoding fail hard. Then decode_with_fallback() will do our own software
- * fallback. Fully reinitializing the decoder is saner, and will probably
- * save us from other weird corner cases, like having to "reroute" the
- * get_buffer callback.
- */
int imgfmt = pixfmt2imgfmt(pic->format);
if (!IMGFMT_IS_HWACCEL(imgfmt) || !ctx->hwdec)
- return -1;
+ ctx->hwdec_failed = true;
+
+ /* Hardware decoding failed, and we will trigger a proper fallback later
+ * when returning from the decode call. (We are forcing complete
+ * reinitialization later to reset the thread count properly.)
+ */
+ if (ctx->hwdec_failed)
+ return avcodec_default_get_buffer2(avctx, pic, flags);
// We expect it to use the exact size used to create the hw decoder in
// get_format_hwdec(). For cropped video, this is expected to be the