[FFmpeg-devel] [PATCH] broaden ff_set_fixed_vector
Måns Rullgård
mans
Wed Jan 27 04:36:09 CET 2010
"Ronald S. Bultje" <rsbultje at gmail.com> writes:
> Hi,
>
> On Jan 26, 2010, at 8:51 PM, M?ns Rullg?rd <mans at mansr.com> wrote:
>> "Ronald S. Bultje" <rsbultje at gmail.com> writes:
>>> /** Sparse representation for the algebraic codebook (fixed) vector
>>> */
>>> typedef struct {
>>> int n;
>>> - int x[10];
>>> - float y[10];
>>> + struct {
>>> + unsigned int single:1;
>>> + unsigned int x:31;
>>> + float y;
>>> + } pulses[10];
>>> int pitch_lag;
>>> float pitch_fac;
>>> } AMRFixed;
>>
>> Why the bit-fields? GCC often generates incredibly stupid code for
>> bit-fields.
>
> I'm hoping gcc is smarter than that?
Never underestimate the stupidity of gcc. Here's a quick test:
struct bf {
unsigned a:1;
unsigned b:31;
};
void foo(struct bf *p, int n, int a)
{
int i = 0;
do {
if (p[i].a)
p[i].b += a;
} while (++i < n);
}
This is what gcc does:
00000000 <foo>:
0: push {r4} ; (str r4, [sp, #-4]!)
4: mov ip, #0
8: mov r4, r2
c: ldrb r3, [r0]
10: add ip, ip, #1
14: tst r3, #1
18: ldrne r3, [r0]
1c: addne r2, r4, r3, lsr #1
20: bfine r3, r2, #1, #31
24: strne r3, [r0]
28: cmp ip, r1
2c: add r0, r0, #4
30: blt c <foo+0xc>
34: pop {r4}
38: bx lr
That's twice as much code as it needs to be.
This is how it should be done:
foo:
ldr r3, [r0], #4
tst r3, #1
add r3, r3, r2, lsl #1
strne r3, [r0, #-4]
subs r1, r1, #1
bne foo
bx lr
And this is what armcc does:
00000000 <foo>:
0: push {r4, r5, lr}
4: mov r3, #0
8: ldr r4, [r0, r3, lsl #2]
c: tst r4, #1
10: addne r4, r4, r2, lsl #1
14: strne r4, [r0, r3, lsl #2]
18: add r3, r3, #1
1c: cmp r3, r1
20: blt 8 <foo+0x8>
24: pop {r4, r5, pc}
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list