annotate libmpcodecs/native/decode288.c @ 10624:cdfd4a43c406

I've juste found a bug which prevent to load a file whose name contain a quote ('). The menu simply execute a "loadfile '%p'" but when the %p is replaced by the actual value, quotes in it are not escaped ! Moreover, mp_input_parse_cmd contain some code to unescape strings but this code was placed after the string was copied in his final buffer. So this patch correct this issue. By Aurlien Jacobs
author albeu
date Fri, 15 Aug 2003 18:45:35 +0000
parents 597ad4eb02fc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10260
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
1 #include "common1428.h"
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
2 #include "decode288.h"
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
3 #include "tables288.h"
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
4
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
5 /* Initialize internal variable structure */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
6 Real_288 *init_288(void)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
7 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
8 Real_internal *glob;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
9
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
10 if ((glob=malloc(sizeof(Real_internal))))
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
11 memset(glob,0,sizeof(Real_internal));
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
12
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
13 return (Real_288 *)glob;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
14 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
15
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
16 /* Free internal variable structure */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
17 void free_288(Real_288 *global)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
18 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
19 if (!global) return;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
20 free(global);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
21 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
22
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
23 /* Unlike the 14.4 format, 28.8 blocks are interleaved */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
24 /* to dilute the effects of transmission errors */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
25 void deinterleave(unsigned char *in, unsigned char *out, unsigned int size)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
26 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
27 unsigned int x=0,y=0,z=0;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
28 if (size>=38) z=size-38;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
29 else return;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
30
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
31 while (x<=z)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
32 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
33 memcpy(out+y,in+x,38);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
34 x+=38;y+=456;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
35 if (y>z) y-=z;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
36 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
37 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
38
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
39 /* Decode a block (celp) */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
40 void decode_288(Real_288 *global, unsigned char *in, signed short int *out)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
41 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
42 int x,y;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
43 unsigned short int buffer[32];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
44 Real_internal *glob;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
45
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
46 if (!global) return;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
47 glob = (Real_internal *)global;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
48
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
49 unpack(buffer,in,32);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
50 for (x=0;x<32;x++)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
51 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
52 glob->phasep=(glob->phase=x&7)*5;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
53 decode(glob,buffer[x]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
54 for (y=0;y<5;*(out++)=8*glob->output[glob->phasep+(y++)]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
55 if (glob->phase==3) update(glob);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
56 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
57 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
58
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
59 /* initial decode */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
60 static void unpack(unsigned short *tgt, unsigned char *src, int len)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
61 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
62 int x,y,z;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
63 int n,temp;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
64 int buffer[38];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
65
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
66 for (x=0;x<len;tgt[x++]=0)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
67 buffer[x]=9+(x&1);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
68
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
69 for (x=y=z=0;x<38;x++) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
70 n=buffer[y]-z;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
71 temp=src[x];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
72 if (n<8) temp&=255>>(8-n);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
73 tgt[y]+=temp<<z;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
74 if (n<=8) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
75 tgt[++y]+=src[x]>>n;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
76 z=8-n;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
77 } else z+=8;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
78 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
79 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
80
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
81 static void update(Real_internal *glob)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
82 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
83 int x,y;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
84 float buffer1[40],temp1[37];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
85 float buffer2[8],temp2[11];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
86
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
87 for (x=0,y=glob->phasep+5;x<40;buffer1[x++]=glob->output[(y++)%40]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
88 co(36,40,35,buffer1,temp1,glob->st1a,glob->st1b,table1);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
89 if (pred(temp1,glob->st1,36))
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
90 colmult(glob->pr1,glob->st1,table1a,36);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
91
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
92 for (x=0,y=glob->phase+1;x<8;buffer2[x++]=glob->history[(y++)%8]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
93 co(10,8,20,buffer2,temp2,glob->st2a,glob->st2b,table2);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
94 if (pred(temp2,glob->st2,10))
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
95 colmult(glob->pr2,glob->st2,table2a,10);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
96 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
97
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
98 /* Decode and produce output */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
99 static void decode(Real_internal *glob, unsigned int input)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
100 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
101 unsigned int x,y;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
102 float f;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
103 double sum,sumsum;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
104 float *p1,*p2;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
105 float buffer[5];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
106 const float *table;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
107
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
108 for (x=36;x--;glob->sb[x+5]=glob->sb[x]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
109 for (x=5;x--;) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
110 p1=glob->sb+x;p2=glob->pr1;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
111 for (sum=0,y=36;y--;sum-=(*(++p1))*(*(p2++)));
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
112 glob->sb[x]=sum;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
113 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
114
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
115 f=amptable[input&7];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
116 table=codetable+(input>>3)*5;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
117
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
118 /* convert log and do rms */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
119 for (sum=32,x=10;x--;sum-=glob->pr2[x]*glob->lhist[x]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
120 if (sum<0) sum=0; else if (sum>60) sum=60;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
121
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
122 sumsum=exp(sum*0.1151292546497)*f; /* pow(10.0,sum/20)*f */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
123 for (sum=0,x=5;x--;) { buffer[x]=table[x]*sumsum; sum+=buffer[x]*buffer[x]; }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
124 if ((sum/=5)<1) sum=1;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
125
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
126 /* shift and store */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
127 for (x=10;--x;glob->lhist[x]=glob->lhist[x-1]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
128 *glob->lhist=glob->history[glob->phase]=10*log10(sum)-32;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
129
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
130 for (x=1;x<5;x++) for (y=x;y--;buffer[x]-=glob->pr1[x-y-1]*buffer[y]);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
131
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
132 /* output */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
133 for (x=0;x<5;x++) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
134 f=glob->sb[4-x]+buffer[x];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
135 if (f>4095) f=4095; else if (f<-4095) f=-4095;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
136 glob->output[glob->phasep+x]=glob->sb[4-x]=f;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
137 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
138 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
139
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
140 /* column multiply */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
141 static void colmult(float *tgt, float *m1, const float *m2, int n)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
142 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
143 while (n--)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
144 *(tgt++)=(*(m1++))*(*(m2++));
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
145 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
146
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
147 static int pred(float *in, float *tgt, int n)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
148 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
149 int x,y;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
150 float *p1,*p2;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
151 double f0,f1,f2;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
152 float temp;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
153
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
154 if (in[n]==0) return 0;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
155 if ((f0=*in)<=0) return 0;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
156
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
157 for (x=1;;x++) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
158 if (n<x) return 1;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
159
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
160 p1=in+x;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
161 p2=tgt;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
162 f1=*(p1--);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
163 for (y=x;--y;f1+=(*(p1--))*(*(p2++)));
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
164
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
165 p1=tgt+x-1;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
166 p2=tgt;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
167 *(p1--)=f2=-f1/f0;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
168 for (y=x>>1;y--;) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
169 temp=*p2+*p1*f2;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
170 *(p1--)+=*p2*f2;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
171 *(p2++)=temp;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
172 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
173 if ((f0+=f1*f2)<0) return 0;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
174 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
175 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
176
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
177 static void co(int n, int i, int j, float *in, float *out, float *st1, float *st2, const float *table)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
178 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
179 int a,b,c;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
180 unsigned int x;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
181 float *fp,*fp2;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
182 float buffer1[37];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
183 float buffer2[37];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
184 float work[111];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
185
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
186 /* rotate and multiply */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
187 c=(b=(a=n+i)+j)-i;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
188 fp=st1+i;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
189 for (x=0;x<b;x++) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
190 if (x==c) fp=in;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
191 work[x]=*(table++)*(*(st1++)=*(fp++));
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
192 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
193
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
194 prodsum(buffer1,work+n,i,n);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
195 prodsum(buffer2,work+a,j,n);
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
196
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
197 for (x=0;x<=n;x++) {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
198 *st2=*st2*(0.5625)+buffer1[x];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
199 out[x]=*(st2++)+buffer2[x];
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
200 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
201 *out*=1.00390625; /* to prevent clipping */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
202 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
203
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
204 /* product sum (lsf) */
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
205 static void prodsum(float *tgt, float *src, int len, int n)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
206 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
207 unsigned int x;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
208 float *p1,*p2;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
209 double sum;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
210
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
211 while (n>=0)
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
212 {
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
213 p1=(p2=src)-n;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
214 for (sum=0,x=len;x--;sum+=(*p1++)*(*p2++));
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
215 tgt[n--]=sum;
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
216 }
597ad4eb02fc RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.
rtognimp
parents:
diff changeset
217 }