From f2374f4e4b341d6204188743e6bc63fe3fcd878b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 16 Mar 2014 12:50:15 +0100 Subject: ad_lavc: use new AVFrame API Set refcounted_frames, because in some versions of libavcodec mixing the new AVFrame API and non-refcounted decoding could cause memory corruption. Likewise, it's probably still required to unref a frame before calling the decoder. --- audio/decode/ad_lavc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'audio') diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 242b23b994..802683bf7b 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -205,7 +205,8 @@ static int init(struct dec_audio *da, const char *decoder) lavc_context = avcodec_alloc_context3(lavc_codec); ctx->avctx = lavc_context; - ctx->avframe = avcodec_alloc_frame(); + ctx->avframe = av_frame_alloc(); + lavc_context->refcounted_frames = 1; lavc_context->codec_type = AVMEDIA_TYPE_AUDIO; lavc_context->codec_id = lavc_codec->id; @@ -289,7 +290,7 @@ static void uninit(struct dec_audio *da) av_freep(&lavc_context->extradata); av_freep(&lavc_context); } - avcodec_free_frame(&ctx->avframe); + av_frame_free(&ctx->avframe); } static int control(struct dec_audio *da, int cmd, void *arg) @@ -331,6 +332,7 @@ static int decode_new_packet(struct dec_audio *da) } int got_frame = 0; + av_frame_unref(priv->avframe); int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt); if (mpkt) { // At least "shorten" decodes sub-frames, instead of the whole packet. -- cgit v1.2.3