Mercurial > mplayer.hg
annotate liba52/resample_c.c @ 3951:50be9c235764
do not hide cursur if play at rootwin. based on patch by Tomas Konir <moje@molly.vabo.cz>
author | arpi |
---|---|
date | Wed, 02 Jan 2002 18:41:25 +0000 |
parents | ef32c8bdee81 |
children | faf5af8e5481 |
rev | line source |
---|---|
3909 | 1 // this code is based on a52dec/libao/audio_out_oss.c |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
2 |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
3 static inline int16_t convert (int32_t i) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
4 { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
5 if (i > 0x43c07fff) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
6 return 32767; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
7 else if (i < 0x43bf8000) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
8 return -32768; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
9 else |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
10 return i - 0x43c00000; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
11 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
12 |
3909 | 13 static int a52_resample_MONO_to_5_C(float * _f, int16_t * s16){ |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
14 int i; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
15 int32_t * f = (int32_t *) _f; |
3626 | 16 for (i = 0; i < 256; i++) { |
17 s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0; | |
18 s16[5*i+4] = convert (f[i]); | |
19 } | |
3909 | 20 return 5*256; |
21 } | |
22 | |
23 static int a52_resample_STEREO_to_2_C(float * _f, int16_t * s16){ | |
24 int i; | |
25 int32_t * f = (int32_t *) _f; | |
3626 | 26 for (i = 0; i < 256; i++) { |
27 s16[2*i] = convert (f[i]); | |
28 s16[2*i+1] = convert (f[i+256]); | |
29 } | |
3909 | 30 return 2*256; |
31 } | |
32 | |
33 static int a52_resample_3F_to_5_C(float * _f, int16_t * s16){ | |
34 int i; | |
35 int32_t * f = (int32_t *) _f; | |
3626 | 36 for (i = 0; i < 256; i++) { |
37 s16[5*i] = convert (f[i]); | |
38 s16[5*i+1] = convert (f[i+512]); | |
39 s16[5*i+2] = s16[5*i+3] = 0; | |
40 s16[5*i+4] = convert (f[i+256]); | |
41 } | |
3909 | 42 return 5*256; |
43 } | |
44 | |
45 static int a52_resample_2F_2R_to_4_C(float * _f, int16_t * s16){ | |
46 int i; | |
47 int32_t * f = (int32_t *) _f; | |
3626 | 48 for (i = 0; i < 256; i++) { |
49 s16[4*i] = convert (f[i]); | |
50 s16[4*i+1] = convert (f[i+256]); | |
51 s16[4*i+2] = convert (f[i+512]); | |
52 s16[4*i+3] = convert (f[i+768]); | |
53 } | |
3909 | 54 return 4*256; |
55 } | |
56 | |
57 static int a52_resample_3F_2R_to_5_C(float * _f, int16_t * s16){ | |
58 int i; | |
59 int32_t * f = (int32_t *) _f; | |
3626 | 60 for (i = 0; i < 256; i++) { |
61 s16[5*i] = convert (f[i]); | |
62 s16[5*i+1] = convert (f[i+512]); | |
63 s16[5*i+2] = convert (f[i+768]); | |
64 s16[5*i+3] = convert (f[i+1024]); | |
65 s16[5*i+4] = convert (f[i+256]); | |
66 } | |
3909 | 67 return 5*256; |
68 } | |
69 | |
70 static int a52_resample_MONO_LFE_to_6_C(float * _f, int16_t * s16){ | |
71 int i; | |
72 int32_t * f = (int32_t *) _f; | |
3626 | 73 for (i = 0; i < 256; i++) { |
74 s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0; | |
75 s16[6*i+4] = convert (f[i+256]); | |
76 s16[6*i+5] = convert (f[i]); | |
77 } | |
3909 | 78 return 6*256; |
79 } | |
80 | |
81 static int a52_resample_STEREO_LFE_to_6_C(float * _f, int16_t * s16){ | |
82 int i; | |
83 int32_t * f = (int32_t *) _f; | |
3626 | 84 for (i = 0; i < 256; i++) { |
85 s16[6*i] = convert (f[i+256]); | |
86 s16[6*i+1] = convert (f[i+512]); | |
87 s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0; | |
88 s16[6*i+5] = convert (f[i]); | |
89 } | |
3909 | 90 return 6*256; |
91 } | |
92 | |
93 static int a52_resample_3F_LFE_to_6_C(float * _f, int16_t * s16){ | |
94 int i; | |
95 int32_t * f = (int32_t *) _f; | |
3626 | 96 for (i = 0; i < 256; i++) { |
97 s16[6*i] = convert (f[i+256]); | |
98 s16[6*i+1] = convert (f[i+768]); | |
99 s16[6*i+2] = s16[6*i+3] = 0; | |
100 s16[6*i+4] = convert (f[i+512]); | |
101 s16[6*i+5] = convert (f[i]); | |
102 } | |
3909 | 103 return 6*256; |
104 } | |
105 | |
106 static int a52_resample_2F_2R_LFE_to_6_C(float * _f, int16_t * s16){ | |
107 int i; | |
108 int32_t * f = (int32_t *) _f; | |
3626 | 109 for (i = 0; i < 256; i++) { |
110 s16[6*i] = convert (f[i+256]); | |
111 s16[6*i+1] = convert (f[i+512]); | |
112 s16[6*i+2] = convert (f[i+768]); | |
113 s16[6*i+3] = convert (f[i+1024]); | |
114 s16[6*i+4] = 0; | |
115 s16[6*i+5] = convert (f[i]); | |
116 } | |
3909 | 117 return 6*256; |
118 } | |
119 | |
120 static int a52_resample_3F_2R_LFE_to_6_C(float * _f, int16_t * s16){ | |
121 int i; | |
122 int32_t * f = (int32_t *) _f; | |
3626 | 123 for (i = 0; i < 256; i++) { |
124 s16[6*i] = convert (f[i+256]); | |
125 s16[6*i+1] = convert (f[i+768]); | |
126 s16[6*i+2] = convert (f[i+1024]); | |
127 s16[6*i+3] = convert (f[i+1280]); | |
128 s16[6*i+4] = convert (f[i+512]); | |
129 s16[6*i+5] = convert (f[i]); | |
130 } | |
3909 | 131 return 6*256; |
3626 | 132 } |
133 | |
134 | |
3909 | 135 static void* a52_resample_C(int flags, int ch){ |
3626 | 136 switch (flags) { |
137 case A52_MONO: | |
3909 | 138 if(ch==5) return a52_resample_MONO_to_5_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
139 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
140 case A52_CHANNEL: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
141 case A52_STEREO: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
142 case A52_DOLBY: |
3909 | 143 if(ch==2) return a52_resample_STEREO_to_2_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
144 break; |
3909 | 145 case A52_3F: |
146 if(ch==5) return a52_resample_3F_to_5_C; | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
147 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
148 case A52_2F2R: |
3909 | 149 if(ch==4) return a52_resample_2F_2R_to_4_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
150 break; |
3909 | 151 case A52_3F2R: |
152 if(ch==5) return a52_resample_3F_2R_to_5_C; | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
153 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
154 case A52_MONO | A52_LFE: |
3909 | 155 if(ch==6) return a52_resample_MONO_LFE_to_6_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
156 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
157 case A52_CHANNEL | A52_LFE: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
158 case A52_STEREO | A52_LFE: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
159 case A52_DOLBY | A52_LFE: |
3909 | 160 if(ch==6) return a52_resample_STEREO_LFE_to_6_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
161 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
162 case A52_3F | A52_LFE: |
3909 | 163 if(ch==6) return a52_resample_3F_LFE_to_6_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
164 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
165 case A52_2F2R | A52_LFE: |
3909 | 166 if(ch==6) return a52_resample_2F_2R_LFE_to_6_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
167 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
168 case A52_3F2R | A52_LFE: |
3909 | 169 if(ch==6) return a52_resample_3F_2R_LFE_to_6_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
170 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
171 } |
3909 | 172 return NULL; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
173 } |