Replace remaining avcodec_close() calls

This API isn't deprecated (yet?), but it's still inferior and harder to
use than avcodec_free_context().

Leave the call only in 1 case in af_lavcac3enc.c, where we apparently
seriously close and reopen the encoder for whatever reason.
This commit is contained in:
wm4 2017-07-16 12:51:48 +02:00
parent 8e20ef4292
commit ddd068491c
6 changed files with 7 additions and 27 deletions

View File

@ -137,11 +137,8 @@ static void determine_codec_params(struct dec_audio *da, AVPacket *pkt,
if (!ctx)
goto done;
if (avcodec_open2(ctx, codec, NULL) < 0) {
av_free(ctx); // don't attempt to avcodec_close() an unopened ctx
ctx = NULL;
if (avcodec_open2(ctx, codec, NULL) < 0)
goto done;
}
if (avcodec_send_packet(ctx, pkt) < 0)
goto done;

View File

@ -192,10 +192,7 @@ static void uninit(struct af_instance* af)
af_ac3enc_t *s = af->priv;
if (s) {
if(s->lavc_actx) {
avcodec_close(s->lavc_actx);
av_free(s->lavc_actx);
}
avcodec_free_context(&s->lavc_actx);
talloc_free(s->pending);
}
}

View File

@ -384,10 +384,7 @@ void encode_lavc_finish(struct encode_lavc_context *ctx)
stream_write_buffer(ctx->twopass_bytebuffer_v,
stats, strlen(stats));
}
avcodec_close(ctx->vcc);
talloc_free(ctx->vcc->stats_in);
av_free(ctx->vcc);
ctx->vcc = NULL;
avcodec_free_context(&ctx->vcc);
}
if (ctx->acc) {
@ -397,10 +394,7 @@ void encode_lavc_finish(struct encode_lavc_context *ctx)
stream_write_buffer(ctx->twopass_bytebuffer_a,
stats, strlen(stats));
}
avcodec_close(ctx->acc);
talloc_free(ctx->acc->stats_in);
av_free(ctx->acc);
ctx->acc = NULL;
avcodec_free_context(&ctx->acc);
}
for (i = 0; i < ctx->avc->nb_streams; i++) {

View File

@ -2239,11 +2239,7 @@ static void mkv_seek_reset(demuxer_t *demuxer)
if (track->av_parser)
av_parser_close(track->av_parser);
track->av_parser = NULL;
if (track->av_parser_codec) {
avcodec_close(track->av_parser_codec);
av_free(track->av_parser_codec);
}
track->av_parser_codec = NULL;
avcodec_free_context(&track->av_parser_codec);
}
free_block(&mkv_d->tmp_block);

View File

@ -500,9 +500,7 @@ static void uninit(struct sd *sd)
for (int n = 0; n < MAX_QUEUE; n++)
clear_sub(&priv->subs[n]);
avcodec_close(priv->avctx);
av_free(priv->avctx->extradata);
av_free(priv->avctx);
avcodec_free_context(&priv->avctx);
talloc_free(priv);
}

View File

@ -160,9 +160,7 @@ static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp
success = !!got_output;
error_exit:
if (avctx)
avcodec_close(avctx);
av_free(avctx);
avcodec_free_context(&avctx);
av_frame_free(&pic);
av_packet_unref(&pkt);
return success;