diff options
author | wm4 <wm4@nowhere> | 2014-03-16 12:50:15 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-16 13:19:29 +0100 |
commit | f2374f4e4b341d6204188743e6bc63fe3fcd878b (patch) | |
tree | 344c28c1bcf8b759294b2591a74ccbe8137eaa95 /audio | |
parent | 8e6bd496ca68c8a672ffd7d9827bfde12ca83b6b (diff) | |
download | mpv-f2374f4e4b341d6204188743e6bc63fe3fcd878b.tar.bz2 mpv-f2374f4e4b341d6204188743e6bc63fe3fcd878b.tar.xz |
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.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/decode/ad_lavc.c | 6 |
1 files changed, 4 insertions, 2 deletions
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. |