[Bf-blender-cvs] [a2930c6] master: Code cleanup: remove quicktime image loading code (not animation loading).

Brecht Van Lommel noreply at git.blender.org
Mon Jan 20 16:58:14 CET 2014


Commit: a2930c634f5debf2dc25cc2b80e7c91f84eae833
Author: Brecht Van Lommel
Date:   Mon Jan 20 16:52:06 2014 +0100
https://developer.blender.org/rBa2930c634f5debf2dc25cc2b80e7c91f84eae833

Code cleanup: remove quicktime image loading code (not animation loading).

This code has been broken for a few years and no one noticed, it's also less
useful now that we support PSD image loading ourselves which was the original
motivation to have this.

===================================================================

M	source/blender/imbuf/intern/filetype.c
M	source/blender/quicktime/apple/qtkit_import.m
M	source/blender/quicktime/quicktime_import.h

===================================================================

diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c
index f9e05db..b6b46c7 100644
--- a/source/blender/imbuf/intern/filetype.c
+++ b/source/blender/imbuf/intern/filetype.c
@@ -62,17 +62,6 @@ static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf)
 	(void)type;
 	return (ibuf->ftype == IMAGIC);
 }
-#ifdef WITH_QUICKTIME
-static int imb_ftype_quicktime(ImFileType *UNUSED(type), ImBuf *UNUSED(ibuf))
-{
-	return 0; /* XXX */
-}
-#endif
-
-#ifdef WITH_QUICKTIME
-void quicktime_init(void);
-void quicktime_exit(void);
-#endif
 
 ImFileType IMB_FILE_TYPES[] = {
 	{NULL, NULL, imb_is_a_jpeg, NULL, imb_ftype_default, imb_load_jpeg, NULL, imb_savejpeg, NULL, 0, JPG, COLOR_ROLE_DEFAULT_BYTE},
@@ -99,9 +88,6 @@ ImFileType IMB_FILE_TYPES[] = {
 #ifdef WITH_DDS
 	{NULL, NULL, imb_is_a_dds, NULL, imb_ftype_default, imb_load_dds, NULL, NULL, NULL, 0, DDS, COLOR_ROLE_DEFAULT_BYTE},
 #endif
-#ifdef WITH_QUICKTIME
-	{quicktime_init, quicktime_exit, imb_is_a_quicktime, NULL, imb_ftype_quicktime, imb_quicktime_decode, NULL, NULL, 0, QUICKTIME, COLOR_ROLE_DEFAULT_BYTE},
-#endif
 #ifdef WITH_OPENIMAGEIO
 	{NULL, NULL, NULL, imb_is_a_photoshop, imb_ftype_default, NULL, imb_load_photoshop, NULL, NULL, IM_FTYPE_FLOAT, PSD, COLOR_ROLE_DEFAULT_FLOAT},
 #endif
@@ -117,6 +103,10 @@ void imb_filetypes_init(void)
 	for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
 		if (type->init)
 			type->init();
+
+#ifdef WITH_QUICKTIME
+	quicktime_init();
+#endif
 }
 
 void imb_filetypes_exit(void)
@@ -126,5 +116,9 @@ void imb_filetypes_exit(void)
 	for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
 		if (type->exit)
 			type->exit();
+
+#ifdef WITH_QUICKTIME
+	quicktime_exit();
+#endif
 }
 
diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m
index fbe4733..d0bf7a3 100644
--- a/source/blender/quicktime/apple/qtkit_import.m
+++ b/source/blender/quicktime/apple/qtkit_import.m
@@ -66,10 +66,9 @@ typedef struct _QuicktimeMovie {
 
 void quicktime_init(void)
 {
-		G.have_quicktime = TRUE;
+	G.have_quicktime = TRUE;
 }
 
-
 void quicktime_exit(void)
 {
 	if (G.have_quicktime) {
@@ -392,166 +391,5 @@ int startquicktime(struct anim *anim)
 	return 0;
 }
 
-int imb_is_a_quicktime(char *name)
-{
-	NSImage *image;
-	int result;
-	NSAutoreleasePool *pool;
-	
-	if (!G.have_quicktime) return 0;
-
-	pool = [[NSAutoreleasePool alloc] init];
-	
-	// don't let quicktime image import handle these
-	if (BLI_testextensie(name, ".swf") ||
-		BLI_testextensie(name, ".txt") ||
-		BLI_testextensie(name, ".mpg") ||
-		BLI_testextensie(name, ".wav") ||
-		BLI_testextensie(name, ".mov") ||	// not as image, doesn't work
-		BLI_testextensie(name, ".avi") ||
-		BLI_testextensie(name, ".mp3")) return 0;
-
-	
-	image = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:name]];
-	if (image) {
-		[image release];
-		result = true;
-	}
-	else 
-		result = false;
-
-	[pool drain];
-	return result;
-}
-
-ImBuf  *imb_quicktime_decode(unsigned char *mem, int size, int flags)
-{
-	struct ImBuf *ibuf = NULL;
-	NSSize bitmapSize;
-	uchar *rasterRGB = NULL;
-	uchar *rasterRGBA = NULL;
-	uchar *toIBuf = NULL;
-	int x, y, to_i, from_i;
-	NSData *data;
-	NSBitmapImageRep *bitmapImage;
-	NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA;
-	NSAutoreleasePool *pool;
-
-	if (!G.have_quicktime)
-		return NULL;
-	
-	pool = [[NSAutoreleasePool alloc] init];
-	
-	data = [NSData dataWithBytes:mem length:size];
-	bitmapImage = [[NSBitmapImageRep alloc] initWithData:data];
-	
-	if (!bitmapImage) {
-		fprintf(stderr, "imb_cocoaLoadImage: error loading image\n");
-		[pool drain];
-		return NULL;
-	}
-	
-	bitmapSize.width = [bitmapImage pixelsWide];
-	bitmapSize.height = [bitmapImage pixelsHigh];
-	
-	/* Tell cocoa image resolution is same as current system one */
-	[bitmapImage setSize:bitmapSize];
-	
-	/* allocate the image buffer */
-	ibuf = IMB_allocImBuf(bitmapSize.width, bitmapSize.height, 32/*RGBA*/, 0);
-	if (!ibuf) {
-		fprintf(stderr, 
-		        "imb_cocoaLoadImage: could not allocate memory for the image.\n");
-		[bitmapImage release];
-		[pool drain];
-		return NULL;
-	}
-	
-	/* read in the image data */
-	if (!(flags & IB_test)) {
-		
-		/* allocate memory for the ibuf->rect */
-		imb_addrectImBuf(ibuf);
-		
-		/* Convert the image in a RGBA 32bit format */
-		/* As Core Graphics does not support contextes with non premutliplied alpha,
-		 we need to get alpha key values in a separate batch */
-		
-		/* First get RGB values w/o Alpha to avoid pre-multiplication, 32bit but last byte is unused */
-		blBitmapFormatImageRGB = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-																		 pixelsWide:bitmapSize.width 
-																		 pixelsHigh:bitmapSize.height
-																	  bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO
-																	 colorSpaceName:NSCalibratedRGBColorSpace 
-																	   bitmapFormat:0
-																		bytesPerRow:4*bitmapSize.width
-																	   bitsPerPixel:32/*RGB format padded to 32bits*/];
-		
-		[NSGraphicsContext saveGraphicsState];
-		[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:blBitmapFormatImageRGB]];
-		[bitmapImage draw];
-		[NSGraphicsContext restoreGraphicsState];
-		
-		rasterRGB = (uchar *)[blBitmapFormatImageRGB bitmapData];
-		if (rasterRGB == NULL) {
-			[bitmapImage release];
-			[blBitmapFormatImageRGB release];
-			[pool drain];
-			return NULL;
-		}
-		
-		/* Then get Alpha values by getting the RGBA image (that is premultiplied btw) */
-		blBitmapFormatImageRGBA = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-																		  pixelsWide:bitmapSize.width
-																		  pixelsHigh:bitmapSize.height
-																	   bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO
-																	  colorSpaceName:NSCalibratedRGBColorSpace
-																		bitmapFormat:0
-																		 bytesPerRow:4*bitmapSize.width
-																		bitsPerPixel:32/* RGBA */];
-		
-		[NSGraphicsContext saveGraphicsState];
-		[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:blBitmapFormatImageRGBA]];
-		[bitmapImage draw];
-		[NSGraphicsContext restoreGraphicsState];
-		
-		rasterRGBA = (uchar *)[blBitmapFormatImageRGBA bitmapData];
-		if (rasterRGBA == NULL) {
-			[bitmapImage release];
-			[blBitmapFormatImageRGB release];
-			[blBitmapFormatImageRGBA release];
-			[pool drain];
-			return NULL;
-		}
-		
-		/*Copy the image to ibuf, flipping it vertically*/
-		toIBuf = (uchar *)ibuf->rect;
-		for (x = 0; x < bitmapSize.width; x++) {
-			for (y = 0; y < bitmapSize.height; y++) {
-				to_i = (bitmapSize.height-y-1)*bitmapSize.width + x;
-				from_i = y*bitmapSize.width + x;
-				
-				toIBuf[4*to_i] = rasterRGB[4*from_i]; /* R */
-				toIBuf[4*to_i+1] = rasterRGB[4*from_i+1]; /* G */
-				toIBuf[4*to_i+2] = rasterRGB[4*from_i+2]; /* B */
-				toIBuf[4*to_i+3] = rasterRGBA[4*from_i+3]; /* A */
-			}
-		}
-		
-		[blBitmapFormatImageRGB release];
-		[blBitmapFormatImageRGBA release];
-	}
-	
-	/* release the cocoa objects */
-	[bitmapImage release];
-	[pool drain];
-	
-	if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
-	
-	/* return successfully */
-	return (ibuf);
-}
-
-
 #endif /* WITH_QUICKTIME */
 
diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h
index e457204..3c6b202 100644
--- a/source/blender/quicktime/quicktime_import.h
+++ b/source/blender/quicktime/quicktime_import.h
@@ -48,7 +48,10 @@
 #  endif /* __FIXMATH__ */
 #endif /* _WIN32 _ */
 
-char *get_valid_qtname(const char *name);
+/* init/exit */
+
+void quicktime_init(void);
+void quicktime_exit(void);
 
 /* quicktime movie import functions */
 
@@ -57,9 +60,4 @@ int		startquicktime(struct anim *anim);
 void	free_anim_quicktime(struct anim *anim);
 ImBuf  *qtime_fetchibuf(struct anim *anim, int position);
 
-/* quicktime image import functions */
-
-int		imb_is_a_quicktime(char *name);
-ImBuf  *imb_quicktime_decode(unsigned char *mem, int size, int flags);
-
 #endif  /* __QUICKTIME_IMPORT_H__ */




More information about the Bf-blender-cvs mailing list