Commit: e443dd4d9768394a61197dc187eb21c65aad7941
Author: Porteries Tristan
Date:   Sun Sep 13 17:50:27 2015 +0200
Branches: master
https://developer.blender.org/rBe443dd4d9768394a61197dc187eb21c65aad7941

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

===================================================================

M       source/gameengine/VideoTexture/VideoFFmpeg.cpp

===================================================================

diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp 
b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
index db76ba5..ffe06cf 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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to