Skip to content
Snippets Groups Projects
Commit 6aaf79f7 authored by Philippe Gorley's avatar Philippe Gorley Committed by Philippe Gorley
Browse files

media: fix memory leaks


avcodec_close leaks memory, while avcodec_free_context doesn't.

FFmpeg documentation specifies not to use avcodec_close, as opening and
closing a context multiple times is no longer supported.

Change-Id: I230891f2510c355b9d44d918dcf387399d79a8aa
Reviewed-by: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent f1088fa8
No related branches found
No related tags found
No related merge requests found
......@@ -64,7 +64,7 @@ MediaDecoder::~MediaDecoder()
av_buffer_unref(&decoderCtx_->hw_device_ctx);
#endif
if (decoderCtx_)
avcodec_close(decoderCtx_);
avcodec_free_context(&decoderCtx_);
if (inputCtx_)
avformat_close_input(&inputCtx_);
......
......@@ -54,8 +54,7 @@ MediaEncoder::~MediaEncoder()
av_write_trailer(outputCtx_);
for (auto encoderCtx : encoders_)
if (encoderCtx)
avcodec_close(encoderCtx);
avcodec_free_context(&encoderCtx);
avformat_free_context(outputCtx_);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment