[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50843] trunk/blender/source/blender: Proper fix for #32626: TIFF renders are limited to 8 bit even when we choose 16.

Sergey Sharybin sergey.vfx at gmail.com
Mon Sep 24 13:56:07 CEST 2012


Revision: 50843
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50843
Author:   nazgul
Date:     2012-09-24 11:56:07 +0000 (Mon, 24 Sep 2012)
Log Message:
-----------
Proper fix for #32626: TIFF renders are limited to 8 bit even when we choose 16.

Color management would be applied on both of float and byte buffers on image
save in cases if file format doesn't require linear float buffer and if image
is saving as render result.

This solves both initial report issue and TODO marked in previous fix.

Also de-duplicated image buffer color managing code and gave some more
meaningful names for few functions. Also wrote documentation around this
function, so current assumptions about spaces should be clear enough.

Made regression tests by saving EXR/PNG images to all supported format and
rendering OpenGL/Normal animation, in all cases seems everything is fine,
but more tests for sure would be welcome.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_image.h
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/compositor/operations/COM_OutputFileOperation.cpp
    trunk/blender/source/blender/editors/render/render_opengl.c
    trunk/blender/source/blender/editors/space_image/image_buttons.c
    trunk/blender/source/blender/editors/space_image/image_ops.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
    trunk/blender/source/blender/imbuf/IMB_colormanagement.h
    trunk/blender/source/blender/imbuf/intern/colormanagement.c
    trunk/blender/source/blender/imbuf/intern/jp2.c
    trunk/blender/source/blender/imbuf/intern/tiff.c
    trunk/blender/source/blender/makesrna/intern/rna_image_api.c
    trunk/blender/source/blender/render/intern/source/pipeline.c

Modified: trunk/blender/source/blender/blenkernel/BKE_image.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_image.h	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/blenkernel/BKE_image.h	2012-09-24 11:56:07 UTC (rev 50843)
@@ -66,7 +66,7 @@
 int     BKE_imtype_supports_zbuf(const char imtype);
 int     BKE_imtype_supports_compress(const char imtype);
 int     BKE_imtype_supports_quality(const char imtype);
-int     BKE_imtype_supports_float(const char imtype);
+int     BKE_imtype_requires_linear_float(const char imtype);
 char    BKE_imtype_valid_channels(const char imtype);
 char    BKE_imtype_valid_depths(const char imtype);
 

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2012-09-24 11:56:07 UTC (rev 50843)
@@ -1031,13 +1031,12 @@
 	return 0;
 }
 
-int BKE_imtype_supports_float(const char imtype)
+int BKE_imtype_requires_linear_float(const char imtype)
 {
 	switch (imtype) {
 		case R_IMF_IMTYPE_CINEON:
 		case R_IMF_IMTYPE_DPX:
 		case R_IMF_IMTYPE_RADHDR:
-		case R_IMF_IMTYPE_TIFF:  /* uses the float buffer to write 16bits per channel */
 		case R_IMF_IMTYPE_OPENEXR:
 		case R_IMF_IMTYPE_MULTILAYER:
 			return TRUE;

Modified: trunk/blender/source/blender/compositor/operations/COM_OutputFileOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_OutputFileOperation.cpp	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/compositor/operations/COM_OutputFileOperation.cpp	2012-09-24 11:56:07 UTC (rev 50843)
@@ -138,8 +138,9 @@
 		ibuf->mall |= IB_rectfloat; 
 		ibuf->dither = this->m_rd->dither_intensity;
 		
-		IMB_display_buffer_to_imbuf_rect(ibuf, m_viewSettings, m_displaySettings);
-		
+		IMB_colormanagement_imbuf_for_write(ibuf, TRUE, FALSE, m_viewSettings, m_displaySettings,
+		                                    this->m_format);
+
 		BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format->imtype,
 		                  (this->m_rd->scemode & R_EXTENSION), true);
 		

Modified: trunk/blender/source/blender/editors/render/render_opengl.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_opengl.c	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/editors/render/render_opengl.c	2012-09-24 11:56:07 UTC (rev 50843)
@@ -547,11 +547,11 @@
 	if (ibuf) {
 		int needs_free = FALSE;
 
-		if (is_movie || !BKE_imtype_supports_float(scene->r.im_format.imtype)) {
-			ImBuf *colormanage_ibuf = IMB_dupImBuf(ibuf);
+		if (is_movie || !BKE_imtype_requires_linear_float(scene->r.im_format.imtype)) {
+			ImBuf *colormanage_ibuf;
 
-			IMB_display_buffer_to_imbuf_rect(colormanage_ibuf, &scene->view_settings, &scene->display_settings);
-			imb_freerectfloatImBuf(colormanage_ibuf);
+			colormanage_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, TRUE, TRUE, &scene->view_settings,
+			                                                       &scene->display_settings, &scene->r.im_format);
 
 			// IMB_freeImBuf(ibuf); /* owned by the image */
 			ibuf = colormanage_ibuf;

Modified: trunk/blender/source/blender/editors/space_image/image_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_buttons.c	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/editors/space_image/image_buttons.c	2012-09-24 11:56:07 UTC (rev 50843)
@@ -814,7 +814,7 @@
 
 	/* color management */
 	if (color_management &&
-	    (!BKE_imtype_supports_float(imf->imtype) ||
+	    (!BKE_imtype_requires_linear_float(imf->imtype) ||
 	     (show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG)))
 	{
 		prop = RNA_struct_find_property(imfptr, "display_settings");

Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2012-09-24 11:56:07 UTC (rev 50843)
@@ -1205,39 +1205,6 @@
 	RNA_string_set(op->ptr, "filepath", simopts->filepath);
 }
 
-static ImBuf *save_image_colormanaged_imbuf_acquire(ImBuf *ibuf, SaveImageOptions *simopts, int save_as_render, void **cache_handle)
-{
-	ImageFormatData *imf = &simopts->im_format;
-	ImBuf *colormanaged_ibuf;
-	int do_colormanagement;
-
-	*cache_handle = NULL;
-	do_colormanagement = save_as_render && !BKE_imtype_supports_float(imf->imtype);
-
-	if (do_colormanagement) {
-		unsigned char *display_buffer;
-
-		display_buffer = IMB_display_buffer_acquire(ibuf, &imf->view_settings, &imf->display_settings, cache_handle);
-
-		if (*cache_handle) {
-			colormanaged_ibuf = IMB_allocImBuf(ibuf->x, ibuf->y, ibuf->planes, 0);
-			colormanaged_ibuf->rect = (unsigned int *) display_buffer;
-		}
-		else {
-			/* no cache handle means color management didn't run transformation
-			 * or performed transformation to image's byte buffer which doesn't
-			 * require allocating new image buffer
-			 */
-			colormanaged_ibuf = ibuf;
-		}
-	}
-	else {
-		colormanaged_ibuf = ibuf;
-	}
-
-	return colormanaged_ibuf;
-}
-
 /* assumes name is FILE_MAX */
 /* ima->name and ibuf->name should end up the same */
 static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
@@ -1247,12 +1214,12 @@
 	ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
 
 	if (ibuf) {
-		void *cache_handle;
 		ImBuf *colormanaged_ibuf;
 		const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id);
 		const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
 		const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
 		const short save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") && RNA_boolean_get(op->ptr, "save_as_render"));
+		ImageFormatData *imf = &simopts->im_format;
 		short ok = FALSE;
 
 		/* old global to ensure a 2nd save goes to same dir */
@@ -1277,7 +1244,7 @@
 			}
 		}
 
-		colormanaged_ibuf = save_image_colormanaged_imbuf_acquire(ibuf, simopts, save_as_render, &cache_handle);
+		colormanaged_ibuf = IMB_colormanagement_imbuf_for_write(ibuf, save_as_render, TRUE, &imf->view_settings, &imf->display_settings, imf);
 
 		if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
 			Scene *scene = CTX_data_scene(C);
@@ -1345,12 +1312,8 @@
 
 		WM_cursor_wait(0);
 
-		if (cache_handle) {
-			colormanaged_ibuf->rect = NULL;
+		if (colormanaged_ibuf != ibuf)
 			IMB_freeImBuf(colormanaged_ibuf);
-
-			IMB_display_buffer_release(cache_handle);
-		}
 	}
 
 	ED_space_image_release_buffer(sima, lock);

Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_draw.c	2012-09-24 11:56:07 UTC (rev 50843)
@@ -885,7 +885,10 @@
 	ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
 	ImBuf *scope;
 
-	IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings);
+	if (display_ibuf->rect_float) {
+		IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
+		                                             &scene->display_settings);
+	}
 
 	scope = make_scope_cb(display_ibuf);
 
@@ -967,7 +970,10 @@
 				if (!scopes->zebra_ibuf) {
 					ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
 
-					IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings);
+					if (display_ibuf->rect_float) {
+						IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
+						                                             &scene->display_settings);
+					}
 					scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra);
 					IMB_freeImBuf(display_ibuf);
 				}

Modified: trunk/blender/source/blender/imbuf/IMB_colormanagement.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_colormanagement.h	2012-09-24 10:57:44 UTC (rev 50842)
+++ trunk/blender/source/blender/imbuf/IMB_colormanagement.h	2012-09-24 11:56:07 UTC (rev 50843)
@@ -45,6 +45,7 @@
 struct PartialBufferUpdateContext;
 struct wmWindow;
 struct Scene;
+struct ImageFormatData;
 
 struct ColorSpace;
 struct ColorManagedDisplay;
@@ -90,15 +91,17 @@
 void IMB_colormanagement_imbuf_make_display_space(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
                                                   const struct ColorManagedDisplaySettings *display_settings);
 
+struct ImBuf *IMB_colormanagement_imbuf_for_write(struct ImBuf *ibuf, int save_as_render, int allocate_result,
+                                                  const struct ColorManagedViewSettings *view_settings,
+                                                  const struct ColorManagedDisplaySettings *display_settings,
+                                                  struct ImageFormatData *image_format_data);
+
 /* ** Public display buffers interfaces ** */
 
 unsigned char *IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
                                           const struct ColorManagedDisplaySettings *display_settings, void **cache_handle);
 unsigned char *IMB_display_buffer_acquire_ctx(const struct bContext *C, struct ImBuf *ibuf, void **cache_handle);
 
-void IMB_display_buffer_to_imbuf_rect(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
-                                      const struct ColorManagedDisplaySettings *display_settings);
-
 void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list