Mercurial > mplayer.hg
annotate mp3lib/layer1.c @ 15459:ae92bce4e6aa
German man page review part II (finishes "PLAYER-SPEZIFISCHE OPTIONEN")
author | kraymer |
---|---|
date | Sat, 14 May 2005 12:44:30 +0000 |
parents | 07e7a572bd84 |
children | 0783dd397f74 |
rev | line source |
---|---|
15167
07e7a572bd84
Mark modified imported files as such to comply with (L)GPL ¡ø2a.
diego
parents:
15103
diff
changeset
|
1 /* |
07e7a572bd84
Mark modified imported files as such to comply with (L)GPL ¡ø2a.
diego
parents:
15103
diff
changeset
|
2 * Modified for use with MPlayer, for details see the CVS changelog at |
07e7a572bd84
Mark modified imported files as such to comply with (L)GPL ¡ø2a.
diego
parents:
15103
diff
changeset
|
3 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
07e7a572bd84
Mark modified imported files as such to comply with (L)GPL ¡ø2a.
diego
parents:
15103
diff
changeset
|
4 * $Id$ |
07e7a572bd84
Mark modified imported files as such to comply with (L)GPL ¡ø2a.
diego
parents:
15103
diff
changeset
|
5 */ |
07e7a572bd84
Mark modified imported files as such to comply with (L)GPL ¡ø2a.
diego
parents:
15103
diff
changeset
|
6 |
10468 | 7 /* |
8 * Mpeg Layer-1 audio decoder | |
9 * -------------------------- | |
10 * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README' | |
11 * near unoptimzed ... | |
12 * | |
13 * may have a few bugs after last optimization ... | |
14 * | |
15 */ | |
16 | |
17 //#include "mpg123.h" | |
18 | |
19 static void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],struct frame *fr) | |
20 { | |
21 unsigned int *ba=balloc; | |
22 unsigned int *sca = (unsigned int *) scale_index; | |
23 | |
15103 | 24 if(fr->stereo == 2) { |
10468 | 25 int i; |
26 int jsbound = fr->jsbound; | |
27 for (i=0;i<jsbound;i++) { | |
28 *ba++ = getbits(4); | |
29 *ba++ = getbits(4); | |
30 } | |
31 for (i=jsbound;i<SBLIMIT;i++) | |
32 *ba++ = getbits(4); | |
33 | |
34 ba = balloc; | |
35 | |
36 for (i=0;i<jsbound;i++) { | |
37 if ((*ba++)) | |
38 *sca++ = getbits(6); | |
39 if ((*ba++)) | |
40 *sca++ = getbits(6); | |
41 } | |
42 for (i=jsbound;i<SBLIMIT;i++) | |
43 if ((*ba++)) { | |
44 *sca++ = getbits(6); | |
45 *sca++ = getbits(6); | |
46 } | |
47 } | |
48 else { | |
49 int i; | |
50 for (i=0;i<SBLIMIT;i++) | |
51 *ba++ = getbits(4); | |
52 ba = balloc; | |
53 for (i=0;i<SBLIMIT;i++) | |
54 if ((*ba++)) | |
55 *sca++ = getbits(6); | |
56 } | |
57 } | |
58 | |
59 static void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT], | |
60 unsigned int scale_index[2][SBLIMIT],struct frame *fr) | |
61 { | |
62 int i,n; | |
63 int smpb[2*SBLIMIT]; /* values: 0-65535 */ | |
64 int *sample; | |
65 register unsigned int *ba; | |
66 register unsigned int *sca = (unsigned int *) scale_index; | |
67 | |
15103 | 68 if(fr->stereo == 2) { |
10468 | 69 int jsbound = fr->jsbound; |
70 register real *f0 = fraction[0]; | |
71 register real *f1 = fraction[1]; | |
72 ba = balloc; | |
73 for (sample=smpb,i=0;i<jsbound;i++) { | |
74 if ((n = *ba++)) | |
75 *sample++ = getbits(n+1); | |
76 if ((n = *ba++)) | |
77 *sample++ = getbits(n+1); | |
78 } | |
79 for (i=jsbound;i<SBLIMIT;i++) | |
80 if ((n = *ba++)) | |
81 *sample++ = getbits(n+1); | |
82 | |
83 ba = balloc; | |
84 for (sample=smpb,i=0;i<jsbound;i++) { | |
85 if((n=*ba++)) | |
86 *f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; | |
87 else | |
88 *f0++ = 0.0; | |
89 if((n=*ba++)) | |
90 *f1++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; | |
91 else | |
92 *f1++ = 0.0; | |
93 } | |
94 for (i=jsbound;i<SBLIMIT;i++) { | |
95 if ((n=*ba++)) { | |
96 real samp = ( ((-1)<<n) + (*sample++) + 1); | |
97 *f0++ = samp * muls[n+1][*sca++]; | |
98 *f1++ = samp * muls[n+1][*sca++]; | |
99 } | |
100 else | |
101 *f0++ = *f1++ = 0.0; | |
102 } | |
103 for(i=fr->down_sample_sblimit;i<32;i++) | |
104 fraction[0][i] = fraction[1][i] = 0.0; | |
105 } | |
106 else { | |
107 register real *f0 = fraction[0]; | |
108 ba = balloc; | |
109 for (sample=smpb,i=0;i<SBLIMIT;i++) | |
110 if ((n = *ba++)) | |
111 *sample++ = getbits(n+1); | |
112 ba = balloc; | |
113 for (sample=smpb,i=0;i<SBLIMIT;i++) { | |
114 if((n=*ba++)) | |
115 *f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; | |
116 else | |
117 *f0++ = 0.0; | |
118 } | |
119 for(i=fr->down_sample_sblimit;i<32;i++) | |
120 fraction[0][i] = 0.0; | |
121 } | |
122 } | |
123 | |
124 static int do_layer1(struct frame *fr,int single) | |
125 { | |
126 int clip=0; | |
127 int i,stereo = fr->stereo; | |
128 unsigned int balloc[2*SBLIMIT]; | |
129 unsigned int scale_index[2][SBLIMIT]; | |
130 real fraction[2][SBLIMIT]; | |
131 // int single = fr->single; | |
132 | |
133 // printf("do_layer1(0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X )\n", | |
134 // wordpointer[0],wordpointer[1],wordpointer[2],wordpointer[3],wordpointer[4],wordpointer[5],wordpointer[6],wordpointer[7]); | |
135 | |
136 fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? | |
137 (fr->mode_ext<<2)+4 : 32; | |
138 | |
139 if(stereo == 1 || single == 3) | |
140 single = 0; | |
141 | |
142 I_step_one(balloc,scale_index,fr); | |
143 | |
144 for (i=0;i<SCALE_BLOCK;i++) | |
145 { | |
146 I_step_two(fraction,balloc,scale_index,fr); | |
147 | |
148 if(single >= 0) | |
149 { | |
150 clip += (fr->synth_mono)( (real *) fraction[single],pcm_sample,&pcm_point); | |
151 } | |
152 else { | |
153 int p1 = pcm_point; | |
154 clip += (fr->synth)( (real *) fraction[0],0,pcm_sample,&p1); | |
155 clip += (fr->synth)( (real *) fraction[1],1,pcm_sample,&pcm_point); | |
156 } | |
157 | |
158 } | |
159 | |
160 return clip; | |
161 } | |
162 | |
163 |