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:
authorCampbell Barton <ideasman42@gmail.com>2010-09-18 11:19:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-18 11:19:32 +0400
commitd81315e9d221b3fdd0dafedff58398226590f468 (patch)
tree074d5f8a877ae0171331bf9d9125a61070da00ec /source/blender/nodes/intern/CMP_nodes
parentc853c23267853e3585bc4d1ef8fa57a7856bec25 (diff)
bugfix [#23706] SEGFAULT: File Load of EXR
image node was modifying the original buffer color management, now only modify a copy.
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes')
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_image.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c
index 0bbf9c9bf85..545399fb2d0 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c
@@ -62,38 +62,55 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i
ImBuf *ibuf;
CompBuf *stackbuf;
int type;
-
+
+ float *rect;
+ int alloc= FALSE;
+
ibuf= BKE_image_get_ibuf(ima, iuser);
- if(ibuf==NULL)
+ if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
return NULL;
-
- if (!(rd->color_mgt_flag & R_COLOR_MANAGEMENT)) {
- int profile = IB_PROFILE_NONE;
-
- /* temporarily set profile to none to not disturb actual */
- SWAP(int, ibuf->profile, profile);
-
- if (ibuf->rect_float != NULL) {
- imb_freerectfloatImBuf(ibuf);
- }
- IMB_float_from_rect(ibuf);
-
- SWAP(int, ibuf->profile, profile);
}
-
+
if (ibuf->rect_float == NULL) {
IMB_float_from_rect(ibuf);
}
+ /* now we need a float buffer from the image
+ * with matching color management */
+ if(rd->color_mgt_flag & R_COLOR_MANAGEMENT) {
+ if(ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+ rect= ibuf->rect_float;
+ }
+ else {
+ rect= MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image");
+ srgb_to_linearrgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y);
+ alloc= TRUE;
+ }
+ }
+ else {
+ if(ibuf->profile != IB_PROFILE_LINEAR_RGB) {
+ rect= ibuf->rect_float;
+ }
+ else {
+ rect= MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image");
+ linearrgb_to_srgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y);
+ alloc= TRUE;
+ }
+ }
+ /* done coercing into the correct color management */
+
+
type= ibuf->channels;
if(rd->scemode & R_COMP_CROP) {
- stackbuf= get_cropped_compbuf(&rd->disprect, ibuf->rect_float, ibuf->x, ibuf->y, type);
+ stackbuf= get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type);
+ if(alloc)
+ MEM_freeN(rect);
}
else {
/* we put imbuf copy on stack, cbuf knows rect is from other ibuf when freed! */
- stackbuf= alloc_compbuf(ibuf->x, ibuf->y, type, 0);
- stackbuf->rect= ibuf->rect_float;
+ stackbuf= alloc_compbuf(ibuf->x, ibuf->y, type, alloc);
+ stackbuf->rect= rect;
}
/*code to respect the premul flag of images; I'm