ffmpeg: leak when re-allocating ffmpeg context

The _Setup method can be called several times if the parameters are
changed (for example when calling SetQuality). But it always allocated a
new context without freeinthe previous one, resulting in a leak.

Part of #9458, it fixes the largest leak there (10K bytes for each loop
of the provided test) but there are other leaks left as well, some of
which apparently need an update to a newer ffmpeg version removing some
deprecated fields.

Change-Id: Iad119dbda9cff1ce023b602a1978b100a1263f7d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5953
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
PulkoMandy
2022-12-22 15:56:25 +00:00
committed by waddlesplash
parent 18edaef38c
commit beff8fa729
@@ -271,6 +271,11 @@ AVCodecEncoder::_Setup()
int rawBitRate;
if (fCodecContext != NULL) {
avcodec_close(fCodecContext);
avcodec_free_context(&fCodecContext);
}
fCodecContext = avcodec_alloc_context3(fCodec);
if (fCodecContext == NULL)
return B_NO_INIT;