1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-11 08:37:59 +00:00

ad_lavc, vd_lavc, sd_lavc: consistently use avcodec_free_context()

Instead of various ad-hoc ways to achieve the same thing. (The API was
added only later.)
This commit is contained in:
wm4 2017-07-06 16:12:50 +02:00
parent aa2bdec26c
commit d5702d3b95
3 changed files with 3 additions and 15 deletions

View File

@ -147,14 +147,8 @@ static void uninit(struct dec_audio *da)
struct priv *ctx = da->priv; struct priv *ctx = da->priv;
if (!ctx) if (!ctx)
return; return;
AVCodecContext *lavc_context = ctx->avctx;
if (lavc_context) { avcodec_free_context(&ctx->avctx);
if (avcodec_close(lavc_context) < 0)
MP_ERR(da, "Could not close codec.\n");
av_freep(&lavc_context->extradata);
av_freep(&lavc_context);
}
av_frame_free(&ctx->avframe); av_frame_free(&ctx->avframe);
} }

View File

@ -113,9 +113,7 @@ static int init(struct sd *sd)
error: error:
MP_FATAL(sd, "Could not open libavcodec subtitle decoder\n"); MP_FATAL(sd, "Could not open libavcodec subtitle decoder\n");
if (ctx) avcodec_free_context(&ctx);
av_free(ctx->extradata);
av_free(ctx);
talloc_free(priv); talloc_free(priv);
return -1; return -1;
} }

View File

@ -664,11 +664,7 @@ static void uninit_avctx(struct dec_video *vd)
av_frame_free(&ctx->pic); av_frame_free(&ctx->pic);
av_buffer_unref(&ctx->cached_hw_frames_ctx); av_buffer_unref(&ctx->cached_hw_frames_ctx);
if (ctx->avctx) { avcodec_free_context(&ctx->avctx);
if (avcodec_close(ctx->avctx) < 0)
MP_ERR(vd, "Could not close codec.\n");
av_freep(&ctx->avctx->extradata);
}
if (ctx->hwdec_dev && ctx->hwdec && ctx->hwdec->generic_hwaccel && if (ctx->hwdec_dev && ctx->hwdec && ctx->hwdec->generic_hwaccel &&
ctx->hwdec_dev->destroy) ctx->hwdec_dev->destroy)