Commit b590950e authored by vitor's avatar vitor

Rewrite unpack() using the bitstream reader

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@14038 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 7953be53
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
*/ */
#include "avcodec.h" #include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
#include "bitstream.h"
#include "ra288.h" #include "ra288.h"
typedef struct { typedef struct {
...@@ -39,28 +41,15 @@ typedef struct { ...@@ -39,28 +41,15 @@ typedef struct {
static void unpack(unsigned short *tgt, const unsigned char *src, static void unpack(unsigned short *tgt, const unsigned char *src,
unsigned int len) unsigned int len)
{ {
int x, y, z; int i = 0;
int n, temp; GetBitContext gb;
int buffer[len];
for (x=0; x < len; tgt[x++] = 0) init_get_bits(&gb, src, len * 8);
buffer[x] = 9 + (x & 1);
for (x=y=z=0; x < len/*was 38*/; x++) { while (get_bits_count(&gb) + 9 + (i&1) <= len*8) {
n = buffer[y] - z; tgt[i] = get_bits(&gb, 9 + (i&1));
temp = src[x]; i++;
}
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;
}
} }
/* Decode and produce output */ /* Decode and produce output */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment