ewavr
- interpolation of 7000 bad pixels: 110
Not much, but might be sped up using cached memory (malloc and load with fopen/fread)
- reverting bytes order in RAW buffer: 650
Most time waste happens in reverting bytes order in RAW buffer, but I don't know how avoid this procedure or decrease its time (now 2.5 CPU instructions/byte).
How about 1.1 instruction/byte ? Reduced from 550ms -> 290ms on my 6MP camera (a540):
void revert_bytes_order(char* start, int count){
// note, we will go to count rounded up to the nearest 32
asm volatile(
"ldr r2, =0xFF00FF\n" // r2 = mask
"add r1, r0, r1\n" // r1 = start + count
"LOOP:\n"
"ldm r0, {R4-R11}\n" // load 8 words
// out = ((in>>😎 & 0xFF00FF) | ((in&0xFF00FF) << 😎;
"mov r3, r4, lsr #8\n" // r3 = in >> 8
"and r3, r3, r2\n" // r3 &= 0xFF00FF
"and r4, r4, r2\n" // r4 = in & 0xFF00FF
"orr r4, r3, r4, asl #8\n" // out = r3 | (r4 << 😎
"mov r3, r5, lsr #8\n"
"and r3, r3, r2\n"
"and r5, r5, r2\n"
"orr r5, r3, r5, asl #8\n"
"mov r3, r6, lsr #8\n"
"and r3, r3, r2\n"
"and r6, r6, r2\n"
"orr r6, r3, r6, asl #8\n"
"mov r3, r7, lsr #8\n"
"and r3, r3, r2\n"
"and r7, r7, r2\n"
"orr r7, r3, r7, asl #8\n"
"mov r3, r8, lsr #8\n"
"and r3, r3, r2\n"
"and r8, r8, r2\n"
"orr r8, r3, r8, asl #8\n"
"mov r3, r9, lsr #8\n"
"and r3, r3, r2\n"
"and r9, r9, r2\n"
"orr r9, r3, r9, asl #8\n"
"mov r3, r10, lsr #8\n"
"and r3, r3, r2\n"
"and r10, r10, r2\n"
"orr r10, r3, r10, asl #8\n"
"mov r3, r11, lsr #8\n"
"and r3, r3, r2\n"
"and r11, r11, r2\n"
"orr r11, r3, r11, asl #8\n"
"stmia r0!, {r4-r11}\n" // store and increment
"cmp r0, r1\n"
"bcc LOOP\n"
:::"r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","r11"
);
}
I tried interleaving the memory accesses more, but it nothing seemed to get me below 280-290ms. It seems like you should be able to gain more by starting to get one batch of words into cache while you are processing the next, but either it is already doing it, or I didn't get it right.
Note this will go a bit past the end of the raw buffer if it isn't a multiple of 8 words. Seems harmless on mine, but you could actually just do a few less, since all the cameras have some border pixels that are zero and don't need to be swapped. In fact, you might be able to do a few thousand bytes less if you take the border into account.
@MartinBudden:
We are armv5te, rev is armv6 and above 🙁