[FFmpeg-devel] rmdec.c: add SIPR codec try #2
Ronald S. Bultje
rsbultje
Tue Mar 17 20:41:41 CET 2009
Hi,
On Tue, Mar 17, 2009 at 2:55 PM, Kostya <kostya.shishkov at gmail.com> wrote:
> On Tue, Mar 17, 2009 at 02:29:03PM -0400, Ronald S. Bultje wrote:
>> + ? ?for (n = 0; n < 38; n++) {
>
> It would be nice to comment where that came from.
> 38 unlike 16, 256, 1024 or 42 is not an obvious number.
Benjamin, any idea?
>> + ? ? ? ?int j;
>> + ? ? ? ?int i = bs * sipr_swaps[n][0];
>> + ? ? ? ?int o = bs * sipr_swaps[n][1];
>> + ? ? ? ?uint8_t *buf = ast->pkt.data;
>> +
>> +#define LOOP_ITER \
>> + ? ? ? ?for (j = 0; j < bs; j++, i++, o++) { \
>> + ? ? ? ? ? ?int mask1 = (i & 1) ? 0xF0 : 0x0F, \
>> + ? ? ? ? ? ? ? ?mask2 = (i & 1) ? 0x0F : 0xF0, \
>> + ? ? ? ? ? ? ? ?tmp = buf[i >> 1] & mask1;
>> +#define LOOP_END }
>> +
>> + ? ? ? ?/* swap 4bit-nibbles of block 'i' with 'o' */
>> + ? ? ? ?if (!((i ^ o) & 1)) LOOP_ITER {
>> + ? ? ? ? ? ?buf[i >> 1] = (buf[i >> 1] & mask2) | (buf[o >> 1] & mask1);
>> + ? ? ? ? ? ?buf[o >> 1] = (buf[o >> 1] & mask2) | tmp;
>> + ? ? ? ?} LOOP_END else if (i & 1) LOOP_ITER {
>> + ? ? ? ? ? ?buf[i >> 1] = (buf[i >> 1] & mask2) | ((buf[o >> 1] & mask2) << 4);
>> + ? ? ? ? ? ?buf[o >> 1] = (buf[o >> 1] & mask1) | (tmp >> 4);
>> + ? ? ? ?} LOOP_END else /* o & 1 */ LOOP_ITER {
>> + ? ? ? ? ? ?buf[i >> 1] = (buf[i >> 1] & mask2) | ((buf[o >> 1] & mask2) >> 4);
>> + ? ? ? ? ? ?buf[o >> 1] = (buf[o >> 1] & mask1) | (tmp << 4);
>> + ? ? ? ?} LOOP_END;
>
> Yes, that's horrible.
> Let's return to your original version and I'll try to optimize it in SVN.
Sorry. :-). /me no good at writing fast & simple code for complex stuff.
Ronald
More information about the ffmpeg-devel
mailing list