From e443dd4d9768394a61197dc187eb21c65aad7941 Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Sun, 13 Sep 2015 17:50:27 +0200 Subject: 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 --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'source') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index db76ba5822a..ffe06cff100 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -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; -- cgit v1.2.3