[FFmpeg-devel] rmdec.c: add SIPR codec try #2
Ronald S. Bultje
rsbultje
Tue Mar 17 17:01:41 CET 2009
Hi Kostya,
On Tue, Mar 17, 2009 at 10:28 AM, Kostya <kostya.shishkov at gmail.com> wrote:
> On Tue, Mar 17, 2009 at 09:29:39AM -0400, Ronald S. Bultje wrote:
>> + ? ? ? ? ? ? ? ? ? ?/* swap 4bit-nibbles of block 'i' with 'o' */
>> + ? ? ? ? ? ? ? ? ? ?for (j = 0; j < bs; j++, i++, o++) {
>> + ? ? ? ? ? ? ? ? ? ? ? ?int x = (buf[i >> 1] >> (4 * (i & 1))) & 0xF,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?y = (buf[o >> 1] >> (4 * (o & 1))) & 0xF;
> [style nit suppressed]
>> +
>> + ? ? ? ? ? ? ? ? ? ? ? ?buf[o >> 1] = (x << (4 * (o & 1))) |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?(buf[o >> 1] & (0xF << (4 * !(o & 1))));
>> + ? ? ? ? ? ? ? ? ? ? ? ?buf[i >> 1] = (y << (4 * (i & 1))) |
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?(buf[i >> 1] & (0xF << (4 * !(i & 1))));
>
> this is not very readable and the value is swapped twice.
> I think full swapping should be done at each iteration, probably
> with splitting for (i&1 == o&1) and (i&1 != o&1) cases
I'd prefer get_bits(), this is ideally suited for that. Can I seek in
GetBitContexts, or "get 4 bits at offset X"?
Ronald
More information about the ffmpeg-devel
mailing list