[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51495] trunk/blender/source/blender: Patch #27397: Improved DPX/Cineon code

Sergey Sharybin sergey.vfx at gmail.com
Mon Oct 22 14:49:00 CEST 2012


Revision: 51495
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51495
Author:   nazgul
Date:     2012-10-22 12:49:00 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
Patch #27397: Improved DPX/Cineon code

Patch by Julien Enche, thanks!

>From the patch comment:

It allows Blender to load:
- 1, 8, 10, 12 and 16 bits files. For 10 and 12 bits files, packed or
  filled type A/B are supported.
- RGB, Log, Luma and YCbCr colorspaces.
- Big and little endian storage.
- Multi-elements (planar) storage.

It allows Blender to save :
- 8, 10, 12 and 16 bits file. For 10 and 12 bits files, the most used
  type A padding is used.
- RGB and Log colorspaces (Cineon can only be saved in Log colorspace).
  For Log colorspace, the common default values are used for gamma,
  reference black and reference white (respectively 1.7, 95 and 685 for
  10 bits files).
- Saved DPX/Cineon files now match the viewer.

Some files won't load (mostly because I haven't seen any of them):
- Compressed files
- 32 and 64 bits files
- Image orientation information are not taken in account. Here too,
  I haven't seen any file that was not top-bottom/left-right oriented.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/editors/space_image/image_buttons.c
    trunk/blender/source/blender/imbuf/CMakeLists.txt
    trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
    trunk/blender/source/blender/imbuf/intern/IMB_filetype.h
    trunk/blender/source/blender/imbuf/intern/cineon/CMakeLists.txt
    trunk/blender/source/blender/imbuf/intern/cineon/cin_debug_stuff.h
    trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c
    trunk/blender/source/blender/imbuf/intern/cineon/cineonfile.h
    trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.c
    trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.h
    trunk/blender/source/blender/imbuf/intern/cineon/dpxfile.h
    trunk/blender/source/blender/imbuf/intern/cineon/dpxlib.c
    trunk/blender/source/blender/imbuf/intern/cineon/dpxlib.h
    trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.c
    trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.h
    trunk/blender/source/blender/imbuf/intern/cineon/logImageLib.c
    trunk/blender/source/blender/imbuf/intern/cineon/logImageLib.h
    trunk/blender/source/blender/imbuf/intern/cineon/logmemfile.c
    trunk/blender/source/blender/imbuf/intern/cineon/logmemfile.h
    trunk/blender/source/blender/imbuf/intern/filetype.c
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/makesrna/intern/rna_scene.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2012-10-22 12:49:00 UTC (rev 51495)
@@ -1063,6 +1063,7 @@
 		case R_IMF_IMTYPE_DDS:
 		case R_IMF_IMTYPE_JP2:
 		case R_IMF_IMTYPE_QUICKTIME:
+		case R_IMF_IMTYPE_DPX:
 			chan_flag |= IMA_CHAN_FLAG_ALPHA;
 	}
 
@@ -1091,10 +1092,11 @@
 			return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32;
 		case R_IMF_IMTYPE_MULTILAYER:
 			return R_IMF_CHAN_DEPTH_32;
-		/* eeh, cineone does some strange 10bits per channel */
+		/* eeh, cineon does some strange 10bits per channel */
 		case R_IMF_IMTYPE_DPX:
+			return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_10 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
 		case R_IMF_IMTYPE_CINEON:
-			return R_IMF_CHAN_DEPTH_12;
+			return R_IMF_CHAN_DEPTH_10;
 		case R_IMF_IMTYPE_JP2:
 			return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16;
 		/* most formats are 8bit only */
@@ -1825,9 +1827,29 @@
 #ifdef WITH_CINEON
 	else if (imtype == R_IMF_IMTYPE_CINEON) {
 		ibuf->ftype = CINEON;
+		if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
+			ibuf->ftype |= CINEON_LOG;
+		}
+		if (imf->depth == R_IMF_CHAN_DEPTH_16) {
+			ibuf->ftype |= CINEON_16BIT;
+		} else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
+			ibuf->ftype |= CINEON_12BIT;
+		} else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
+			ibuf->ftype |= CINEON_10BIT;
+		}
 	}
 	else if (imtype == R_IMF_IMTYPE_DPX) {
 		ibuf->ftype = DPX;
+		if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) {
+		  ibuf->ftype |= CINEON_LOG;
+		}
+		if (imf->depth == R_IMF_CHAN_DEPTH_16) {
+			ibuf->ftype |= CINEON_16BIT;
+		} else if (imf->depth == R_IMF_CHAN_DEPTH_12) {
+			ibuf->ftype |= CINEON_12BIT;
+		} else if (imf->depth == R_IMF_CHAN_DEPTH_10) {
+			ibuf->ftype |= CINEON_10BIT;
+		}
 	}
 #endif
 	else if (imtype == R_IMF_IMTYPE_TARGA) {

Modified: trunk/blender/source/blender/editors/space_image/image_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_buttons.c	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/editors/space_image/image_buttons.c	2012-10-22 12:49:00 UTC (rev 51495)
@@ -759,9 +759,10 @@
 	uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE);
 
 	/* only display depth setting if multiple depths can be used */
-	if ((ELEM6(depth_ok,
+	if ((ELEM7(depth_ok,
 	           R_IMF_CHAN_DEPTH_1,
 	           R_IMF_CHAN_DEPTH_8,
+	           R_IMF_CHAN_DEPTH_10,
 	           R_IMF_CHAN_DEPTH_12,
 	           R_IMF_CHAN_DEPTH_16,
 	           R_IMF_CHAN_DEPTH_24,
@@ -801,9 +802,13 @@
 		uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE);
 	}
 
+	if (imf->imtype == R_IMF_IMTYPE_DPX) {
+		uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
+	}
+
 	if (imf->imtype == R_IMF_IMTYPE_CINEON) {
 #if 1
-		uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma: 1.0"), ICON_NONE);
+		uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma:1.7"), ICON_NONE);
 #else
 		uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
 		uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE);

Modified: trunk/blender/source/blender/imbuf/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/imbuf/CMakeLists.txt	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/imbuf/CMakeLists.txt	2012-10-22 12:49:00 UTC (rev 51495)
@@ -81,13 +81,9 @@
 	intern/IMB_indexer.h
 	intern/IMB_metadata.h
 	intern/imbuf.h
-	intern/cineon/cin_debug_stuff.h
-	intern/cineon/cineonfile.h
 	intern/cineon/cineonlib.h
-	intern/cineon/dpxfile.h
 	intern/cineon/dpxlib.h
 	intern/cineon/logImageCore.h
-	intern/cineon/logImageLib.h
 	intern/cineon/logmemfile.h
 	intern/dds/BlockDXT.h
 	intern/dds/Color.h

Modified: trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2012-10-22 12:49:00 UTC (rev 51495)
@@ -200,6 +200,10 @@
 #ifdef WITH_CINEON
 #define CINEON			(1 << 21)
 #define DPX				(1 << 20)
+#define CINEON_LOG		(1 << 8)
+#define CINEON_16BIT	(1 << 7)
+#define CINEON_12BIT	(1 << 6)
+#define CINEON_10BIT	(1 << 5)
 #endif
 
 #ifdef WITH_DDS

Modified: trunk/blender/source/blender/imbuf/intern/IMB_filetype.h
===================================================================
--- trunk/blender/source/blender/imbuf/intern/IMB_filetype.h	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/imbuf/intern/IMB_filetype.h	2012-10-22 12:49:00 UTC (rev 51495)
@@ -97,13 +97,13 @@
 short imb_cocoaSaveImage(struct ImBuf *ibuf, const char *name, int flags);
 
 /* cineon */
-int imb_savecineon(struct ImBuf *buf, const char *name, int flags);
-struct ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+int imb_save_cineon(struct ImBuf *buf, const char *name, int flags);
+struct ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
 int imb_is_cineon(unsigned char *buf);
 
 /* dpx */
 int imb_save_dpx(struct ImBuf *buf, const char *name, int flags);
-struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
+struct ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
 int imb_is_dpx(unsigned char *buf);
 
 /* hdr */

Modified: trunk/blender/source/blender/imbuf/intern/cineon/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/CMakeLists.txt	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/imbuf/intern/cineon/CMakeLists.txt	2012-10-22 12:49:00 UTC (rev 51495)
@@ -43,8 +43,11 @@
 	cineonlib.c
 	dpxlib.c
 	logImageCore.c
-	logImageLib.c
 	logmemfile.c
 )
 
+if(WITH_IMAGE_CINEON)
+	add_definitions(-DWITH_CINEON)
+endif()
+
 blender_add_lib(bf_imbuf_cineon "${SRC}" "${INC}" "${INC_SYS}")

Modified: trunk/blender/source/blender/imbuf/intern/cineon/cin_debug_stuff.h
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/cin_debug_stuff.h	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/imbuf/intern/cineon/cin_debug_stuff.h	2012-10-22 12:49:00 UTC (rev 51495)
@@ -1,4 +0,0 @@
-/** \file blender/imbuf/intern/cineon/cin_debug_stuff.h
- *  \ingroup imbcineon
- */
-#define d_printf printf

Modified: trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c	2012-10-22 12:22:15 UTC (rev 51494)
+++ trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c	2012-10-22 12:49:00 UTC (rev 51495)
@@ -4,11 +4,11 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
@@ -20,26 +20,25 @@
  *
  * The Original Code is: all of this file.
  *
- * Contributor(s): none yet.
+ * Contributor(s): Julien Enche.
  *
  * ***** END GPL LICENSE BLOCK *****
  * cineon.c
- * contributors: joeedh
+ * contributors: joeedh, Julien Enche
  * I hearby donate this code and all rights to the Blender Foundation.
+ * $Id$
  */
 
 /** \file blender/imbuf/intern/cineon/cineon_dpx.c
  *  \ingroup imbcineon
  */
 
- 
+
 #include <stdio.h>
-#include <string.h> /*for memcpy*/
+#include <string.h>
+#include <math.h>
+#include "logImageCore.h"
 
-#include "logImageLib.h"
-#include "cineonlib.h"
-#include "dpxlib.h"
-
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 #include "IMB_filetype.h"
@@ -51,167 +50,141 @@
 
 #include "MEM_guardedalloc.h"
 
-#if 0
-static void cineon_conversion_parameters(LogImageByteConversionParameters *params)
+static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int use_cineon, int flags,
+                                         char colorspace[IM_MAX_SPACE])
 {
-//	params->blackPoint = scene?scene->r.cineonblack:95;
-//	params->whitePoint = scene?scene->r.cineonwhite:685;
-//	params->gamma = scene?scene->r.cineongamma:1.7f;
-//	params->doLogarithm = scene?scene->r.subimtype & R_CINEON_LOG:0;
-	
-	params->blackPoint = 95;
-	params->whitePoint = 685;
-	params->gamma = 1.0f;
-	params->doLogarithm = 0;
-}
-#endif
-
-static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags, char colorspace[IM_MAX_SPACE])
-{
 	ImBuf *ibuf;
 	LogImageFile *image;
-	int x, y;
-	unsigned short *row, *upix;
 	int width, height, depth;
-	float *frow;
 
 	colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
 
-	logImageSetVerbose((G.debug & G_DEBUG) ? 1:0);
-	
-	image = logImageOpenFromMem(mem, size, use_cineon);
-	
-	if (!image) {
-		printf("no image!\n");
-		return NULL;
+	logImageSetVerbose((G.f & G_DEBUG) ? 1:0);
+
+	image = logImageOpenFromMemory(mem, size);
+
+	if (image == 0) {
+		printf("DPX/Cineon: error opening image.\n");
+		return 0;
 	}
-	
+
 	logImageGetSize(image, &width, &height, &depth);
-	
-	if (depth != 3) { /*need to do grayscale loading eventually.*/
+
+	if (width == 0 || height == 0) {
 		logImageClose(image);
-		return NULL;
+		return 0;
 	}
-	
-	if (width == 0 && height == 0) {
+
+	ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags);
+	if (ibuf == 0) {
 		logImageClose(image);
-		return NULL;
+		return 0;
 	}
-	
-	ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags);
 
-	row = MEM_mallocN(sizeof(unsigned short)*width*depth, "row in cineon_dpx.c");
-	frow = ibuf->rect_float+width*height*4;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list