summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-02 22:44:39 +0100
committerwm4 <wm4@nowhere>2019-11-02 22:44:39 +0100
commit0e1cfe0c421699ab7fbf6f17b83721d28135a0b8 (patch)
tree703a6d077d4ee56c20a8f3f9c500b0b62466ba47 /video/decode
parent7bf31c51f2bd5b0d95b12a503be47e930419cae9 (diff)
downloadmpv-0e1cfe0c421699ab7fbf6f17b83721d28135a0b8.tar.bz2
mpv-0e1cfe0c421699ab7fbf6f17b83721d28135a0b8.tar.xz
vd_lavc: fix prepare_decoding() failure modes
prepare_decoding() returned a bool that was supposed to tell whether decoding could work, or if something was fucked. After recent changes to the decoder loop, this did not work anymore, and caused an endless loop. Redo it, so it makes more sense. avctx being NULL (software fallback initialization failed) now signals EOF. hwdec_failed needs to be handled on send_packet() only, where it probably never happens anyway. (Who was the idiot who made libavcodec have two entrypoints for decoding? Oh right, it was me. PEBKAC.)
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/vd_lavc.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 58cdc01cdb..fbb0e9c137 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -927,14 +927,14 @@ fallback:
return avcodec_default_get_buffer2(avctx, pic, flags);
}
-static bool prepare_decoding(struct mp_filter *vd)
+static void prepare_decoding(struct mp_filter *vd)
{
vd_ffmpeg_ctx *ctx = vd->priv;
AVCodecContext *avctx = ctx->avctx;
struct vd_lavc_params *opts = ctx->opts;
- if (!avctx || ctx->hwdec_failed)
- return false;
+ if (!avctx)
+ return;
int drop = ctx->framedrop_flags;
if (drop == 1) {
@@ -950,8 +950,6 @@ static bool prepare_decoding(struct mp_filter *vd)
if (ctx->hwdec_request_reinit)
reset_avctx(vd);
-
- return true;
}
static void handle_err(struct mp_filter *vd)
@@ -977,8 +975,13 @@ static int send_packet(struct mp_filter *vd, struct demux_packet *pkt)
if (ctx->num_requeue_packets && ctx->requeue_packets[0] != pkt)
return AVERROR(EAGAIN); // cannot consume the packet
- if (!prepare_decoding(vd))
- return AVERROR_UNKNOWN;
+ if (ctx->hwdec_failed)
+ return AVERROR(EAGAIN);
+
+ if (!ctx->avctx)
+ return AVERROR_EOF;
+
+ prepare_decoding(vd);
if (avctx->skip_frame == AVDISCARD_ALL)
return 0;
@@ -1019,8 +1022,10 @@ static int decode_frame(struct mp_filter *vd)
vd_ffmpeg_ctx *ctx = vd->priv;
AVCodecContext *avctx = ctx->avctx;
- if (!prepare_decoding(vd))
- return AVERROR_UNKNOWN;
+ if (!avctx)
+ return AVERROR_EOF;
+
+ prepare_decoding(vd);
// Re-send old packets (typically after a hwdec fallback during init).
if (ctx->num_requeue_packets)