summaryrefslogtreecommitdiff
path: root/libavcodec/ra288.c
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2008-06-30 19:09:00 +0000
committerVitor Sessak <vitor1001@gmail.com>2008-06-30 19:09:00 +0000
commit6091357fc038553ecb836b58b2699470a0018074 (patch)
treed0eb1bf6f80c5ea0310af64de8f818e3e4843827 /libavcodec/ra288.c
parent285ea3e30ab7638eccf8f0b9e1bb0ef36a8e1be0 (diff)
Remove unpack() function, read the bitstream as needed
Originally committed as revision 14040 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ra288.c')
-rw-r--r--libavcodec/ra288.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index 4f77ada45b..5e6a1aeba3 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -37,23 +37,8 @@ typedef struct {
float lhist[10];
} Real288_internal;
-/* initial decode */
-static void unpack(unsigned short *tgt, const unsigned char *src,
- unsigned int len)
-{
- int i = 0;
- GetBitContext gb;
-
- init_get_bits(&gb, src, len * 8);
-
- while (get_bits_count(&gb) + 9 + (i&1) <= len*8) {
- tgt[i] = get_bits(&gb, 9 + (i&1));
- i++;
- }
-}
-
/* Decode and produce output */
-static void decode(Real288_internal *glob, unsigned int input)
+static void decode(Real288_internal *glob, int amp_coef, int cb_coef)
{
unsigned int x, y;
float f;
@@ -72,8 +57,8 @@ static void decode(Real288_internal *glob, unsigned int input)
glob->sb[x] = sum;
}
- f = amptable[input & 7];
- table = codetable + (input >> 3) * 5;
+ f = amptable[amp_coef];
+ table = codetable + cb_coef * 5;
/* convert log and do rms */
for (sum=32, x=10; x--; sum -= glob->pr2[x] * glob->lhist[x]);
@@ -225,13 +210,15 @@ static void * decode_block(AVCodecContext * avctx, const unsigned char *in,
{
int x, y;
Real288_internal *glob = avctx->priv_data;
- unsigned short int buffer[len];
+ GetBitContext gb;
- unpack(buffer, in, len);
+ init_get_bits(&gb, in, len * 8);
for (x=0; x < 32; x++) {
+ int amp_coef = get_bits(&gb, 3);
+ int cb_coef = get_bits(&gb, 6 + (x&1));
glob->phasep = (glob->phase = x & 7) * 5;
- decode(glob, buffer[x]);
+ decode(glob, amp_coef, cb_coef);
for (y=0; y<5; *(out++) = 8 * glob->output[glob->phasep+(y++)]);