summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-24 17:53:30 +0100
committerwm4 <wm4@nowhere>2016-03-24 17:53:30 +0100
commit4300bfd5180b7d287d93b04d8e600f34886e0c53 (patch)
tree21626648c5f27c5b3e47c35bc55050a1ebcb5017 /video/decode
parentf0febc35eb0bf7376e31e3d325a84b532aa2b886 (diff)
downloadmpv-4300bfd5180b7d287d93b04d8e600f34886e0c53.tar.bz2
mpv-4300bfd5180b7d287d93b04d8e600f34886e0c53.tar.xz
ad_lavc, vd_lavc: support new Libav decoding API
For now only found in Libav.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/vd_lavc.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 56633c0227..9559e0800f 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -646,6 +646,7 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
vd_ffmpeg_ctx *ctx = vd->priv;
AVCodecContext *avctx = ctx->avctx;
struct vd_lavc_params *opts = ctx->opts->vd_lavc_params;
+ bool consumed = false;
AVPacket pkt;
if (!avctx)
@@ -667,7 +668,23 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
reset_avctx(vd);
hwdec_lock(ctx);
+#if HAVE_AVCODEC_NEW_CODEC_API
+ ret = avcodec_send_packet(avctx, packet ? &pkt : NULL);
+ if (ret >= 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
+ if (ret >= 0)
+ consumed = true;
+ ret = avcodec_receive_frame(avctx, ctx->pic);
+ if (ret >= 0)
+ got_picture = 1;
+ if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
+ ret = 0;
+ } else {
+ consumed = true;
+ }
+#else
ret = avcodec_decode_video2(avctx, ctx->pic, &got_picture, &pkt);
+ consumed = true;
+#endif
hwdec_unlock(ctx);
// Reset decoder if it was fully flushed. Caller might send more flush
@@ -692,10 +709,8 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
return;
}
- if (packet) {
- // always fully consumed
+ if (packet && consumed)
packet->len = 0;
- }
// Skipped frame, or delayed output due to multithreaded decoding.
if (!got_picture) {