Mercurial > mplayer.hg
annotate liba52/resample_c.c @ 30603:c5d8b7640b7d
Call mpcodecs_config_vo with the proper image format for dmo and dshow codecs.
author | reimar |
---|---|
date | Thu, 18 Feb 2010 22:28:55 +0000 |
parents | 170fc6d9dfa1 |
children |
rev | line source |
---|---|
25483 | 1 /* |
2 * resample_c.c | |
3 * Copyright (C) 2001 Árpád Gereöffy | |
4 * | |
5 * This file is part of a52dec, a free ATSC A-52 stream decoder. | |
6 * See http://liba52.sourceforge.net/ for updates. | |
7 * | |
8 * File added for use with MPlayer and not part of original a52dec. | |
9 * | |
10 * a52dec is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * a52dec is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
24 | |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
25 static inline int16_t convert (int32_t i) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
26 { |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
27 if (i > 0x43c07fff) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
28 return 32767; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
29 else if (i < 0x43bf8000) |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
30 return -32768; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
31 else |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
32 return i - 0x43c00000; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
33 } |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
34 |
3909 | 35 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
|
36 int i; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
37 int32_t * f = (int32_t *) _f; |
3626 | 38 for (i = 0; i < 256; i++) { |
39 s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0; | |
40 s16[5*i+4] = convert (f[i]); | |
41 } | |
3909 | 42 return 5*256; |
43 } | |
44 | |
3967 | 45 static int a52_resample_MONO_to_1_C(float * _f, int16_t * s16){ |
46 int i; | |
47 int32_t * f = (int32_t *) _f; | |
48 for (i = 0; i < 256; i++) { | |
49 s16[i] = convert (f[i]); | |
50 } | |
51 return 1*256; | |
52 } | |
53 | |
3909 | 54 static int a52_resample_STEREO_to_2_C(float * _f, int16_t * s16){ |
55 int i; | |
56 int32_t * f = (int32_t *) _f; | |
3626 | 57 for (i = 0; i < 256; i++) { |
58 s16[2*i] = convert (f[i]); | |
59 s16[2*i+1] = convert (f[i+256]); | |
60 } | |
3909 | 61 return 2*256; |
62 } | |
63 | |
64 static int a52_resample_3F_to_5_C(float * _f, int16_t * s16){ | |
65 int i; | |
66 int32_t * f = (int32_t *) _f; | |
3626 | 67 for (i = 0; i < 256; i++) { |
68 s16[5*i] = convert (f[i]); | |
69 s16[5*i+1] = convert (f[i+512]); | |
70 s16[5*i+2] = s16[5*i+3] = 0; | |
71 s16[5*i+4] = convert (f[i+256]); | |
72 } | |
3909 | 73 return 5*256; |
74 } | |
75 | |
76 static int a52_resample_2F_2R_to_4_C(float * _f, int16_t * s16){ | |
77 int i; | |
78 int32_t * f = (int32_t *) _f; | |
3626 | 79 for (i = 0; i < 256; i++) { |
80 s16[4*i] = convert (f[i]); | |
81 s16[4*i+1] = convert (f[i+256]); | |
82 s16[4*i+2] = convert (f[i+512]); | |
83 s16[4*i+3] = convert (f[i+768]); | |
84 } | |
3909 | 85 return 4*256; |
86 } | |
87 | |
88 static int a52_resample_3F_2R_to_5_C(float * _f, int16_t * s16){ | |
89 int i; | |
90 int32_t * f = (int32_t *) _f; | |
3626 | 91 for (i = 0; i < 256; i++) { |
92 s16[5*i] = convert (f[i]); | |
93 s16[5*i+1] = convert (f[i+512]); | |
94 s16[5*i+2] = convert (f[i+768]); | |
95 s16[5*i+3] = convert (f[i+1024]); | |
96 s16[5*i+4] = convert (f[i+256]); | |
97 } | |
3909 | 98 return 5*256; |
99 } | |
100 | |
101 static int a52_resample_MONO_LFE_to_6_C(float * _f, int16_t * s16){ | |
102 int i; | |
103 int32_t * f = (int32_t *) _f; | |
3626 | 104 for (i = 0; i < 256; i++) { |
105 s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0; | |
106 s16[6*i+4] = convert (f[i+256]); | |
107 s16[6*i+5] = convert (f[i]); | |
108 } | |
3909 | 109 return 6*256; |
110 } | |
111 | |
112 static int a52_resample_STEREO_LFE_to_6_C(float * _f, int16_t * s16){ | |
113 int i; | |
114 int32_t * f = (int32_t *) _f; | |
3626 | 115 for (i = 0; i < 256; i++) { |
116 s16[6*i] = convert (f[i+256]); | |
117 s16[6*i+1] = convert (f[i+512]); | |
118 s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0; | |
119 s16[6*i+5] = convert (f[i]); | |
120 } | |
3909 | 121 return 6*256; |
122 } | |
123 | |
124 static int a52_resample_3F_LFE_to_6_C(float * _f, int16_t * s16){ | |
125 int i; | |
126 int32_t * f = (int32_t *) _f; | |
3626 | 127 for (i = 0; i < 256; i++) { |
128 s16[6*i] = convert (f[i+256]); | |
129 s16[6*i+1] = convert (f[i+768]); | |
130 s16[6*i+2] = s16[6*i+3] = 0; | |
131 s16[6*i+4] = convert (f[i+512]); | |
132 s16[6*i+5] = convert (f[i]); | |
133 } | |
3909 | 134 return 6*256; |
135 } | |
136 | |
137 static int a52_resample_2F_2R_LFE_to_6_C(float * _f, int16_t * s16){ | |
138 int i; | |
139 int32_t * f = (int32_t *) _f; | |
3626 | 140 for (i = 0; i < 256; i++) { |
141 s16[6*i] = convert (f[i+256]); | |
142 s16[6*i+1] = convert (f[i+512]); | |
143 s16[6*i+2] = convert (f[i+768]); | |
144 s16[6*i+3] = convert (f[i+1024]); | |
145 s16[6*i+4] = 0; | |
146 s16[6*i+5] = convert (f[i]); | |
147 } | |
3909 | 148 return 6*256; |
149 } | |
150 | |
151 static int a52_resample_3F_2R_LFE_to_6_C(float * _f, int16_t * s16){ | |
152 int i; | |
153 int32_t * f = (int32_t *) _f; | |
3626 | 154 for (i = 0; i < 256; i++) { |
155 s16[6*i] = convert (f[i+256]); | |
156 s16[6*i+1] = convert (f[i+768]); | |
157 s16[6*i+2] = convert (f[i+1024]); | |
158 s16[6*i+3] = convert (f[i+1280]); | |
159 s16[6*i+4] = convert (f[i+512]); | |
160 s16[6*i+5] = convert (f[i]); | |
161 } | |
3909 | 162 return 6*256; |
3626 | 163 } |
164 | |
165 | |
3909 | 166 static void* a52_resample_C(int flags, int ch){ |
3626 | 167 switch (flags) { |
168 case A52_MONO: | |
3909 | 169 if(ch==5) return a52_resample_MONO_to_5_C; |
3967 | 170 if(ch==1) return a52_resample_MONO_to_1_C; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
171 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
172 case A52_CHANNEL: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
173 case A52_STEREO: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
174 case A52_DOLBY: |
3909 | 175 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
|
176 break; |
3909 | 177 case A52_3F: |
178 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
|
179 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
180 case A52_2F2R: |
3909 | 181 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
|
182 break; |
3909 | 183 case A52_3F2R: |
184 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
|
185 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
186 case A52_MONO | A52_LFE: |
3909 | 187 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
|
188 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
189 case A52_CHANNEL | A52_LFE: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
190 case A52_STEREO | A52_LFE: |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
191 case A52_DOLBY | A52_LFE: |
3909 | 192 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
|
193 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
194 case A52_3F | A52_LFE: |
3909 | 195 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
|
196 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
197 case A52_2F2R | A52_LFE: |
3909 | 198 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
|
199 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
200 case A52_3F2R | A52_LFE: |
3909 | 201 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
|
202 break; |
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
203 } |
3909 | 204 return NULL; |
3412
21d65a4ae3c9
resample.c added - float->int conversion and channel ordering
arpi
parents:
diff
changeset
|
205 } |