Mercurial > mplayer.hg
annotate mp3lib/layer1.c @ 34120:5feea1437279
Support ASP by QNAP Systems.
author | cehoyos |
---|---|
date | Sun, 16 Oct 2011 11:48:05 +0000 |
parents | 0ad2da052b2e |
children |
rev | line source |
---|---|
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
23464
diff
changeset
|
1 /* |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
23464
diff
changeset
|
2 * Mpeg Layer-1 audio decoder |
10468 | 3 * -------------------------- |
4 * copyright (c) 1995 by Michael Hipp, All rights reserved. See also 'README' | |
5 * near unoptimzed ... | |
6 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
23464
diff
changeset
|
7 * may have a few bugs after last optimization ... |
10468 | 8 * |
9 */ | |
10 | |
19265 | 11 /* |
12 * Modified for use with MPlayer, for details see the changelog at | |
13 * http://svn.mplayerhq.hu/mplayer/trunk/ | |
14 * $Id$ | |
15 * | |
16 * The above-mentioned README file has the following to say about licensing: | |
17 * | |
18 * COPYING: you may use this source under LGPL terms! | |
19 */ | |
20 | |
30167
347d152a5cfa
Refactor real --> float #define to a typedef in a common header.
diego
parents:
29263
diff
changeset
|
21 #include "mpg123.h" |
10468 | 22 |
23 static void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],struct frame *fr) | |
24 { | |
25 unsigned int *ba=balloc; | |
26 unsigned int *sca = (unsigned int *) scale_index; | |
27 | |
15103 | 28 if(fr->stereo == 2) { |
10468 | 29 int i; |
30 int jsbound = fr->jsbound; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
23464
diff
changeset
|
31 for (i=0;i<jsbound;i++) { |
10468 | 32 *ba++ = getbits(4); |
33 *ba++ = getbits(4); | |
34 } | |
35 for (i=jsbound;i<SBLIMIT;i++) | |
36 *ba++ = getbits(4); | |
37 | |
38 ba = balloc; | |
39 | |
40 for (i=0;i<jsbound;i++) { | |
41 if ((*ba++)) | |
42 *sca++ = getbits(6); | |
43 if ((*ba++)) | |
44 *sca++ = getbits(6); | |
45 } | |
46 for (i=jsbound;i<SBLIMIT;i++) | |
47 if ((*ba++)) { | |
48 *sca++ = getbits(6); | |
49 *sca++ = getbits(6); | |
50 } | |
51 } | |
52 else { | |
53 int i; | |
54 for (i=0;i<SBLIMIT;i++) | |
55 *ba++ = getbits(4); | |
56 ba = balloc; | |
57 for (i=0;i<SBLIMIT;i++) | |
58 if ((*ba++)) | |
59 *sca++ = getbits(6); | |
60 } | |
61 } | |
62 | |
63 static void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT], | |
30990 | 64 unsigned int scale_index[2][SBLIMIT],struct frame *fr) |
10468 | 65 { |
66 int i,n; | |
67 int smpb[2*SBLIMIT]; /* values: 0-65535 */ | |
68 int *sample; | |
69 register unsigned int *ba; | |
70 register unsigned int *sca = (unsigned int *) scale_index; | |
71 | |
15103 | 72 if(fr->stereo == 2) { |
10468 | 73 int jsbound = fr->jsbound; |
74 register real *f0 = fraction[0]; | |
75 register real *f1 = fraction[1]; | |
76 ba = balloc; | |
77 for (sample=smpb,i=0;i<jsbound;i++) { | |
78 if ((n = *ba++)) | |
79 *sample++ = getbits(n+1); | |
80 if ((n = *ba++)) | |
81 *sample++ = getbits(n+1); | |
82 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
23464
diff
changeset
|
83 for (i=jsbound;i<SBLIMIT;i++) |
10468 | 84 if ((n = *ba++)) |
85 *sample++ = getbits(n+1); | |
86 | |
87 ba = balloc; | |
88 for (sample=smpb,i=0;i<jsbound;i++) { | |
89 if((n=*ba++)) | |
90 *f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; | |
91 else | |
92 *f0++ = 0.0; | |
93 if((n=*ba++)) | |
94 *f1++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; | |
95 else | |
96 *f1++ = 0.0; | |
97 } | |
98 for (i=jsbound;i<SBLIMIT;i++) { | |
99 if ((n=*ba++)) { | |
100 real samp = ( ((-1)<<n) + (*sample++) + 1); | |
101 *f0++ = samp * muls[n+1][*sca++]; | |
102 *f1++ = samp * muls[n+1][*sca++]; | |
103 } | |
104 else | |
105 *f0++ = *f1++ = 0.0; | |
106 } | |
107 for(i=fr->down_sample_sblimit;i<32;i++) | |
108 fraction[0][i] = fraction[1][i] = 0.0; | |
109 } | |
110 else { | |
111 register real *f0 = fraction[0]; | |
112 ba = balloc; | |
113 for (sample=smpb,i=0;i<SBLIMIT;i++) | |
114 if ((n = *ba++)) | |
115 *sample++ = getbits(n+1); | |
116 ba = balloc; | |
117 for (sample=smpb,i=0;i<SBLIMIT;i++) { | |
118 if((n=*ba++)) | |
119 *f0++ = (real) ( ((-1)<<n) + (*sample++) + 1) * muls[n+1][*sca++]; | |
120 else | |
121 *f0++ = 0.0; | |
122 } | |
123 for(i=fr->down_sample_sblimit;i<32;i++) | |
124 fraction[0][i] = 0.0; | |
125 } | |
126 } | |
127 | |
128 static int do_layer1(struct frame *fr,int single) | |
129 { | |
130 int clip=0; | |
131 int i,stereo = fr->stereo; | |
132 unsigned int balloc[2*SBLIMIT]; | |
133 unsigned int scale_index[2][SBLIMIT]; | |
23464
1b1fdac4a68c
Align output pointer so that we can use movaps instead of movups in dct64_sse;
zuxy
parents:
19265
diff
changeset
|
134 DECLARE_ALIGNED(16, real, fraction[2][SBLIMIT]); |
10468 | 135 // int single = fr->single; |
136 | |
137 // printf("do_layer1(0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X )\n", | |
138 // wordpointer[0],wordpointer[1],wordpointer[2],wordpointer[3],wordpointer[4],wordpointer[5],wordpointer[6],wordpointer[7]); | |
139 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
23464
diff
changeset
|
140 fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? |
10468 | 141 (fr->mode_ext<<2)+4 : 32; |
142 | |
143 if(stereo == 1 || single == 3) | |
144 single = 0; | |
145 | |
146 I_step_one(balloc,scale_index,fr); | |
147 | |
148 for (i=0;i<SCALE_BLOCK;i++) | |
149 { | |
150 I_step_two(fraction,balloc,scale_index,fr); | |
151 | |
152 if(single >= 0) | |
153 { | |
154 clip += (fr->synth_mono)( (real *) fraction[single],pcm_sample,&pcm_point); | |
155 } | |
156 else { | |
157 int p1 = pcm_point; | |
158 clip += (fr->synth)( (real *) fraction[0],0,pcm_sample,&p1); | |
159 clip += (fr->synth)( (real *) fraction[1],1,pcm_sample,&pcm_point); | |
160 } | |
161 | |
162 } | |
163 | |
164 return clip; | |
165 } |