comparison ra288.c @ 7171:9176fe6f17c9 libavcodec

Rewrite unpack() using the bitstream reader
author vitor
date Mon, 30 Jun 2008 18:36:45 +0000
parents f12513065d85
children 6a88b6f05ea4
comparison
equal deleted inserted replaced
7170:04da42c2b7b4 7171:9176fe6f17c9
18 * License along with FFmpeg; if not, write to the Free Software 18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21 21
22 #include "avcodec.h" 22 #include "avcodec.h"
23 #define ALT_BITSTREAM_READER_LE
24 #include "bitstream.h"
23 #include "ra288.h" 25 #include "ra288.h"
24 26
25 typedef struct { 27 typedef struct {
26 float history[8]; 28 float history[8];
27 float output[40]; 29 float output[40];
37 39
38 /* initial decode */ 40 /* initial decode */
39 static void unpack(unsigned short *tgt, const unsigned char *src, 41 static void unpack(unsigned short *tgt, const unsigned char *src,
40 unsigned int len) 42 unsigned int len)
41 { 43 {
42 int x, y, z; 44 int i = 0;
43 int n, temp; 45 GetBitContext gb;
44 int buffer[len]; 46
45 47 init_get_bits(&gb, src, len * 8);
46 for (x=0; x < len; tgt[x++] = 0) 48
47 buffer[x] = 9 + (x & 1); 49 while (get_bits_count(&gb) + 9 + (i&1) <= len*8) {
48 50 tgt[i] = get_bits(&gb, 9 + (i&1));
49 for (x=y=z=0; x < len/*was 38*/; x++) { 51 i++;
50 n = buffer[y] - z; 52 }
51 temp = src[x];
52
53 if (n < 8)
54 temp &= 255 >> (8 - n);
55
56 tgt[y] += temp << z;
57
58 if (n <= 8) {
59 tgt[++y] += src[x] >> n;
60 z = 8 - n;
61 } else
62 z += 8;
63 }
64 } 53 }
65 54
66 /* Decode and produce output */ 55 /* Decode and produce output */
67 static void decode(Real288_internal *glob, unsigned int input) 56 static void decode(Real288_internal *glob, unsigned int input)
68 { 57 {