summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/decode/ad_lavc.c8
-rw-r--r--sub/sd_lavc.c4
-rw-r--r--video/decode/vd_lavc.c6
3 files changed, 3 insertions, 15 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index 6f28d062ee..d701630fc6 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -147,14 +147,8 @@ static void uninit(struct dec_audio *da)
struct priv *ctx = da->priv;
if (!ctx)
return;
- AVCodecContext *lavc_context = ctx->avctx;
- if (lavc_context) {
- if (avcodec_close(lavc_context) < 0)
- MP_ERR(da, "Could not close codec.\n");
- av_freep(&lavc_context->extradata);
- av_freep(&lavc_context);
- }
+ avcodec_free_context(&ctx->avctx);
av_frame_free(&ctx->avframe);
}
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 59e10ab5a9..169a2883df 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -113,9 +113,7 @@ static int init(struct sd *sd)
error:
MP_FATAL(sd, "Could not open libavcodec subtitle decoder\n");
- if (ctx)
- av_free(ctx->extradata);
- av_free(ctx);
+ avcodec_free_context(&ctx);
talloc_free(priv);
return -1;
}
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index e02da5ebda..e5de69499d 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -664,11 +664,7 @@ static void uninit_avctx(struct dec_video *vd)
av_frame_free(&ctx->pic);
av_buffer_unref(&ctx->cached_hw_frames_ctx);
- if (ctx->avctx) {
- if (avcodec_close(ctx->avctx) < 0)
- MP_ERR(vd, "Could not close codec.\n");
- av_freep(&ctx->avctx->extradata);
- }
+ avcodec_free_context(&ctx->avctx);
if (ctx->hwdec_dev && ctx->hwdec && ctx->hwdec->generic_hwaccel &&
ctx->hwdec_dev->destroy)