diff options
author | Vitor Sessak <vitor1001@gmail.com> | 2008-06-30 18:36:45 +0000 |
---|---|---|
committer | Vitor Sessak <vitor1001@gmail.com> | 2008-06-30 18:36:45 +0000 |
commit | a40b2c2a4b303135631f9e25c632c4ca2f3a3048 (patch) | |
tree | 82c05b88d0b9a86245d07796d78e9c5e8e9968fa /libavcodec/ra288.c | |
parent | e500315b1dd7654ec550b5fc013232b3567358e0 (diff) | |
download | ffmpeg-a40b2c2a4b303135631f9e25c632c4ca2f3a3048.tar.gz |
Rewrite unpack() using the bitstream reader
Originally committed as revision 14038 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ra288.c')
-rw-r--r-- | libavcodec/ra288.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index b4d632219c..831b34638f 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -20,6 +20,8 @@ */ #include "avcodec.h" +#define ALT_BITSTREAM_READER_LE +#include "bitstream.h" #include "ra288.h" typedef struct { @@ -39,28 +41,15 @@ typedef struct { static void unpack(unsigned short *tgt, const unsigned char *src, unsigned int len) { - int x, y, z; - int n, temp; - int buffer[len]; + int i = 0; + GetBitContext gb; - for (x=0; x < len; tgt[x++] = 0) - buffer[x] = 9 + (x & 1); + init_get_bits(&gb, src, len * 8); - for (x=y=z=0; x < len/*was 38*/; x++) { - n = buffer[y] - z; - temp = src[x]; - - if (n < 8) - temp &= 255 >> (8 - n); - - tgt[y] += temp << z; - - if (n <= 8) { - tgt[++y] += src[x] >> n; - z = 8 - n; - } else - z += 8; - } + while (get_bits_count(&gb) + 9 + (i&1) <= len*8) { + tgt[i] = get_bits(&gb, 9 + (i&1)); + i++; + } } /* Decode and produce output */ |