vdecode.c
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "vadpcm.h"
void
vdecodeframe(FILE *ifile, int *outp, int order, int ***coefTable)
{
int
optimalp,
scale,
maxlevel = (1<<(SAMPLEBITS-1))-1,
i,
j,
in_vec[FRAMESIZE],
ix[FRAMESIZE];
unsigned char
header,
c;
fread(&header, 1, 1, ifile);
scale = 1<<(header>>4);
optimalp = header & 0xf;
for (i=0; i<FRAMESIZE; i+=2){
fread(&c, 1, 1, ifile);
ix[i] = c>>4;
ix[i+1] = c & 0xf;
if (ix[i]<=maxlevel)
ix[i] = scale*ix[i];
else
ix[i] = -((1<<SAMPLEBITS) - ix[i])*scale;
if (ix[i+1]<=maxlevel)
ix[i+1] = scale*ix[i+1];
else
ix[i+1] = -((1<<SAMPLEBITS) - ix[i+1])*scale;
}
for (j=0; j<FRAMESIZE/VECTORSIZE; j++){
for (i=0; i<VECTORSIZE; i++)
in_vec[i+order] = ix[j*VECTORSIZE+i];
if (j==0){
for (i=0; i<order; i++)
in_vec[i] = outp[FRAMESIZE-order+i];
} else {
for (i=0; i<order; i++)
in_vec[i] = outp[j*VECTORSIZE-order+i];
}
for (i=0; i<VECTORSIZE; i++){
outp[i+j*VECTORSIZE] =
inner_product(VECTORSIZE+order, coefTable[optimalp][i], in_vec);
}
}
}