Fix T43033: VideoTexture module repeated loading of images causes memory leak

Fix proposal for memory leak caused by png decoding in videoFFmpeg.cpp

T43033

Author: Ulysse MARTIN (youle)

Reviewers: dfelinto, ben2610, moguri, lordloki, panzergame

Reviewed By: lordloki, panzergame

Subscribers: panzergame, lordloki

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1396
This commit is contained in:
Porteries Tristan 2015-09-13 17:50:27 +02:00
parent 09e40a4956
commit e443dd4d97
Notes: blender-bot 2023-02-14 09:41:22 +01:00
Referenced by issue #43033, VideoTexture module repeated loading of images causes memory leak
1 changed files with 7 additions and 12 deletions

View File

@ -1023,19 +1023,14 @@ AVFrame *VideoFFmpeg::grabFrame(long position)
{
if (packet.stream_index == m_videoStream)
{
if (m_isImage)
{
// If we're an image, we're probably not going to be here often,
// so we don't want to deal with delayed frames from threading.
// There might be a better way to handle this, but I'll leave that
// for people more knowledgeable with ffmpeg than myself. We don't
// need threading for a single image anyways.
m_codecCtx->thread_count = 1;
}
AVFrame *input = m_frame;
short counter = 0;
avcodec_decode_video2(m_codecCtx,
m_frame, &frameFinished,
&packet);
/* While the data is not read properly (png, tiffs, etc formats may need several pass)*/
while ((input->data[0] == 0 && input->data[1] == 0 && input->data[2] == 0 && input->data[3] == 0) && counter < 10) {
avcodec_decode_video2(m_codecCtx, m_frame, &frameFinished, &packet);
counter++;
}
// remember dts to compute exact frame number
dts = packet.dts;