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:
@@ -271,6 +271,11 @@ AVCodecEncoder::_Setup()
|
|||||||
|
|
||||||
int rawBitRate;
|
int rawBitRate;
|
||||||
|
|
||||||
|
if (fCodecContext != NULL) {
|
||||||
|
avcodec_close(fCodecContext);
|
||||||
|
avcodec_free_context(&fCodecContext);
|
||||||
|
}
|
||||||
|
|
||||||
fCodecContext = avcodec_alloc_context3(fCodec);
|
fCodecContext = avcodec_alloc_context3(fCodec);
|
||||||
if (fCodecContext == NULL)
|
if (fCodecContext == NULL)
|
||||||
return B_NO_INIT;
|
return B_NO_INIT;
|
||||||
|
|||||||
Reference in New Issue
Block a user