[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50520] branches/soc-2011-tomato: Color Management: added check for invertibility of color spaces

Sergey Sharybin sergey.vfx at gmail.com
Tue Sep 11 09:56:48 CEST 2012


Revision: 50520
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50520
Author:   nazgul
Date:     2012-09-11 07:56:47 +0000 (Tue, 11 Sep 2012)
Log Message:
-----------
Color Management: added check for invertibility of color spaces

So now non-invertible color spaces can not be used as input color space
for images and as working color space for sequencer.

Currently have got two hard-coded families which are rrt and display.
If color space belong to one of this families, it would be considered
as non-invertible.

Data color spaces are always considered invertible.

If color space has got to_reference transformation, it'll be considered
invertible.

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/opencolorio/ocio_capi.cpp
    branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h
    branches/soc-2011-tomato/release/datafiles/colormanagement/config.ocio
    branches/soc-2011-tomato/source/blender/imbuf/intern/IMB_colormanagement_intern.h
    branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c

Modified: branches/soc-2011-tomato/intern/opencolorio/ocio_capi.cpp
===================================================================
--- branches/soc-2011-tomato/intern/opencolorio/ocio_capi.cpp	2012-09-11 06:12:48 UTC (rev 50519)
+++ branches/soc-2011-tomato/intern/opencolorio/ocio_capi.cpp	2012-09-11 07:56:47 UTC (rev 50520)
@@ -19,12 +19,14 @@
  * All rights reserved.
  *
  * Contributor(s): Xavier Thomas
- *                 Lukas Toene
+ *                 Lukas Toene,
+ *                 Sergey Sharybin
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
 #include <iostream>
+#include <string.h>
 
 #include <OpenColorIO/OpenColorIO.h>
 
@@ -264,6 +266,30 @@
 	return NULL;
 }
 
+int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs)
+{
+	const char *family = (*cs)->getFamily();
+
+	if (!strcmp(family, "rrt") || !strcmp(family, "display")) {
+		/* assume display and rrt transformations are not invertible
+		 * in fact some of them could be, but it doesn't make much sense to allow use them as invertible
+		 */
+		return false;
+	}
+
+	if ((*cs)->isData()) {
+		/* data color spaces don't have transformation at all */
+		return true;
+	}
+
+	if ((*cs)->getTransform(COLORSPACE_DIR_TO_REFERENCE)) {
+		/* if there's defined transform to reference space, color space could be converted to scene linear */
+		return true;
+	}
+
+	return true;
+}
+
 void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs)
 {
 	MEM_DELETE(cs, ConstColorSpaceRcPtr);

Modified: branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h
===================================================================
--- branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h	2012-09-11 06:12:48 UTC (rev 50519)
+++ branches/soc-2011-tomato/intern/opencolorio/ocio_capi.h	2012-09-11 07:56:47 UTC (rev 50520)
@@ -71,6 +71,8 @@
 ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const char *name);
 int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name);
 
+int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs);
+
 void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs);
 
 const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *config);

Modified: branches/soc-2011-tomato/release/datafiles/colormanagement/config.ocio
===================================================================
--- branches/soc-2011-tomato/release/datafiles/colormanagement/config.ocio	2012-09-11 06:12:48 UTC (rev 50519)
+++ branches/soc-2011-tomato/release/datafiles/colormanagement/config.ocio	2012-09-11 07:56:47 UTC (rev 50520)
@@ -120,7 +120,7 @@
 
   - !<ColorSpace>
     name: nuke_rec709
-    family:
+    family: display
     equalitygroup:
     bitdepth: 32f
     description: |
@@ -186,7 +186,7 @@
 
   - !<ColorSpace>
     name: dci_xyz
-    family:
+    family: display
     equalitygroup:
     bitdepth: 16f
     description: |
@@ -216,7 +216,7 @@
 
   - !<ColorSpace>
     name: srgb8
-    family: srgb
+    family: display
     equalitygroup:
     bitdepth: 8ui
     description: |

Modified: branches/soc-2011-tomato/source/blender/imbuf/intern/IMB_colormanagement_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/intern/IMB_colormanagement_intern.h	2012-09-11 06:12:48 UTC (rev 50519)
+++ branches/soc-2011-tomato/source/blender/imbuf/intern/IMB_colormanagement_intern.h	2012-09-11 07:56:47 UTC (rev 50520)
@@ -45,6 +45,8 @@
 
 	struct ConstProcessorRcPtr *to_scene_linear;
 	struct ConstProcessorRcPtr *from_scene_linear;
+
+	int is_invertible;
 } ColorSpace;
 
 typedef struct ColorManagedDisplay {
@@ -76,7 +78,7 @@
 struct ColorManagedView *colormanage_view_get_indexed(int index);
 struct ColorManagedView *colormanage_view_get_named(const char *name);
 
-struct ColorSpace *colormanage_colorspace_add(const char *name, const char *description);
+struct ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible);
 struct ColorSpace *colormanage_colorspace_get_named(const char *name);
 struct ColorSpace *colormanage_colorspace_get_indexed(int index);
 

Modified: branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c
===================================================================
--- branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-09-11 06:12:48 UTC (rev 50519)
+++ branches/soc-2011-tomato/source/blender/imbuf/intern/colormanagement.c	2012-09-11 07:56:47 UTC (rev 50520)
@@ -466,13 +466,15 @@
 	for (index = 0 ; index < tot_colorspace; index++) {
 		ConstColorSpaceRcPtr *ocio_colorspace;
 		const char *description;
+		int is_invertible;
 
 		name = OCIO_configGetColorSpaceNameByIndex(config, index);
 
 		ocio_colorspace = OCIO_configGetColorSpace(config, name);
 		description = OCIO_colorSpaceGetDescription(ocio_colorspace);
+		is_invertible = OCIO_colorSpaceIsInvertible(ocio_colorspace);
 
-		colormanage_colorspace_add(name, description);
+		colormanage_colorspace_add(name, description, is_invertible);
 
 		OCIO_colorSpaceRelease(ocio_colorspace);
 	}
@@ -2158,7 +2160,7 @@
 	}
 }
 
-ColorSpace *colormanage_colorspace_add(const char *name, const char *description)
+ColorSpace *colormanage_colorspace_add(const char *name, const char *description, int is_invertible)
 {
 	ColorSpace *colorspace;
 
@@ -2173,6 +2175,8 @@
 		colormanage_description_strip(colorspace->description);
 	}
 
+	colorspace->is_invertible = is_invertible;
+
 	BLI_addtail(&global_colorspaces, colorspace);
 
 	global_tot_colorspace++;
@@ -2279,6 +2283,9 @@
 	for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) {
 		EnumPropertyItem item;
 
+		if (!colorspace->is_invertible)
+			continue;
+
 		item.value = colorspace->index;
 		item.name = colorspace->name;
 		item.identifier = colorspace->name;




More information about the Bf-blender-cvs mailing list