diff options
author | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-09-13 18:50:27 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-09-13 21:59:24 +0300 |
commit | e443dd4d9768394a61197dc187eb21c65aad7941 (patch) | |
tree | 80696755d808c592e57d4a97a9d9a63d0e718e83 /source/gameengine/VideoTexture | |
parent | 09e40a4956494655a2d544ab654372455882dbc3 (diff) |
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
Diffstat (limited to 'source/gameengine/VideoTexture')
-rw-r--r-- | source/gameengine/VideoTexture/VideoFFmpeg.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
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; |