[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60965] trunk/blender/source/blender: Fix #37221: Multilayer EXR inputs generate pink frame/ last displayed frame when using an image sequence offset

Sergey Sharybin sergey.vfx at gmail.com
Mon Oct 28 13:16:18 CET 2013


Revision: 60965
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60965
Author:   nazgul
Date:     2013-10-28 12:16:17 +0000 (Mon, 28 Oct 2013)
Log Message:
-----------
Fix #37221: Multilayer EXR inputs generate pink frame/last displayed frame when using an image sequence offset

generally speaking, if multilayer image fails to load for current
frame doesn't mean anything bad. It might be used to make it so
image sequence is being alpha-overed somewhere in the middle of
scene time.

Made it so if the whole file fails to load, image node will
deliver black transparent color, the same what happens for
regular (non-multilayer images).

Also needed to tweak code in load_multilayer_sequwnce to make
sure no cached frames are pointing to a freed memory.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/compositor/nodes/COM_ImageNode.cpp

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2013-10-28 10:42:08 UTC (rev 60964)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2013-10-28 12:16:17 UTC (rev 60965)
@@ -191,18 +191,22 @@
 
 /* ***************** ALLOC & FREE, DATA MANAGING *************** */
 
-static void image_free_buffers(Image *ima)
+static void image_free_cahced_frames(Image *image)
 {
 	ImBuf *ibuf;
-
-	while ((ibuf = BLI_pophead(&ima->ibufs))) {
+	while ((ibuf = BLI_pophead(&image->ibufs))) {
 		if (ibuf->userdata) {
 			MEM_freeN(ibuf->userdata);
 			ibuf->userdata = NULL;
 		}
 		IMB_freeImBuf(ibuf);
 	}
+}
 
+static void image_free_buffers(Image *ima)
+{
+	image_free_cahced_frames(ima);
+
 	if (ima->anim) IMB_free_anim(ima->anim);
 	ima->anim = NULL;
 
@@ -2505,26 +2509,22 @@
 
 	/* check for new RenderResult */
 	if (ima->rr == NULL || frame != ima->rr->framenr) {
-		/* copy to survive not found multilayer image */
-		RenderResult *oldrr = ima->rr;
+		if (ima->rr) {
+			/* Cached image buffers shares pointers with render result,
+			 * need to ensure there's no image buffers are hanging around
+			 * with dead links after freeing the render result.
+			 */
+			image_free_cahced_frames(ima);
+			RE_FreeRenderResult(ima->rr);
+			ima->rr = NULL;
+		}
 
-		ima->rr = NULL;
 		ibuf = image_load_sequence_file(ima, iuser, frame);
 
 		if (ibuf) { /* actually an error */
 			ima->type = IMA_TYPE_IMAGE;
 			printf("error, multi is normal image\n");
 		}
-		// printf("loaded new result %p\n", ima->rr);
-		/* free result if new one found */
-		if (ima->rr) {
-			// if (oldrr) printf("freed previous result %p\n", oldrr);
-			if (oldrr) RE_FreeRenderResult(oldrr);
-		}
-		else {
-			ima->rr = oldrr;
-		}
-
 	}
 	if (ima->rr) {
 		RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser);

Modified: trunk/blender/source/blender/compositor/nodes/COM_ImageNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_ImageNode.cpp	2013-10-28 10:42:08 UTC (rev 60964)
+++ trunk/blender/source/blender/compositor/nodes/COM_ImageNode.cpp	2013-10-28 12:16:17 UTC (rev 60965)
@@ -142,7 +142,17 @@
 
 		/* without this, multilayer that fail to load will crash blender [#32490] */
 		if (is_multilayer_ok == false) {
-			convertToOperations_invalid(graph, context);
+			int index;
+			vector<OutputSocket *> &outputsockets = this->getOutputSockets();
+			for (index = 0; index < outputsockets.size(); index++) {
+				const float warning_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+				SetColorOperation *operation = new SetColorOperation();
+				operation->setChannels(warning_color);
+
+				/* link the operation */
+				this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket());
+				graph->addOperation(operation);
+			}
 		}
 	}
 	else {




More information about the Bf-blender-cvs mailing list