Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-10-05 00:31:08 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-10-05 00:31:08 +0400
commit41202e25e781543eaabfa5be90e2de0f1b7f94a8 (patch)
tree67838bef4c850d363bc98d4807300f25914d7cde /source/blender/imbuf
parent282f98a84dc7d454a36918b9b8b279aa127c4d3b (diff)
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.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/intern/colormanagement.c25
-rw-r--r--source/blender/imbuf/intern/divers.c15
2 files changed, 30 insertions, 10 deletions
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index bb1449060dd..50000b9eeea 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -88,6 +88,13 @@ static int global_tot_colorspace = 0;
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 *create_colorspace_transform_processor(const char *fr
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 @@ static ConstProcessorRcPtr *colorspace_to_scene_linear_processor(ColorSpace *col
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_to_scene_linear_processor(ColorSpace *col
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 @@ static ConstProcessorRcPtr *colorspace_from_scene_linear_processor(ColorSpace *c
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 *colorspace_from_scene_linear_processor(ColorSpace *c
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 @@ static ConstProcessorRcPtr *display_from_scene_linear_processor(ColorManagedDisp
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_from_scene_linear_processor(ColorManagedDisp
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 @@ static ConstProcessorRcPtr *display_to_scene_linear_processor(ColorManagedDispla
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 @@ static void *do_display_buffer_apply_thread(void *handle_v)
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) {
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 9ce5d0e30da..aa236af3507 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -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 @@ void IMB_float_from_rect(ImBuf *ibuf)
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 @@ void IMB_float_from_rect(ImBuf *ibuf)
/* 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 */