[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18638] trunk/blender: [#18164] jpeg2000 patch, with some fixes from Peter too.

Campbell Barton ideasman42 at gmail.com
Fri Jan 23 22:08:08 CET 2009


Revision: 18638
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18638
Author:   campbellbarton
Date:     2009-01-23 22:08:01 +0100 (Fri, 23 Jan 2009)

Log Message:
-----------
[#18164] jpeg2000 patch, with some fixes from Peter too.

Support for jpeg2000 and writing DCI Cinema standard files.

Notes
* 12 and 16bit channel depths are converted from/to blenders float buffer.
* Grayscale/RGB with alpha supported.
* Theres an option to save color channels as YCC rather then RGB.
* Quality 100 saves lossless
* The UI is a bit weired because of the DCI standards need to be given to the encoder.

Modified Paths:
--------------
    trunk/blender/config/irix6-config.py
    trunk/blender/config/linux2-config.py
    trunk/blender/config/win32-vc-config.py
    trunk/blender/source/blender/blenkernel/SConscript
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/blenpluginapi/iff.h
    trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
    trunk/blender/source/blender/imbuf/intern/readimage.c
    trunk/blender/source/blender/imbuf/intern/util.c
    trunk/blender/source/blender/imbuf/intern/writeimage.c
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/src/SConscript
    trunk/blender/source/blender/src/buttons_scene.c
    trunk/blender/source/blender/src/filelist.c
    trunk/blender/source/blender/src/writeimage.c
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/config/irix6-config.py
===================================================================
--- trunk/blender/config/irix6-config.py	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/config/irix6-config.py	2009-01-23 21:08:01 UTC (rev 18638)
@@ -159,7 +159,7 @@
 WITH_BF_OPENJPEG = 'false' 
 BF_OPENJPEG = '#extern/libopenjpeg'
 BF_OPENJPEG_LIB = ''
-BF_OPENJPEG_INC = '${BF_OPENJPEG}/include'
+BF_OPENJPEG_INC = '${BF_OPENJPEG}'
 BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
 
 WITH_BF_REDCODE = 'false'  

Modified: trunk/blender/config/linux2-config.py
===================================================================
--- trunk/blender/config/linux2-config.py	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/config/linux2-config.py	2009-01-23 21:08:01 UTC (rev 18638)
@@ -157,7 +157,7 @@
 WITH_BF_OPENJPEG = True 
 BF_OPENJPEG = '#extern/libopenjpeg'
 BF_OPENJPEG_LIB = ''
-BF_OPENJPEG_INC = '${BF_OPENJPEG}/include'
+BF_OPENJPEG_INC = '${BF_OPENJPEG}'
 BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
 
 WITH_BF_REDCODE = False  

Modified: trunk/blender/config/win32-vc-config.py
===================================================================
--- trunk/blender/config/win32-vc-config.py	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/config/win32-vc-config.py	2009-01-23 21:08:01 UTC (rev 18638)
@@ -153,6 +153,10 @@
 BF_QUICKTIME_LIBPATH = '${BF_QUICKTIME}/Libraries'
 
 WITH_BF_OPENJPEG = True 
+BF_OPENJPEG = '#extern/libopenjpeg'
+BF_OPENJPEG_LIB = ''
+BF_OPENJPEG_INC = '${BF_OPENJPEG}'
+BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
 
 WITH_BF_REDCODE = False  
 BF_REDCODE_INC = '#extern'

Modified: trunk/blender/source/blender/blenkernel/SConscript
===================================================================
--- trunk/blender/source/blender/blenkernel/SConscript	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/blenkernel/SConscript	2009-01-23 21:08:01 UTC (rev 18638)
@@ -42,6 +42,9 @@
 if env['WITH_BF_OPENEXR']:
     defs += ' WITH_OPENEXR'
 
+if env['WITH_BF_OPENJPEG']:
+    defs += ' WITH_OPENJPEG'
+
 if env['WITH_BF_DDS']:
     defs += ' WITH_DDS'
 

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2009-01-23 21:08:01 UTC (rev 18638)
@@ -767,6 +767,10 @@
 		return RAWTGA;
 	else if(imtype==R_HAMX)
 		return AN_hamx;
+#ifdef WITH_OPENJPEG
+	else if(imtype==R_JP2)
+		return JP2;
+#endif
 	else
 		return JPG|90;
 }
@@ -801,6 +805,10 @@
 		return R_RAWTGA;
 	else if(ftype == AN_hamx)
 		return R_HAMX;
+#ifdef WITH_OPENJPEG
+	else if(ftype & JP2)
+		return R_JP2;
+#endif
 	else
 		return R_JPEG90;
 }
@@ -877,6 +885,12 @@
 		if(!BLI_testextensie(string, ".tga"))
 			extension= ".tga";
 	}
+#ifdef WITH_OPENJPEG
+	else if(imtype==R_JP2) {
+		if(!BLI_testextensie(string, ".jp2"))
+			extension= ".jp2";
+	}
+#endif
 	else { //   R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90, R_QUICKTIME etc
 		if(!( BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg")))
 			extension= ".jpg";
@@ -1220,6 +1234,28 @@
 	else if(imtype==R_HAMX) {
 		ibuf->ftype= AN_hamx;
 	}
+#ifdef WITH_OPENJPEG
+	else if(imtype==R_JP2) {
+		if(quality < 10) quality= 90;
+		ibuf->ftype= JP2|quality;
+		
+		if (subimtype & R_JPEG2K_16BIT) {
+			ibuf->ftype |= JP2_16BIT;
+		} else if (subimtype & R_JPEG2K_12BIT) {
+			ibuf->ftype |= JP2_12BIT;
+		}
+		
+		if (subimtype & R_JPEG2K_YCC) {
+			ibuf->ftype |= JP2_YCC;
+		}
+		
+		if (subimtype & R_JPEG2K_CINE_PRESET) {
+			ibuf->ftype |= JP2_CINE;
+			if (subimtype & R_JPEG2K_CINE_48FPS)
+				ibuf->ftype |= JP2_CINE_48FPS;
+		}
+	}
+#endif
 	else {
 		/* R_JPEG90, R_MOVIE, etc. default we save jpegs */
 		if(quality < 10) quality= 90;

Modified: trunk/blender/source/blender/blenpluginapi/iff.h
===================================================================
--- trunk/blender/source/blender/blenpluginapi/iff.h	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/blenpluginapi/iff.h	2009-01-23 21:08:01 UTC (rev 18638)
@@ -56,6 +56,10 @@
 #endif
 #define RADHDR  (1<<24)
 
+#ifdef WITH_OPENJPEG
+#define JP2                            (1 << 18)
+#endif
+
 #define RAWTGA	(TGA | 1)
 
 #define JPG_STD	(JPG | (0 << 8))
@@ -113,6 +117,7 @@
 #define IS_tim(x)		(x->ftype & TIM)
 #define IS_tiff(x)		(x->ftype & TIFF)
 #define IS_openexr(x)           (x->ftype & OPENEXR)
+#define IS_jp2(x)           (x->ftype & JP2)
 
 
 #define IMAGIC 	0732

Modified: trunk/blender/source/blender/imbuf/IMB_imbuf_types.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf_types.h	2009-01-23 21:08:01 UTC (rev 18638)
@@ -181,6 +181,15 @@
 #define DDS				(1 << 19)
 #endif
 
+#ifdef WITH_OPENJPEG
+#define JP2				(1 << 18)
+#define JP2_12BIT			(1 << 17)
+#define JP2_16BIT			(1 << 16)
+#define JP2_YCC			(1 << 15)
+#define JP2_CINE			(1 << 14)
+#define JP2_CINE_48FPS		(1 << 13) 
+#endif
+
 #define RAWTGA	        (TGA | 1)
 
 #define JPG_STD	        (JPG | (0 << 8))
@@ -217,6 +226,7 @@
 #define IS_tga(x)		(x->ftype & TGA)
 #define IS_png(x)		(x->ftype & PNG)
 #define IS_openexr(x)	(x->ftype & OPENEXR)
+#define IS_jp2(x)              (x->ftype & JP2)
 #define IS_cineon(x)	(x->ftype & CINEON)
 #define IS_dpx(x)		(x->ftype & DPX)
 #define IS_bmp(x)		(x->ftype & BMP)

Modified: trunk/blender/source/blender/imbuf/intern/readimage.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/readimage.c	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/imbuf/intern/readimage.c	2009-01-23 21:08:01 UTC (rev 18638)
@@ -58,6 +58,10 @@
 #include "IMB_dpxcineon.h"
 #include "BKE_global.h"
 
+#ifdef WITH_OPENJPEG
+#include "IMB_jp2.h"
+#endif
+
 #ifdef WITH_OPENEXR
 #include "openexr/openexr_api.h"
 #endif
@@ -161,11 +165,16 @@
 		if (ibuf) return (ibuf);
 #endif
 
+#ifdef WITH_OPENJPEG
+		ibuf = imb_jp2_decode((uchar *)mem, size, flags);
+		if (ibuf) return (ibuf);
+#endif
+
 #ifdef WITH_DDS
 		ibuf = imb_load_dds((uchar *)mem, size, flags);
 		if (ibuf) return (ibuf);
 #endif
-		
+	
 #ifdef WITH_QUICKTIME
 #if defined(_WIN32) || defined (__APPLE__)
 		if(G.have_quicktime) {

Modified: trunk/blender/source/blender/imbuf/intern/util.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/util.c	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/imbuf/intern/util.c	2009-01-23 21:08:01 UTC (rev 18638)
@@ -68,6 +68,10 @@
 #include "quicktime_import.h"
 #endif
 
+#ifdef WITH_OPENJPEG
+#include "IMB_jp2.h"
+#endif
+
 #ifdef WITH_FFMPEG
 #include <ffmpeg/avcodec.h>
 #include <ffmpeg/avformat.h>
@@ -140,7 +144,11 @@
 /*
 				if (imb_is_a_bmp(buf)) return(BMP);
 */
-
+				
+#ifdef WITH_OPENJPEG
+				if (imb_is_a_jp2(buf)) return(JP2);
+#endif
+				
 #ifdef WITH_QUICKTIME
 #if defined(_WIN32) || defined(__APPLE__)
 				if(G.have_quicktime) {
@@ -191,6 +199,9 @@
 #ifdef WITH_BF_OPENEXR
 				||	BLI_testextensie(filename, ".exr")
 #endif
+#ifdef WITH_BF_OPENJPEG
+				||	BLI_testextensie(filename, ".jp2")
+#endif
 				||	BLI_testextensie(filename, ".sgi")) {
 				return IMB_ispic_name(filename);
 			} else {
@@ -211,6 +222,9 @@
 #ifdef WITH_BF_OPENEXR
 				||	BLI_testextensie(filename, ".exr")
 #endif
+#ifdef WITH_BF_OPENJPEG
+				||	BLI_testextensie(filename, ".jp2")
+#endif
 				||	BLI_testextensie(filename, ".iff")
 				||	BLI_testextensie(filename, ".lbm")
 				||	BLI_testextensie(filename, ".sgi")) {

Modified: trunk/blender/source/blender/imbuf/intern/writeimage.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/writeimage.c	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/imbuf/intern/writeimage.c	2009-01-23 21:08:01 UTC (rev 18638)
@@ -55,6 +55,9 @@
 #include "IMB_bmp.h"
 #include "IMB_tiff.h"
 #include "IMB_radiance_hdr.h"
+#ifdef WITH_OPENJPEG
+#include "IMB_jp2.h"
+#endif
 #ifdef WITH_OPENEXR
 #include "openexr/openexr_api.h"
 #endif
@@ -129,6 +132,11 @@
 	if (IS_dpx(ibuf)) {
 		return imb_save_dpx(ibuf, name, flags);
 	}
+#ifdef WITH_OPENJPEG
+	if (IS_jp2(ibuf)) {
+		return imb_savejp2(ibuf, name, flags);
+	}
+#endif	
 	file = open(name, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666);
 	if (file < 0) return (FALSE);
 

Modified: trunk/blender/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_scene_types.h	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/makesdna/DNA_scene_types.h	2009-01-23 21:08:01 UTC (rev 18638)
@@ -310,6 +310,10 @@
 	/* cineon */
 	short cineonwhite, cineonblack;
 	float cineongamma;
+	
+	/* jpeg2000 */
+	short jp2_preset, jp2_depth;
+	int rpad3;
 } RenderData;
 
 /* control render convert and shading engine */
@@ -692,6 +696,7 @@
 #define R_DPX			27
 #define R_MULTILAYER	28
 #define R_DDS			29
+#define R_JP2			30
 
 /* subimtype, flag options for imtype */
 #define R_OPENEXR_HALF	1
@@ -700,6 +705,13 @@
 #define R_CINEON_LOG 	8
 #define R_TIFF_16BIT	16
 
+#define R_JPEG2K_12BIT	32 /* Jpeg2000 */
+#define R_JPEG2K_16BIT	64
+#define R_JPEG2K_YCC	128 /* when disabled use RGB */
+#define R_JPEG2K_CINE_PRESET	256
+#define R_JPEG2K_CINE_48FPS		512
+
+
 /* bake_mode: same as RE_BAKE_xxx defines */
 /* bake_flag: */
 #define R_BAKE_CLEAR		1

Modified: trunk/blender/source/blender/src/SConscript
===================================================================
--- trunk/blender/source/blender/src/SConscript	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/src/SConscript	2009-01-23 21:08:01 UTC (rev 18638)
@@ -53,6 +53,9 @@
 if env['WITH_BF_OPENEXR']:
     defs.append('WITH_OPENEXR')
 
+if env['WITH_BF_OPENJPEG']:
+    defs.append('WITH_OPENJPEG')
+
 if env['WITH_BF_DDS']:
     defs.append('WITH_DDS')
 

Modified: trunk/blender/source/blender/src/buttons_scene.c
===================================================================
--- trunk/blender/source/blender/src/buttons_scene.c	2009-01-23 20:36:47 UTC (rev 18637)
+++ trunk/blender/source/blender/src/buttons_scene.c	2009-01-23 21:08:01 UTC (rev 18638)
@@ -1956,7 +1956,6 @@
 	char appendstring[1024];
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list