[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51056] trunk/blender/source/blender/imbuf /intern: Fix #32763: Image flickering appears if Movie Clip Editor and compositor opened

Sergey Sharybin sergey.vfx at gmail.com
Thu Oct 4 22:31:08 CEST 2012


Revision: 51056
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51056
Author:   nazgul
Date:     2012-10-04 20:31:08 +0000 (Thu, 04 Oct 2012)
Log Message:
-----------
Fix #32763: Image flickering appears if Movie Clip Editor and compositor opened

The issue was caused by compositor was allocating float buffer for image and
then this buffer was filled with data converted from byte buffer.

If display happens at time between float was allocated and it was filled black
areas were appearing on the screen.

Made it so IMB_float_from_rect locks color management thread so display
transform wouldn't use uninitialized buffer anymore.

Modified Paths:
--------------
    trunk/blender/source/blender/imbuf/intern/colormanagement.c
    trunk/blender/source/blender/imbuf/intern/divers.c

Modified: trunk/blender/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/colormanagement.c	2012-10-04 20:12:16 UTC (rev 51055)
+++ trunk/blender/source/blender/imbuf/intern/colormanagement.c	2012-10-04 20:31:08 UTC (rev 51056)
@@ -88,6 +88,13 @@
 static int global_tot_display = 0;
 static int global_tot_view = 0;
 
+/* lock used by pre-cached processors getters, so processor wouldn't
+ * be created several times
+ * LOCK_COLORMANAGE can not be used since this mutex could be needed to
+ * be locked before pre-cached processor are creating
+ */
+static pthread_mutex_t processor_lock = BLI_MUTEX_INITIALIZER;
+
 typedef struct ColormanageProcessor {
 	ConstProcessorRcPtr *processor;
 	CurveMapping *curve_mapping;
@@ -732,7 +739,7 @@
 static ConstProcessorRcPtr *colorspace_to_scene_linear_processor(ColorSpace *colorspace)
 {
 	if (colorspace->to_scene_linear == NULL) {
-		BLI_lock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_lock(&processor_lock);
 
 		if (colorspace->to_scene_linear == NULL) {
 			ConstProcessorRcPtr *to_scene_linear;
@@ -740,7 +747,7 @@
 			colorspace->to_scene_linear = (struct ConstProcessorRcPtr *) to_scene_linear;
 		}
 
-		BLI_unlock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_unlock(&processor_lock);
 	}
 
 	return (ConstProcessorRcPtr *) colorspace->to_scene_linear;
@@ -749,7 +756,7 @@
 static ConstProcessorRcPtr *colorspace_from_scene_linear_processor(ColorSpace *colorspace)
 {
 	if (colorspace->from_scene_linear == NULL) {
-		BLI_lock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_lock(&processor_lock);
 
 		if (colorspace->from_scene_linear == NULL) {
 			ConstProcessorRcPtr *from_scene_linear;
@@ -757,7 +764,7 @@
 			colorspace->from_scene_linear = (struct ConstProcessorRcPtr *) from_scene_linear;
 		}
 
-		BLI_unlock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_unlock(&processor_lock);
 	}
 
 	return (ConstProcessorRcPtr *) colorspace->from_scene_linear;
@@ -766,7 +773,7 @@
 static ConstProcessorRcPtr *display_from_scene_linear_processor(ColorManagedDisplay *display)
 {
 	if (display->from_scene_linear == NULL) {
-		BLI_lock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_lock(&processor_lock);
 
 		if (display->from_scene_linear == NULL) {
 			const char *view_name = colormanage_view_get_default_name(display);
@@ -783,7 +790,7 @@
 			display->from_scene_linear = (struct ConstProcessorRcPtr *) processor;
 		}
 
-		BLI_unlock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_unlock(&processor_lock);
 	}
 
 	return (ConstProcessorRcPtr *) display->from_scene_linear;
@@ -792,7 +799,7 @@
 static ConstProcessorRcPtr *display_to_scene_linear_processor(ColorManagedDisplay *display)
 {
 	if (display->to_scene_linear == NULL) {
-		BLI_lock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_lock(&processor_lock);
 
 		if (display->to_scene_linear == NULL) {
 			const char *view_name = colormanage_view_get_default_name(display);
@@ -809,7 +816,7 @@
 			display->to_scene_linear = (struct ConstProcessorRcPtr *) processor;
 		}
 
-		BLI_unlock_thread(LOCK_COLORMANAGE);
+		BLI_mutex_unlock(&processor_lock);
 	}
 
 	return (ConstProcessorRcPtr *) display->to_scene_linear;
@@ -1263,7 +1270,7 @@
 	if (cm_processor == NULL) {
 		if (display_buffer_byte) {
 			IMB_buffer_byte_from_byte(display_buffer_byte, handle->byte_buffer, IB_PROFILE_SRGB, IB_PROFILE_SRGB,
-			                          FALSE, width, height, width, width);
+			                         FALSE, width, height, width, width);
 		}
 
 		if (display_buffer) {

Modified: trunk/blender/source/blender/imbuf/intern/divers.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/divers.c	2012-10-04 20:12:16 UTC (rev 51055)
+++ trunk/blender/source/blender/imbuf/intern/divers.c	2012-10-04 20:31:08 UTC (rev 51056)
@@ -43,6 +43,8 @@
 #include "IMB_colormanagement.h"
 #include "IMB_colormanagement_intern.h"
 
+#include "BLI_threads.h"
+
 #include "MEM_guardedalloc.h"
 
 /**************************** Interlace/Deinterlace **************************/
@@ -599,9 +601,18 @@
 	if (ibuf->rect == NULL)
 		return;
 
+	/* lock the color management thread
+	 * need this because allocated but not filled float buffer will confuse
+	 * display transform which lead to black areas across the frame
+	 */
+	BLI_lock_thread(LOCK_COLORMANAGE);
+
 	if (ibuf->rect_float == NULL) {
-		if (imb_addrectfloatImBuf(ibuf) == 0)
+		if (imb_addrectfloatImBuf(ibuf) == 0) {
+			BLI_unlock_thread(LOCK_COLORMANAGE);
+
 			return;
+		}
 	}
 
 	/* first, create float buffer in non-linear space */
@@ -611,6 +622,8 @@
 	/* then make float be in linear space */
 	IMB_colormanagement_colorspace_to_scene_linear(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
 	                                               ibuf->rect_colorspace, predivide);
+
+	BLI_unlock_thread(LOCK_COLORMANAGE);
 }
 
 /* no profile conversion */




More information about the Bf-blender-cvs mailing list