I'm trying to copy 1 or 2 colour channels from RGBA image data as quickly as possible (this is the slowest part of my code, and it's slowing the whole app down). Is there a fast way of copying with stride?
The data is simply laid out as RGBARGBARGBA etc., and I need to copy just the R values, or in another case just the RG values.
What I have so far is roughly this to copy the R values:
for(int i=0; i<dataSize; i++){
dest[i] = source[i*4];
}
For the RG values, I'm doing:
for(int i=0; i<dataSize; i+=2){
dest[i] = source[i*2];
dest[i+1] = source[(i*2)+1];
}
All the data is unsigned 1-byte values. Is there a faster way? I've already partially unrolled the loop (doing 64 values per iteration - insignificant speedup beyond that). Platform is Armv7 (iOS), so using NEON (SIMD) might be useful, I've zero experience with that unfortunately!
Changing the data is unfortunately out of the question, it's provided by opengl's readPixels() function, and iOS doesn't support reading as L, LA, RG etc. so far as I've been able to tell.