annotate Plugins/Input/mpg123/layer2.c @ 186:01babf2781bb trunk

[svn] Fileinfo dialog adjustment.
author nenolod
date Sun, 13 Nov 2005 18:14:56 -0800
parents f394090439df
children e39735f0b2f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
1 /*
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
2 * Mpeg Layer-2 audio decoder
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
3 * --------------------------
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
4 * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README'
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
5 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
6 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
7
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
8 #include <math.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
9 #include "audacious/output.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
10 #include "mpg123.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
11 #include "l2tables.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
12 #include "getbits.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
13
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
14 static int grp_3tab[32 * 3] = { 0, }; /* used: 27 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
15 static int grp_5tab[128 * 3] = { 0, }; /* used: 125 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
16 static int grp_9tab[1024 * 3] = { 0, }; /* used: 729 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
17
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
18 real mpg123_muls[27][64]; /* also used by layer 1 */
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
19
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
20 void mpg123_init_layer2(gboolean mmx)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
21 {
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
22 static double mulmul[27] = {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
23 0.0 , -2.0/3.0 , 2.0/3.0 ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
24 2.0/7.0 , 2.0/15.0 , 2.0/31.0, 2.0/63.0 , 2.0/127.0 , 2.0/255.0 ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
25 2.0/511.0 , 2.0/1023.0 , 2.0/2047.0 , 2.0/4095.0 , 2.0/8191.0 ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
26 2.0/16383.0 , 2.0/32767.0 , 2.0/65535.0 ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
27 -4.0/5.0 , -2.0/5.0 , 2.0/5.0, 4.0/5.0 ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
28 -8.0/9.0 , -4.0/9.0 , -2.0/9.0 , 2.0/9.0 , 4.0/9.0 , 8.0/9.0 };
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
29 static int base[3][9] = {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
30 { 1 , 0, 2 , } ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
31 { 17, 18, 0 , 19, 20 , } ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
32 { 21, 1, 22, 23, 0, 24, 25, 2, 26 } };
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
33 int i,j,k,l,len;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
34 real *table;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
35 static int tablen[3] = { 3 , 5 , 9 };
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
36 static int *itable,*tables[3] = { grp_3tab , grp_5tab , grp_9tab };
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
37 #ifdef REAL_IS_FIXED
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
38 const double twotothethird = pow((double)2.0, (double)1/3);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
39 #endif
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
40
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
41 for(i=0;i<3;i++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
42 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
43 itable = tables[i];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
44 len = tablen[i];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
45 for(j=0;j<len;j++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
46 for(k=0;k<len;k++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
47 for(l=0;l<len;l++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
48 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
49 *itable++ = base[i][l];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
50 *itable++ = base[i][k];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
51 *itable++ = base[i][j];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
52 }
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
53 }
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
54
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
55 for(k=0;k<27;k++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
56 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
57 double m=mulmul[k];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
58
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
59 table = mpg123_muls[k];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
60 for(j=3,i=0;i<63;i++,j--)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
61 *table = m * pow(2.0, (double) j / 3.0);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
62 *table++ = 0.0;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
63 }
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
64 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
65
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
66
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
67 void II_step_one(unsigned int *bit_alloc,int *scale,struct frame *fr)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
68 {
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
69 int stereo = fr->stereo-1;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
70 int sblimit = fr->II_sblimit;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
71 int jsbound = fr->jsbound;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
72 int sblimit2 = fr->II_sblimit<<stereo;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
73 struct al_table *alloc1 = fr->alloc;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
74 int i;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
75 static unsigned int scfsi_buf[64];
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
76 unsigned int *scfsi,*bita;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
77 int sc,step;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
78
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
79 bita = bit_alloc;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
80 if(stereo)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
81 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
82 for (i=jsbound;i;i--,alloc1+=(1<<step))
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
83 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
84 *bita++ = (char) mpg123_getbits(&bsi,step=alloc1->bits);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
85 *bita++ = (char) mpg123_getbits(&bsi,step);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
86 }
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
87 for (i=sblimit-jsbound;i;i--,alloc1+=(1<<step))
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
88 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
89 bita[0] = (char) mpg123_getbits(&bsi,step=alloc1->bits);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
90 bita[1] = bita[0];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
91 bita+=2;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
92 }
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
93 bita = bit_alloc;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
94 scfsi=scfsi_buf;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
95 for (i=sblimit2;i;i--)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
96 if (*bita++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
97 *scfsi++ = (char) mpg123_getbits_fast(&bsi,2);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
98 }
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
99 else /* mono */
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
100 {
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
101 for (i=sblimit;i;i--,alloc1+=(1<<step))
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
102 *bita++ = (char) mpg123_getbits(&bsi,step=alloc1->bits);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
103 bita = bit_alloc;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
104 scfsi=scfsi_buf;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
105 for (i=sblimit;i;i--)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
106 if (*bita++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
107 *scfsi++ = (char) mpg123_getbits_fast(&bsi,2);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
108 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
109
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
110 bita = bit_alloc;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
111 scfsi=scfsi_buf;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
112 for (i=sblimit2;i;i--)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
113 if (*bita++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
114 switch (*scfsi++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
115 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
116 case 0:
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
117 *scale++ = mpg123_getbits_fast(&bsi,6);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
118 *scale++ = mpg123_getbits_fast(&bsi,6);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
119 *scale++ = mpg123_getbits_fast(&bsi,6);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
120 break;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
121 case 1 :
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
122 *scale++ = sc = mpg123_getbits_fast(&bsi,6);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
123 *scale++ = sc;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
124 *scale++ = mpg123_getbits_fast(&bsi,6);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
125 break;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
126 case 2:
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
127 *scale++ = sc = mpg123_getbits_fast(&bsi,6);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
128 *scale++ = sc;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
129 *scale++ = sc;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
130 break;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
131 default: /* case 3 */
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
132 *scale++ = mpg123_getbits_fast(&bsi,6);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
133 *scale++ = sc = mpg123_getbits_fast(&bsi,6);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
134 *scale++ = sc;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
135 break;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
136 }
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
137
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
138 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
139
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
140 void II_step_two(unsigned int *bit_alloc,real fraction[2][4][SBLIMIT],int *scale,struct frame *fr,int x1)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
141 {
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
142 int i,j,k,ba;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
143 int stereo = fr->stereo;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
144 int sblimit = fr->II_sblimit;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
145 int jsbound = fr->jsbound;
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
146 struct al_table *alloc2,*alloc1 = fr->alloc;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
147 unsigned int *bita=bit_alloc;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
148 int d1,step;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
149
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
150 for (i=0;i<jsbound;i++,alloc1+=(1<<step))
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
151 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
152 step = alloc1->bits;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
153 for (j=0;j<stereo;j++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
154 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
155 if ( (ba=*bita++) )
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
156 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
157 k=(alloc2 = alloc1+ba)->bits;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
158 if( (d1=alloc2->d) < 0)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
159 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
160 real cm = mpg123_muls[k][scale[x1]];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
161 fraction[j][0][i] = ((real) ((int)mpg123_getbits(&bsi,k) + d1)) * cm;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
162 fraction[j][1][i] = ((real) ((int)mpg123_getbits(&bsi,k) + d1)) * cm;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
163 fraction[j][2][i] = ((real) ((int)mpg123_getbits(&bsi,k) + d1)) * cm;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
164 }
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
165 else
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
166 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
167 static int *table[] = { 0,0,0,grp_3tab,0,grp_5tab,0,0,0,grp_9tab };
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
168 unsigned int idx,*tab,m=scale[x1];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
169 idx = (unsigned int) mpg123_getbits(&bsi,k);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
170 tab = (unsigned int *) (table[d1] + idx + idx + idx);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
171 fraction[j][0][i] = mpg123_muls[*tab++][m];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
172 fraction[j][1][i] = mpg123_muls[*tab++][m];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
173 fraction[j][2][i] = mpg123_muls[*tab][m];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
174 }
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
175 scale+=3;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
176 }
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
177 else
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
178 fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
179 }
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
180 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
181
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
182 for (i=jsbound;i<sblimit;i++,alloc1+=(1<<step))
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
183 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
184 step = alloc1->bits;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
185 bita++; /* channel 1 and channel 2 bitalloc are the same */
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
186 if ( (ba=*bita++) )
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
187 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
188 k=(alloc2 = alloc1+ba)->bits;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
189 if( (d1=alloc2->d) < 0)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
190 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
191 real cm;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
192 cm = mpg123_muls[k][scale[x1+3]];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
193 fraction[1][0][i] = (fraction[0][0][i] = (real) ((int)mpg123_getbits(&bsi,k) + d1) ) * cm;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
194 fraction[1][1][i] = (fraction[0][1][i] = (real) ((int)mpg123_getbits(&bsi,k) + d1) ) * cm;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
195 fraction[1][2][i] = (fraction[0][2][i] = (real) ((int)mpg123_getbits(&bsi,k) + d1) ) * cm;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
196 cm = mpg123_muls[k][scale[x1]];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
197 fraction[0][0][i] *= cm; fraction[0][1][i] *= cm; fraction[0][2][i] *= cm;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
198 }
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
199 else
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
200 {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
201 static int *table[] = { 0,0,0,grp_3tab,0,grp_5tab,0,0,0,grp_9tab };
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
202 unsigned int idx,*tab,m1,m2;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
203 m1 = scale[x1]; m2 = scale[x1+3];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
204 idx = (unsigned int) mpg123_getbits(&bsi,k);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
205 tab = (unsigned int *) (table[d1] + idx + idx + idx);
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
206 fraction[0][0][i] = mpg123_muls[*tab][m1]; fraction[1][0][i] = mpg123_muls[*tab++][m2];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
207 fraction[0][1][i] = mpg123_muls[*tab][m1]; fraction[1][1][i] = mpg123_muls[*tab++][m2];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
208 fraction[0][2][i] = mpg123_muls[*tab][m1]; fraction[1][2][i] = mpg123_muls[*tab][m2];
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
209 }
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
210 scale+=6;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
211 }
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
212 else {
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
213 fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] =
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
214 fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = 0.0;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
215 }
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
216 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
217
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
218 if(sblimit > (fr->down_sample_sblimit) )
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
219 sblimit = fr->down_sample_sblimit;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
220
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
221 for(i=sblimit;i<SBLIMIT;i++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
222 for (j=0;j<stereo;j++)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
223 fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
224
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
225 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
226
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
227 static void II_select_table(struct frame *fr)
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
228 {
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
229 static int translate[3][2][16] =
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
230 { { { 0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0 } ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
231 { 0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0 } } ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
232 { { 0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0 } ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
233 { 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0 } } ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
234 { { 0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0 } ,
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
235 { 0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0 } } };
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
236
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
237 int table,sblim;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
238 static struct al_table *tables[5] =
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
239 { alloc_0, alloc_1, alloc_2, alloc_3 , alloc_4 };
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
240 static int sblims[5] = { 27 , 30 , 8, 12 , 30 };
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
241
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
242 if(fr->lsf)
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
243 table = 4;
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
244 else
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
245 table = translate[fr->sampling_frequency][2-fr->stereo][fr->bitrate_index];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
246 sblim = sblims[table];
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
247
127
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
248 fr->alloc = tables[table];
05d824e30afd [svn] Synchronize mpg123 code with mpg123-0.59s.mc3. This brings us superior accuracy to libMAD, apparently.
nenolod
parents: 61
diff changeset
249 fr->II_sblimit = sblim;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
250 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
251
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
252 int
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
253 mpg123_do_layer2(struct frame *fr)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
254 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
255 int i, j;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
256 int stereo = fr->stereo;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
257 real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
258 unsigned int bit_alloc[64];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
259 int scale[192];
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
260 int single = fr->single;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
261
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
262 II_select_table(fr);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
263 fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
264 (fr->mode_ext << 2) + 4 : fr->II_sblimit;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
265 if (fr->jsbound > fr->II_sblimit)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
266 fr->jsbound = fr->II_sblimit;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
267
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
268 if (stereo == 1 || single == 3)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
269 single = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
270
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
271 II_step_one(bit_alloc, scale, fr);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
272
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
273 for (i = 0; i < SCALE_BLOCK; i++) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
274 II_step_two(bit_alloc, fraction, scale, fr, i >> 2);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
275 for (j = 0; j < 3; j++) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
276 if (single >= 0) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
277 (fr->synth_mono) (fraction[single][j], mpg123_pcm_sample,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
278 &mpg123_pcm_point);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
279 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
280 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
281 int p1 = mpg123_pcm_point;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
282
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
283 (fr->synth) (fraction[0][j], 0, mpg123_pcm_sample, &p1);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
284 (fr->synth) (fraction[1][j], 1, mpg123_pcm_sample,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
285 &mpg123_pcm_point);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
286 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
287
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
288 /* if(mpg123_pcm_point >= audiobufsize)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
289 audio_flush(outmode,ai); */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
290 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
291 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
292 if (mpg123_info->output_audio && mpg123_info->jump_to_time == -1) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
293 produce_audio(mpg123_ip.output->written_time(),
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
294 mpg123_cfg.resolution ==
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
295 16 ? FMT_S16_NE : FMT_U8,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
296 mpg123_cfg.channels ==
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
297 2 ? fr->stereo : 1, mpg123_pcm_point,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
298 mpg123_pcm_sample, &mpg123_info->going);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
299 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
300
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
301 mpg123_pcm_point = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
302
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
303 return 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
304 }