aboutsummaryrefslogtreecommitdiffhomepage
path: root/audio
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2016-03-24 17:53:30 +0100
committerGravatar wm4 <wm4@nowhere>2016-03-24 17:53:30 +0100
commit4300bfd5180b7d287d93b04d8e600f34886e0c53 (patch)
tree21626648c5f27c5b3e47c35bc55050a1ebcb5017 /audio
parentf0febc35eb0bf7376e31e3d325a84b532aa2b886 (diff)
ad_lavc, vd_lavc: support new Libav decoding API
For now only found in Libav.
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad_lavc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 0c61c03986..c5e6b09cd4 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -192,6 +192,19 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
int got_frame = 0;
av_frame_unref(priv->avframe);
+
+#if HAVE_AVCODEC_NEW_CODEC_API
+ int ret = avcodec_send_packet(avctx, &pkt);
+ if (ret >= 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
+ if (ret >= 0 && mpkt)
+ mpkt->len = 0;
+ ret = avcodec_receive_frame(avctx, priv->avframe);
+ if (ret >= 0)
+ got_frame = 1;
+ if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
+ ret = 0;
+ }
+#else
int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt);
if (mpkt) {
// At least "shorten" decodes sub-frames, instead of the whole packet.
@@ -208,6 +221,7 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
return 0;
}
}
+#endif
if (ret < 0) {
MP_ERR(da, "Error decoding audio.\n");
return -1;