[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50595] branches/soc-2011-tomato/source/ blender: Color Management: get rid of image buffer's profile flag

Sergey Sharybin sergey.vfx at gmail.com
Fri Sep 14 16:37:19 CEST 2012


Revision: 50595
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50595
Author:   nazgul
Date:     2012-09-14 14:37:19 +0000 (Fri, 14 Sep 2012)
Log Message:
-----------
Color Management: get rid of image buffer's profile flag

Currently float buffers are always linear, space of byte buffer is defined by
rect_colorspace property.

Replaced logic of IMB_rect_from_float and IMB_float_from_rect to use this
assumptions (before it was special function used in some areas only, now it's
default behavior).

Almost all functions from ImBuf module which are actually used are got rid from
profile flag. Only remained issue is IMB_float_profile_ensure which only used by
CIneon/DPX exporter which is broken for a while already. Need to be fixed
separately.

This also fixed clone brush when cloning byte image on top of float, before
this result would be gamma-corrected twice.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/ocean.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/sequencer.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/compositor/operations/COM_ImageOperation.cpp
    branches/soc-2011-tomato/source/blender/editors/render/render_opengl.c
    branches/soc-2011-tomato/source/blender/editors/render/render_preview.c
    branches/soc-2011-tomato/source/blender/editors/sculpt_paint/paint_image.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_editor.c
    branches/soc-2011-tomato/source/blender/editors/space_image/image_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_node/node_view.c
    branches/soc-2011-tomato/source/blender/gpu/intern/gpu_draw.c
    branches/soc-2011-tomato/source/blender/imbuf/IMB_colormanagement.h
    branches/soc-2011-tomato/source/blender/imbuf/IMB_imbuf.h
    branches/soc-2011-tomato/source/blender/imbuf/IMB_imbuf_types.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/IMB_colormanagement_intern.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/allocimbuf.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/anim_movie.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/bmp.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/dds/dds_api.cpp
    branches/soc-2011-tomato/source/blender/imbuf/intern/divers.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/iris.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/jp2.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/jpeg.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/openexr/openexr_api.cpp
    branches/soc-2011-tomato/source/blender/imbuf/intern/png.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/radiance_hdr.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/readimage.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/targa.c
    branches/soc-2011-tomato/source/blender/imbuf/intern/tiff.c
    branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_image.c
    branches/soc-2011-tomato/source/blender/nodes/composite/nodes/node_composite_outputFile.c
    branches/soc-2011-tomato/source/blender/quicktime/apple/qtkit_import.m
    branches/soc-2011-tomato/source/blender/quicktime/apple/quicktime_import.c
    branches/soc-2011-tomato/source/blender/render/intern/source/envmap.c
    branches/soc-2011-tomato/source/blender/render/intern/source/render_result.c
    branches/soc-2011-tomato/source/blender/render/intern/source/rendercore.c

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c	2012-09-14 14:37:00 UTC (rev 50594)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/image.c	2012-09-14 14:37:19 UTC (rev 50595)
@@ -612,12 +612,10 @@
 	if (floatbuf) {
 		ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat);
 		rect_float = ibuf->rect_float;
-		ibuf->profile = IB_PROFILE_LINEAR_RGB;
 	}
 	else {
 		ibuf = IMB_allocImBuf(width, height, depth, IB_rect);
 		rect = (unsigned char *)ibuf->rect;
-		ibuf->profile = IB_PROFILE_SRGB;
 	}
 
 	BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));
@@ -2330,7 +2328,6 @@
 			ibuf->flags |= IB_rectfloat;
 			ibuf->mall = IB_rectfloat;
 			ibuf->channels = rpass->channels;
-			ibuf->profile = IB_PROFILE_LINEAR_RGB;
 
 			image_initialize_after_load(ima, ibuf);
 			image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame);
@@ -2481,7 +2478,6 @@
 			ibuf->rect_float = rpass->rect;
 			ibuf->flags |= IB_rectfloat;
 			ibuf->channels = rpass->channels;
-			ibuf->profile = IB_PROFILE_LINEAR_RGB;
 
 			image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0);
 		}
@@ -2630,7 +2626,6 @@
 
 	BLI_unlock_thread(LOCK_COLORMANAGE);
 
-	ibuf->profile = IB_PROFILE_LINEAR_RGB;
 	ibuf->dither = dither;
 
 	if (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) {

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/ocean.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/ocean.c	2012-09-14 14:37:00 UTC (rev 50594)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/ocean.c	2012-09-14 14:37:19 UTC (rev 50595)
@@ -1173,8 +1173,6 @@
 		ibuf_disp = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
 		ibuf_normal = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
 
-		ibuf_disp->profile = ibuf_foam->profile = ibuf_normal->profile = IB_PROFILE_LINEAR_RGB;
-
 		BKE_simulate_ocean(o, och->time[i], och->wave_scale, och->chop_amount);
 
 		/* add new foam */

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/sequencer.c	2012-09-14 14:37:00 UTC (rev 50594)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/sequencer.c	2012-09-14 14:37:19 UTC (rev 50595)
@@ -313,7 +313,6 @@
 
 void BKE_sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf)
 {
-	IMB_colormanagement_imbuf_assign_spaces(ibuf, NULL);
 	IMB_colormanagement_imbuf_assign_float_space(ibuf, &scene->sequencer_colorspace_settings);
 }
 
@@ -335,7 +334,7 @@
 			 * OCIO_TODO: would be nice to support direct single transform from byte to sequencer's
 			 */
 
-			IMB_colormanagement_imbuf_float_from_rect(ibuf);
+			IMB_float_from_rect(ibuf);
 		}
 		else {
 			/* if there's only byte buffer in image it's already in compositor's working space,
@@ -352,13 +351,7 @@
 
 		IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
 		                                       from_colorspace, to_colorspace, predivide);
-
-		ibuf->profile = IB_PROFILE_SRGB;
 	}
-	else {
-		/* if no color management enables fallback to legacy conversion */
-		IMB_convert_profile(ibuf, IB_PROFILE_NONE);
-	}
 }
 
 void BKE_sequencer_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf)
@@ -374,13 +367,7 @@
 
 		IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels,
 		                                       from_colorspace, to_colorspace, predivide);
-
-		ibuf->profile = IB_PROFILE_LINEAR_RGB;
 	}
-	else {
-		/* if no color management enables fallback to legacy conversion */
-		IMB_convert_profile(ibuf, IB_PROFILE_LINEAR_RGB);
-	}
 }
 
 void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4])
@@ -2441,7 +2428,6 @@
 			}
 
 			/* float buffers in the sequencer are not linear */
-			ibuf->profile = IB_PROFILE_LINEAR_RGB;
 			BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE);
 		}
 		else if (rres.rect32) {
@@ -2549,8 +2535,7 @@
 					imb_freerectImBuf(ibuf);
 
 				/* all sequencer color is done in SRGB space, linear gives odd crossfades */
-				if (ibuf->profile == IB_PROFILE_LINEAR_RGB)
-					BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE);
+				BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE);
 
 				copy_to_ibuf_still(context, seq, nr, ibuf);
 

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-09-14 14:37:00 UTC (rev 50594)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c	2012-09-14 14:37:19 UTC (rev 50595)
@@ -1627,7 +1627,6 @@
 	float *mask = NULL;
 
 	pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat);
-	pattern_ibuf->profile = IB_PROFILE_LINEAR_RGB;
 
 	if (!search_ibuf->rect_float) {
 		IMB_float_from_rect(search_ibuf);
@@ -1722,7 +1721,6 @@
 	h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
 
 	searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
-	searchibuf->profile = ibuf->profile;
 
 	IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h);
 
@@ -3317,7 +3315,6 @@
 	}
 	else {
 		cacheibuf = IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags);
-		cacheibuf->profile = srcibuf->profile;
 	}
 
 	return cacheibuf;

Modified: branches/soc-2011-tomato/source/blender/compositor/operations/COM_ImageOperation.cpp
===================================================================
--- branches/soc-2011-tomato/source/blender/compositor/operations/COM_ImageOperation.cpp	2012-09-14 14:37:00 UTC (rev 50594)
+++ branches/soc-2011-tomato/source/blender/compositor/operations/COM_ImageOperation.cpp	2012-09-14 14:37:19 UTC (rev 50595)
@@ -71,7 +71,7 @@
 	}
 	
 	if (ibuf->rect_float == NULL) {
-		IMB_colormanagement_imbuf_float_from_rect(ibuf);
+		IMB_float_from_rect(ibuf);
 	}
 	return ibuf;
 }

Modified: branches/soc-2011-tomato/source/blender/editors/render/render_opengl.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/render/render_opengl.c	2012-09-14 14:37:00 UTC (rev 50594)
+++ branches/soc-2011-tomato/source/blender/editors/render/render_opengl.c	2012-09-14 14:37:19 UTC (rev 50595)
@@ -144,22 +144,30 @@
 		ibuf = BKE_sequencer_give_ibuf(context, CFRA, chanshown);
 
 		if (ibuf) {
+			ImBuf *linear_ibuf;
+
 			BLI_assert((oglrender->sizex == ibuf->x) && (oglrender->sizey == ibuf->y));
 
-			if (ibuf->rect_float == NULL) {
-				/* internally sequencer working in sRGB space and stores both bytes and float
-				 * buffers in sRGB space, but if byte->float onversion doesn't happen in sequencer
-				 * (e.g. when adding image sequence/movie into sequencer) there'll be only
-				 * byte buffer and profile will still indicate sRGB->linear space conversion is needed
-				 * here we're ensure there'll be no conversion happen and float buffer would store
-				 * linear frame (sergey) */
-				ibuf->profile = IB_PROFILE_NONE;
-				IMB_float_from_rect(ibuf);
+			linear_ibuf = IMB_dupImBuf(ibuf);
+			IMB_freeImBuf(ibuf);
+
+			if (linear_ibuf->rect_float == NULL) {
+				/* internally sequencer working in display space and stores both bytes and float buffers in that space.
+				 * It is possible that byte->float onversion didn't happen in sequencer (e.g. when adding image sequence/movie
+				 * into sequencer) there'll be only byte buffer. Create float buffer from existing byte buffer, making it linear
+				 */
+
+				IMB_float_from_rect(linear_ibuf);
 			}
+			else {
+				/* ensure float buffer is in linear space, not in display space */
+				BKE_sequencer_imbuf_from_sequencer_space(scene, linear_ibuf);
+			}
 
-			memcpy(rr->rectf, ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
 
-			IMB_freeImBuf(ibuf);
+			memcpy(rr->rectf, linear_ibuf->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
+
+			IMB_freeImBuf(linear_ibuf);
 		}
 	}
 	else if (view_context) {
@@ -234,11 +242,6 @@
 		}
 	}
 	
-	/* rr->rectf is now filled with image data */
-
-	if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
-		BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
-
 	/* note on color management:
 	 *
 	 * OpenGL renders into sRGB colors, but render buffers are expected to be
@@ -247,10 +250,19 @@
 	 * correct linear float buffer.
 	 */
 
-	IMB_buffer_float_from_float(rr->rectf, rr->rectf,
-	                            4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, FALSE,
-	                            oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
+	if (!oglrender->is_sequencer) {
+		/* sequencer has got tricker ocnversion happened above */
 
+		IMB_buffer_float_from_float(rr->rectf, rr->rectf,
+		                            4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, FALSE,
+		                            oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
+	}
+
+	/* rr->rectf is now filled with image data */
+
+	if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
+		BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
+
 	RE_ReleaseResult(oglrender->re);
 
 	/* update byte from float buffer */

Modified: branches/soc-2011-tomato/source/blender/editors/render/render_preview.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/render/render_preview.c	2012-09-14 14:37:00 UTC (rev 50594)
+++ branches/soc-2011-tomato/source/blender/editors/render/render_preview.c	2012-09-14 14:37:19 UTC (rev 50595)
@@ -535,12 +535,12 @@
 
 				}
 				else {
-					/* OCIO_TODO: currently seems an exception for textures,
+					/* OCIO_TODO: currently seems an exception for textures (came fro mlegacish time),
 					 *            but is it indeed expected behavior, or textures should be
 					 *            color managed as well?
 					 */
 					IMB_buffer_byte_from_float(rect_byte, rres.rectf,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list