Mercurial > libavcodec.hg
comparison ra288.c @ 7173:bc2fd265f52b libavcodec
Remove unpack() function, read the bitstream as needed
author | vitor |
---|---|
date | Mon, 30 Jun 2008 19:09:00 +0000 |
parents | 6a88b6f05ea4 |
children | 7c4589349c01 |
comparison
equal
deleted
inserted
replaced
7172:6a88b6f05ea4 | 7173:bc2fd265f52b |
---|---|
35 float st2a[38], st2b[11], st2[11]; | 35 float st2a[38], st2b[11], st2[11]; |
36 float sb[41]; | 36 float sb[41]; |
37 float lhist[10]; | 37 float lhist[10]; |
38 } Real288_internal; | 38 } Real288_internal; |
39 | 39 |
40 /* initial decode */ | |
41 static void unpack(unsigned short *tgt, const unsigned char *src, | |
42 unsigned int len) | |
43 { | |
44 int i = 0; | |
45 GetBitContext gb; | |
46 | |
47 init_get_bits(&gb, src, len * 8); | |
48 | |
49 while (get_bits_count(&gb) + 9 + (i&1) <= len*8) { | |
50 tgt[i] = get_bits(&gb, 9 + (i&1)); | |
51 i++; | |
52 } | |
53 } | |
54 | |
55 /* Decode and produce output */ | 40 /* Decode and produce output */ |
56 static void decode(Real288_internal *glob, unsigned int input) | 41 static void decode(Real288_internal *glob, int amp_coef, int cb_coef) |
57 { | 42 { |
58 unsigned int x, y; | 43 unsigned int x, y; |
59 float f; | 44 float f; |
60 double sum, sumsum; | 45 double sum, sumsum; |
61 float *p1, *p2; | 46 float *p1, *p2; |
70 for (sum=0, y=36; y--; sum -= (*(++p1))*(*(p2++))); | 55 for (sum=0, y=36; y--; sum -= (*(++p1))*(*(p2++))); |
71 | 56 |
72 glob->sb[x] = sum; | 57 glob->sb[x] = sum; |
73 } | 58 } |
74 | 59 |
75 f = amptable[input & 7]; | 60 f = amptable[amp_coef]; |
76 table = codetable + (input >> 3) * 5; | 61 table = codetable + cb_coef * 5; |
77 | 62 |
78 /* convert log and do rms */ | 63 /* convert log and do rms */ |
79 for (sum=32, x=10; x--; sum -= glob->pr2[x] * glob->lhist[x]); | 64 for (sum=32, x=10; x--; sum -= glob->pr2[x] * glob->lhist[x]); |
80 | 65 |
81 if (sum < 0) | 66 if (sum < 0) |
223 static void * decode_block(AVCodecContext * avctx, const unsigned char *in, | 208 static void * decode_block(AVCodecContext * avctx, const unsigned char *in, |
224 signed short int *out, unsigned len) | 209 signed short int *out, unsigned len) |
225 { | 210 { |
226 int x, y; | 211 int x, y; |
227 Real288_internal *glob = avctx->priv_data; | 212 Real288_internal *glob = avctx->priv_data; |
228 unsigned short int buffer[len]; | 213 GetBitContext gb; |
229 | 214 |
230 unpack(buffer, in, len); | 215 init_get_bits(&gb, in, len * 8); |
231 | 216 |
232 for (x=0; x < 32; x++) { | 217 for (x=0; x < 32; x++) { |
218 int amp_coef = get_bits(&gb, 3); | |
219 int cb_coef = get_bits(&gb, 6 + (x&1)); | |
233 glob->phasep = (glob->phase = x & 7) * 5; | 220 glob->phasep = (glob->phase = x & 7) * 5; |
234 decode(glob, buffer[x]); | 221 decode(glob, amp_coef, cb_coef); |
235 | 222 |
236 for (y=0; y<5; *(out++) = 8 * glob->output[glob->phasep+(y++)]); | 223 for (y=0; y<5; *(out++) = 8 * glob->output[glob->phasep+(y++)]); |
237 | 224 |
238 if (glob->phase == 3) | 225 if (glob->phase == 3) |
239 update(glob); | 226 update(glob); |