Commit 6aaf79f7 authored by Philippe Gorley's avatar Philippe Gorley Committed by Philippe Gorley

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: Sébastien Blin's avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent f1088fa8
......@@ -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_);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment