You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
fix a number of memory leaks
- some were with libav functions - same were due to non-virtual destructors
This commit is contained in:
@@ -576,6 +576,12 @@ void FFmpegReader::Close() {
|
||||
|
||||
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::Close", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
|
||||
|
||||
if (packet) {
|
||||
// Remove previous packet before getting next one
|
||||
RemoveAVPacket(packet);
|
||||
packet = NULL;
|
||||
}
|
||||
|
||||
// Close the codec
|
||||
if (info.has_video) {
|
||||
avcodec_flush_buffers(pCodecCtx);
|
||||
@@ -624,6 +630,8 @@ void FFmpegReader::Close() {
|
||||
seek_video_frame_found = 0;
|
||||
current_video_frame = 0;
|
||||
has_missing_frames = false;
|
||||
|
||||
last_video_frame.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,7 +934,9 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame) {
|
||||
// down processing considerably, but might be more stable on some systems.
|
||||
#pragma omp taskwait
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RemoveAVFrame(pFrame);
|
||||
}
|
||||
|
||||
}
|
||||
// Audio packet
|
||||
@@ -1063,7 +1073,7 @@ bool FFmpegReader::GetAVFrame() {
|
||||
{
|
||||
next_frame2 = next_frame;
|
||||
}
|
||||
pFrame = new AVFrame();
|
||||
pFrame = AV_ALLOCATE_FRAME();
|
||||
while (ret >= 0) {
|
||||
ret = avcodec_receive_frame(pCodecCtx, next_frame2);
|
||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
||||
@@ -1206,6 +1216,7 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame) {
|
||||
int width = info.width;
|
||||
int64_t video_length = info.video_length;
|
||||
AVFrame *my_frame = pFrame;
|
||||
pFrame = NULL;
|
||||
|
||||
// Add video frame to list of processing video frames
|
||||
const GenericScopedLock <CriticalSection> lock(processingCriticalSection);
|
||||
|
||||
Reference in New Issue
Block a user