I am in progress to deliver new code for DNG, RAW, Motion detection and shot histogram.
If you want to make significant changes, I'd suggest a thread to discuss them before posting here. Also, as I've mentioned before, I really prefer that unrelated changes be submitted in individual patches. If the changes are non-trivial, I will probably insist on this.
First, I start with some C optimizations and minor corrections to test the delivery process.
Did you check if these optimizations improve performance or binary size ?
I had a bit of a look through it, and most of the changes look like they will be insignificant.
Changing the for loops is unnecessary, modern compilers plenty smart to generate good code in the normal version:
0014b3cc <foo_old>:
14b3cc: b510 push {r4, lr}
14b3ce: 2400 movs r4, #0
14b3d0: 1c20 adds r0, r4, #0
14b3d2: 3401 adds r4, #1
14b3d4: f7ff fff2 bl 14b3bc <bar>
14b3d8: 2c0a cmp r4, #10
14b3da: d1f9 bne.n 14b3d0 <foo_old+0x4>
14b3dc: bc10 pop {r4}
14b3de: bc01 pop {r0}
14b3e0: 4700 bx r0
0014b3e2 <foo_new>:
14b3e2: b510 push {r4, lr}
14b3e4: 240a movs r4, #10
14b3e6: 3c01 subs r4, #1
14b3e8: 1c20 adds r0, r4, #0
14b3ea: f7ff ffe7 bl 14b3bc <bar>
14b3ee: 2c00 cmp r4, #0
14b3f0: d1f9 bne.n 14b3e6 <foo_new+0x4>
14b3f2: bc10 pop {r4}
14b3f4: bc01 pop {r0}
14b3f6: 4700 bx r0
One of these is for(i=0;i<10;i++) and the other is for(i=10;i--;)
Notice they are the exact same number of instructions, and the instructions are equivalent. In the old days, this might have been worthwhile...
Even if there was a marginal improvement, I'd rather not spend my time reviewing and apply stuff that doesn't make any significant difference. If it makes the code clearer or better structured, I'm certainly for that. If doing it in a lot of places makes the binary noticeably smaller, I could go for that too.
Also, the patch has a bunch of unrelated whitespace changes, which makes it a bit harder to follow. These are mostly from trailing whitespace which I'd be happy remove, but preferable in it's own changeset.