Altivec & NSImage (NSBitmapImageRep) question
Altivec & NSImage (NSBitmapImageRep) question
- Subject: Altivec & NSImage (NSBitmapImageRep) question
- From: Ken Tabb <email@hidden>
- Date: Fri, 18 Jan 2002 19:00:38 +0000
Hi,
I'm in the middle of porting my Solaris computer vision (image
processing) code to Cocoa (Obj-C). The algorithms are fairly complex so
I'd quite like to use Altivec to speed things up a bit. Upon reading the
Altivec blurb at developer.apple.com/hardware/ve it would appear that I
can have either 16-way parallellism when using unsigned chars, or 4 way
parallellism when using unsigned floats.
My main use of Altivec would be pixel-crunching (on RGBA
NSBitmapImageReps taken from QuickTime movies). Looking at the TIFF
representations of the NSImages I'm getting from these bitmaps, it would
appear each channel (R, G, B and A) of each pixel in the image is stored
as a float. I don't need this level of detail (8 bits per channel, i.e.
32-bit colour, is fine for my needs) and having floats unnecessarily
would appear to only offer me 1/4 of the potential Altivec performance
gains (from above parallellism docs) as well as taking up 4 times as
much RAM as I need to be using (there are many copies of each image used
in the preprocessing, so it's a lot of memory to expect to be free).
Is there any way of getting the bitmap into the NSImage as channels of
unsigned char's (i.e. 4x 8 bit, i.e. 32 bit colour) as I could then be
processing 16 channels (or 4 complete RGBA pixels) concurrently (or 8
complete pixels at once on a dual processor).
Or would it be quicker / easier to simply convert from unsigned float ->
unsigned char before passing into Altivec? I can't help but think
there'd be a performance knock if I do this though (and again I'd be
using unnecessary amounts of RAM) as the main CPU would still have to be
operating on (converting) each channel of each pixel.
Needless to say I'm using only G4s for this work 8^)
Thanks in advance for your help,
Ken
- - - - - - - - - -
Ken Tabb
Mac & UNIX Technical bloke (C, C++, Obj-C, Java) - Health & Human
Sciences
Machine Vision & Neural Network researcher - Computer Science Dept
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider