Code cleanup: remove quicktime image loading code (not animation loading).
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 20 Jan 2014 15:52:06 +0000 (16:52 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 20 Jan 2014 15:55:00 +0000 (16:55 +0100)
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.

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

index f9e05dbd6d65d6460173e61209e48a5238a561c5..b6b46c7238428601cd55fd30c072fcc6b15346af 100644 (file)
@@ -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
 }
 
index fbe4733c3b18c8d57a550dd58b03c9de1cdc19eb..d0bf7a30e6d4960d171c3c766af2f995b205fa8a 100644 (file)
@@ -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 */
 
index e45720496cc92f412e552e31e74d89a8ba0824ef..3c6b2028031914e17f41032c6c200f7f76b294fa 100644 (file)
 #  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__ */