4 #include "sample_cvt.h"
18 /* IMA ADPCM Stepsize table */
19 static const int IMAStep_size
[89] = {
20 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19,
21 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55,
22 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157,
23 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449,
24 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
25 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660,
26 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493,10442,
27 11487,12635,13899,15289,16818,18500,20350,22358,24633,27086,29794,
31 /* IMA4 ADPCM Codeword decode table */
32 static const int IMA4Codeword
[16] = {
33 1, 3, 5, 7, 9, 11, 13, 15,
34 -1,-3,-5,-7,-9,-11,-13,-15,
37 /* IMA4 ADPCM Step index adjust decode table */
38 static const int IMA4Index_adjust
[16] = {
39 -1,-1,-1,-1, 2, 4, 6, 8,
40 -1,-1,-1,-1, 2, 4, 6, 8
44 /* MSADPCM Adaption table */
45 static const int MSADPCMAdaption
[16] = {
46 230, 230, 230, 230, 307, 409, 512, 614,
47 768, 614, 512, 409, 307, 230, 230, 230
50 /* MSADPCM Adaption Coefficient tables */
51 static const int MSADPCMAdaptionCoeff
[7][2] = {
62 /* A quick'n'dirty lookup table to decode a muLaw-encoded byte sample into a
63 * signed 16-bit sample */
64 static const ALshort muLawDecompressionTable
[256] = {
65 -32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956,
66 -23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764,
67 -15996,-15484,-14972,-14460,-13948,-13436,-12924,-12412,
68 -11900,-11388,-10876,-10364, -9852, -9340, -8828, -8316,
69 -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140,
70 -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092,
71 -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004,
72 -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980,
73 -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436,
74 -1372, -1308, -1244, -1180, -1116, -1052, -988, -924,
75 -876, -844, -812, -780, -748, -716, -684, -652,
76 -620, -588, -556, -524, -492, -460, -428, -396,
77 -372, -356, -340, -324, -308, -292, -276, -260,
78 -244, -228, -212, -196, -180, -164, -148, -132,
79 -120, -112, -104, -96, -88, -80, -72, -64,
80 -56, -48, -40, -32, -24, -16, -8, 0,
81 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956,
82 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764,
83 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412,
84 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316,
85 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140,
86 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092,
87 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004,
88 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980,
89 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436,
90 1372, 1308, 1244, 1180, 1116, 1052, 988, 924,
91 876, 844, 812, 780, 748, 716, 684, 652,
92 620, 588, 556, 524, 492, 460, 428, 396,
93 372, 356, 340, 324, 308, 292, 276, 260,
94 244, 228, 212, 196, 180, 164, 148, 132,
95 120, 112, 104, 96, 88, 80, 72, 64,
96 56, 48, 40, 32, 24, 16, 8, 0
99 /* Values used when encoding a muLaw sample */
100 static const int muLawBias
= 0x84;
101 static const int muLawClip
= 32635;
102 static const char muLawCompressTable
[256] = {
103 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
104 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
105 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
106 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
107 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
108 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
109 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
110 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
111 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
112 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
113 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
114 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
115 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
116 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
117 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
118 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
122 /* A quick'n'dirty lookup table to decode an aLaw-encoded byte sample into a
123 * signed 16-bit sample */
124 static const ALshort aLawDecompressionTable
[256] = {
125 -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
126 -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
127 -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
128 -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
129 -22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944,
130 -30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136,
131 -11008,-10496,-12032,-11520, -8960, -8448, -9984, -9472,
132 -15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568,
133 -344, -328, -376, -360, -280, -264, -312, -296,
134 -472, -456, -504, -488, -408, -392, -440, -424,
135 -88, -72, -120, -104, -24, -8, -56, -40,
136 -216, -200, -248, -232, -152, -136, -184, -168,
137 -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
138 -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
139 -688, -656, -752, -720, -560, -528, -624, -592,
140 -944, -912, -1008, -976, -816, -784, -880, -848,
141 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
142 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
143 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
144 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
145 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
146 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
147 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
148 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
149 344, 328, 376, 360, 280, 264, 312, 296,
150 472, 456, 504, 488, 408, 392, 440, 424,
151 88, 72, 120, 104, 24, 8, 56, 40,
152 216, 200, 248, 232, 152, 136, 184, 168,
153 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
154 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
155 688, 656, 752, 720, 560, 528, 624, 592,
156 944, 912, 1008, 976, 816, 784, 880, 848
159 /* Values used when encoding an aLaw sample */
160 static const int aLawClip
= 32635;
161 static const char aLawCompressTable
[128] = {
162 1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
163 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
164 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
165 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
166 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
167 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
168 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
169 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
173 typedef ALubyte ALmulaw
;
174 typedef ALubyte ALalaw
;
175 typedef ALubyte ALima4
;
176 typedef ALubyte ALmsadpcm
;
180 static_assert(sizeof(ALbyte3
)==sizeof(ALbyte
[3]), "ALbyte3 size is not 3");
184 static_assert(sizeof(ALubyte3
)==sizeof(ALubyte
[3]), "ALubyte3 size is not 3");
186 static inline ALshort
DecodeMuLaw(ALmulaw val
)
187 { return muLawDecompressionTable
[val
]; }
189 static ALmulaw
EncodeMuLaw(ALshort val
)
191 ALint mant
, exp
, sign
;
193 sign
= (val
>>8) & 0x80;
196 /* -32768 doesn't properly negate on a short; it results in itself.
197 * So clamp to -32767 */
198 val
= maxi(val
, -32767);
202 val
= mini(val
, muLawClip
);
205 exp
= muLawCompressTable
[(val
>>7) & 0xff];
206 mant
= (val
>> (exp
+3)) & 0x0f;
208 return ~(sign
| (exp
<<4) | mant
);
211 static inline ALshort
DecodeALaw(ALalaw val
)
212 { return aLawDecompressionTable
[val
]; }
214 static ALalaw
EncodeALaw(ALshort val
)
216 ALint mant
, exp
, sign
;
218 sign
= ((~val
) >> 8) & 0x80;
221 val
= maxi(val
, -32767);
224 val
= mini(val
, aLawClip
);
228 exp
= aLawCompressTable
[(val
>>8) & 0x7f];
229 mant
= (val
>> (exp
+3)) & 0x0f;
237 return ((exp
<<4) | mant
) ^ (sign
^0x55);
240 static void DecodeIMA4Block(ALshort
*dst
, const ALima4
*src
, ALint numchans
, ALsizei align
)
242 ALint sample
[MAX_INPUT_CHANNELS
], index
[MAX_INPUT_CHANNELS
];
243 ALuint code
[MAX_INPUT_CHANNELS
];
246 for(c
= 0;c
< numchans
;c
++)
248 sample
[c
] = *(src
++);
249 sample
[c
] |= *(src
++) << 8;
250 sample
[c
] = (sample
[c
]^0x8000) - 32768;
252 index
[c
] |= *(src
++) << 8;
253 index
[c
] = (index
[c
]^0x8000) - 32768;
255 index
[c
] = clampi(index
[c
], 0, 88);
260 for(j
= 1;j
< align
;j
+= 8)
262 for(c
= 0;c
< numchans
;c
++)
265 code
[c
] |= *(src
++) << 8;
266 code
[c
] |= *(src
++) << 16;
267 code
[c
] |= *(src
++) << 24;
272 for(c
= 0;c
< numchans
;c
++)
274 int nibble
= code
[c
]&0xf;
277 sample
[c
] += IMA4Codeword
[nibble
] * IMAStep_size
[index
[c
]] / 8;
278 sample
[c
] = clampi(sample
[c
], -32768, 32767);
280 index
[c
] += IMA4Index_adjust
[nibble
];
281 index
[c
] = clampi(index
[c
], 0, 88);
283 dst
[(j
+k
)*numchans
+ c
] = sample
[c
];
289 static void EncodeIMA4Block(ALima4
*dst
, const ALshort
*src
, ALint
*sample
, ALint
*index
, ALint numchans
, ALsizei align
)
293 for(c
= 0;c
< numchans
;c
++)
295 int diff
= src
[c
] - sample
[c
];
296 int step
= IMAStep_size
[index
[c
]];
306 diff
= mini(step
*2, diff
);
307 nibble
|= (diff
*8/step
- 1) / 2;
309 sample
[c
] += IMA4Codeword
[nibble
] * step
/ 8;
310 sample
[c
] = clampi(sample
[c
], -32768, 32767);
312 index
[c
] += IMA4Index_adjust
[nibble
];
313 index
[c
] = clampi(index
[c
], 0, 88);
315 *(dst
++) = sample
[c
] & 0xff;
316 *(dst
++) = (sample
[c
]>>8) & 0xff;
317 *(dst
++) = index
[c
] & 0xff;
318 *(dst
++) = (index
[c
]>>8) & 0xff;
321 for(j
= 1;j
< align
;j
+= 8)
323 for(c
= 0;c
< numchans
;c
++)
327 int diff
= src
[(j
+k
)*numchans
+ c
] - sample
[c
];
328 int step
= IMAStep_size
[index
[c
]];
338 diff
= mini(step
*2, diff
);
339 nibble
|= (diff
*8/step
- 1) / 2;
341 sample
[c
] += IMA4Codeword
[nibble
] * step
/ 8;
342 sample
[c
] = clampi(sample
[c
], -32768, 32767);
344 index
[c
] += IMA4Index_adjust
[nibble
];
345 index
[c
] = clampi(index
[c
], 0, 88);
347 if(!(k
&1)) *dst
= nibble
;
348 else *(dst
++) |= nibble
<<4;
355 static void DecodeMSADPCMBlock(ALshort
*dst
, const ALmsadpcm
*src
, ALint numchans
, ALsizei align
)
357 ALubyte blockpred
[MAX_INPUT_CHANNELS
];
358 ALint delta
[MAX_INPUT_CHANNELS
];
359 ALshort samples
[MAX_INPUT_CHANNELS
][2];
362 for(i
= 0;i
< numchans
;i
++)
364 blockpred
[i
] = *(src
++);
365 blockpred
[i
] = minu(blockpred
[i
], 6);
367 for(i
= 0;i
< numchans
;i
++)
370 delta
[i
] |= *(src
++) << 8;
371 delta
[i
] = (delta
[i
]^0x8000) - 0x8000;
373 for(i
= 0;i
< numchans
;i
++)
375 samples
[i
][0] = *(src
++);
376 samples
[i
][0] |= *(src
++) << 8;
377 samples
[i
][0] = (samples
[i
][0]^0x8000) - 0x8000;
379 for(i
= 0;i
< numchans
;i
++)
381 samples
[i
][1] = *(src
++);
382 samples
[i
][1] |= *(src
++) << 8;
383 samples
[i
][1] = (samples
[i
][1]^0x8000) - 0x8000;
386 /* Second sample is written first. */
387 for(i
= 0;i
< numchans
;i
++)
388 *(dst
++) = samples
[i
][1];
389 for(i
= 0;i
< numchans
;i
++)
390 *(dst
++) = samples
[i
][0];
392 for(j
= 2;j
< align
;j
++)
394 for(i
= 0;i
< numchans
;i
++)
396 const ALint num
= (j
*numchans
) + i
;
399 /* Read the nibble (first is in the upper bits). */
401 nibble
= (*src
>>4)&0x0f;
403 nibble
= (*(src
++))&0x0f;
405 pred
= (samples
[i
][0]*MSADPCMAdaptionCoeff
[blockpred
[i
]][0] +
406 samples
[i
][1]*MSADPCMAdaptionCoeff
[blockpred
[i
]][1]) / 256;
407 pred
+= ((nibble
^0x08) - 0x08) * delta
[i
];
408 pred
= clampi(pred
, -32768, 32767);
410 samples
[i
][1] = samples
[i
][0];
411 samples
[i
][0] = pred
;
413 delta
[i
] = (MSADPCMAdaption
[nibble
] * delta
[i
]) / 256;
414 delta
[i
] = maxi(16, delta
[i
]);
421 /* NOTE: This encoder is pretty dumb/simplistic. Some kind of pre-processing
422 * that tries to find the optimal block predictors would be nice, at least. A
423 * multi-pass method that can generate better deltas would be good, too. */
424 static void EncodeMSADPCMBlock(ALmsadpcm
*dst
, const ALshort
*src
, ALint
*sample
, ALint numchans
, ALsizei align
)
426 ALubyte blockpred
[MAX_INPUT_CHANNELS
];
427 ALint delta
[MAX_INPUT_CHANNELS
];
428 ALshort samples
[MAX_INPUT_CHANNELS
][2];
431 /* Block predictor */
432 for(i
= 0;i
< numchans
;i
++)
434 /* FIXME: Calculate something better. */
436 *(dst
++) = blockpred
[i
];
439 for(i
= 0;i
< numchans
;i
++)
442 *(dst
++) = (delta
[i
] ) & 0xff;
443 *(dst
++) = (delta
[i
]>>8) & 0xff;
445 /* Initial sample 1 */
446 for(i
= 0;i
< numchans
;i
++)
448 samples
[i
][0] = src
[1*numchans
+ i
];
449 *(dst
++) = (samples
[i
][0] ) & 0xff;
450 *(dst
++) = (samples
[i
][0]>>8) & 0xff;
452 /* Initial sample 2 */
453 for(i
= 0;i
< numchans
;i
++)
455 samples
[i
][1] = src
[i
];
456 *(dst
++) = (samples
[i
][1] ) & 0xff;
457 *(dst
++) = (samples
[i
][1]>>8) & 0xff;
460 for(j
= 2;j
< align
;j
++)
462 for(i
= 0;i
< numchans
;i
++)
464 const ALint num
= (j
*numchans
) + i
;
468 sample
[i
] = (samples
[i
][0]*MSADPCMAdaptionCoeff
[blockpred
[i
]][0] +
469 samples
[i
][1]*MSADPCMAdaptionCoeff
[blockpred
[i
]][1]) / 256;
471 nibble
= src
[num
] - sample
[i
];
475 bias
= -delta
[i
] / 2;
477 nibble
= (nibble
+ bias
) / delta
[i
];
478 nibble
= clampi(nibble
, -8, 7)&0x0f;
480 sample
[i
] += ((nibble
^0x08)-0x08) * delta
[i
];
481 sample
[i
] = clampi(sample
[i
], -32768, 32767);
483 samples
[i
][1] = samples
[i
][0];
484 samples
[i
][0] = sample
[i
];
486 delta
[i
] = (MSADPCMAdaption
[nibble
] * delta
[i
]) / 256;
487 delta
[i
] = maxi(16, delta
[i
]);
501 static inline ALint
DecodeByte3(ALbyte3 val
)
504 return (val
.b
[2]<<16) | (((ALubyte
)val
.b
[1])<<8) | ((ALubyte
)val
.b
[0]);
505 return (val
.b
[0]<<16) | (((ALubyte
)val
.b
[1])<<8) | ((ALubyte
)val
.b
[2]);
508 static inline ALbyte3
EncodeByte3(ALint val
)
512 ALbyte3 ret
= {{ val
, val
>>8, val
>>16 }};
517 ALbyte3 ret
= {{ val
>>16, val
>>8, val
}};
522 static inline ALint
DecodeUByte3(ALubyte3 val
)
525 return (val
.b
[2]<<16) | (val
.b
[1]<<8) | (val
.b
[0]);
526 return (val
.b
[0]<<16) | (val
.b
[1]<<8) | val
.b
[2];
529 static inline ALubyte3
EncodeUByte3(ALint val
)
533 ALubyte3 ret
= {{ val
, val
>>8, val
>>16 }};
538 ALubyte3 ret
= {{ val
>>16, val
>>8, val
}};
544 static inline ALbyte
Conv_ALbyte_ALbyte(ALbyte val
)
546 static inline ALbyte
Conv_ALbyte_ALubyte(ALubyte val
)
548 static inline ALbyte
Conv_ALbyte_ALshort(ALshort val
)
550 static inline ALbyte
Conv_ALbyte_ALushort(ALushort val
)
551 { return (val
>>8)-128; }
552 static inline ALbyte
Conv_ALbyte_ALint(ALint val
)
554 static inline ALbyte
Conv_ALbyte_ALuint(ALuint val
)
555 { return (val
>>24)-128; }
556 static inline ALbyte
Conv_ALbyte_ALfloat(ALfloat val
)
558 if(val
> 1.0f
) return 127;
559 if(val
< -1.0f
) return -128;
560 return (ALint
)(val
* 127.0f
);
562 static inline ALbyte
Conv_ALbyte_ALdouble(ALdouble val
)
564 if(val
> 1.0) return 127;
565 if(val
< -1.0) return -128;
566 return (ALint
)(val
* 127.0);
568 static inline ALbyte
Conv_ALbyte_ALmulaw(ALmulaw val
)
569 { return Conv_ALbyte_ALshort(DecodeMuLaw(val
)); }
570 static inline ALbyte
Conv_ALbyte_ALalaw(ALalaw val
)
571 { return Conv_ALbyte_ALshort(DecodeALaw(val
)); }
572 static inline ALbyte
Conv_ALbyte_ALbyte3(ALbyte3 val
)
573 { return DecodeByte3(val
)>>16; }
574 static inline ALbyte
Conv_ALbyte_ALubyte3(ALubyte3 val
)
575 { return (DecodeUByte3(val
)>>16)-128; }
577 static inline ALubyte
Conv_ALubyte_ALbyte(ALbyte val
)
579 static inline ALubyte
Conv_ALubyte_ALubyte(ALubyte val
)
581 static inline ALubyte
Conv_ALubyte_ALshort(ALshort val
)
582 { return (val
>>8)+128; }
583 static inline ALubyte
Conv_ALubyte_ALushort(ALushort val
)
585 static inline ALubyte
Conv_ALubyte_ALint(ALint val
)
586 { return (val
>>24)+128; }
587 static inline ALubyte
Conv_ALubyte_ALuint(ALuint val
)
589 static inline ALubyte
Conv_ALubyte_ALfloat(ALfloat val
)
591 if(val
> 1.0f
) return 255;
592 if(val
< -1.0f
) return 0;
593 return (ALint
)(val
* 127.0f
) + 128;
595 static inline ALubyte
Conv_ALubyte_ALdouble(ALdouble val
)
597 if(val
> 1.0) return 255;
598 if(val
< -1.0) return 0;
599 return (ALint
)(val
* 127.0) + 128;
601 static inline ALubyte
Conv_ALubyte_ALmulaw(ALmulaw val
)
602 { return Conv_ALubyte_ALshort(DecodeMuLaw(val
)); }
603 static inline ALubyte
Conv_ALubyte_ALalaw(ALalaw val
)
604 { return Conv_ALubyte_ALshort(DecodeALaw(val
)); }
605 static inline ALubyte
Conv_ALubyte_ALbyte3(ALbyte3 val
)
606 { return (DecodeByte3(val
)>>16)+128; }
607 static inline ALubyte
Conv_ALubyte_ALubyte3(ALubyte3 val
)
608 { return DecodeUByte3(val
)>>16; }
610 static inline ALshort
Conv_ALshort_ALbyte(ALbyte val
)
612 static inline ALshort
Conv_ALshort_ALubyte(ALubyte val
)
613 { return (val
-128)<<8; }
614 static inline ALshort
Conv_ALshort_ALshort(ALshort val
)
616 static inline ALshort
Conv_ALshort_ALushort(ALushort val
)
617 { return val
-32768; }
618 static inline ALshort
Conv_ALshort_ALint(ALint val
)
620 static inline ALshort
Conv_ALshort_ALuint(ALuint val
)
621 { return (val
>>16)-32768; }
622 static inline ALshort
Conv_ALshort_ALfloat(ALfloat val
)
624 if(val
> 1.0f
) return 32767;
625 if(val
< -1.0f
) return -32768;
626 return (ALint
)(val
* 32767.0f
);
628 static inline ALshort
Conv_ALshort_ALdouble(ALdouble val
)
630 if(val
> 1.0) return 32767;
631 if(val
< -1.0) return -32768;
632 return (ALint
)(val
* 32767.0);
634 static inline ALshort
Conv_ALshort_ALmulaw(ALmulaw val
)
635 { return Conv_ALshort_ALshort(DecodeMuLaw(val
)); }
636 static inline ALshort
Conv_ALshort_ALalaw(ALalaw val
)
637 { return Conv_ALshort_ALshort(DecodeALaw(val
)); }
638 static inline ALshort
Conv_ALshort_ALbyte3(ALbyte3 val
)
639 { return DecodeByte3(val
)>>8; }
640 static inline ALshort
Conv_ALshort_ALubyte3(ALubyte3 val
)
641 { return (DecodeUByte3(val
)>>8)-32768; }
643 static inline ALushort
Conv_ALushort_ALbyte(ALbyte val
)
644 { return (val
+128)<<8; }
645 static inline ALushort
Conv_ALushort_ALubyte(ALubyte val
)
647 static inline ALushort
Conv_ALushort_ALshort(ALshort val
)
648 { return val
+32768; }
649 static inline ALushort
Conv_ALushort_ALushort(ALushort val
)
651 static inline ALushort
Conv_ALushort_ALint(ALint val
)
652 { return (val
>>16)+32768; }
653 static inline ALushort
Conv_ALushort_ALuint(ALuint val
)
655 static inline ALushort
Conv_ALushort_ALfloat(ALfloat val
)
657 if(val
> 1.0f
) return 65535;
658 if(val
< -1.0f
) return 0;
659 return (ALint
)(val
* 32767.0f
) + 32768;
661 static inline ALushort
Conv_ALushort_ALdouble(ALdouble val
)
663 if(val
> 1.0) return 65535;
664 if(val
< -1.0) return 0;
665 return (ALint
)(val
* 32767.0) + 32768;
667 static inline ALushort
Conv_ALushort_ALmulaw(ALmulaw val
)
668 { return Conv_ALushort_ALshort(DecodeMuLaw(val
)); }
669 static inline ALushort
Conv_ALushort_ALalaw(ALalaw val
)
670 { return Conv_ALushort_ALshort(DecodeALaw(val
)); }
671 static inline ALushort
Conv_ALushort_ALbyte3(ALbyte3 val
)
672 { return (DecodeByte3(val
)>>8)+32768; }
673 static inline ALushort
Conv_ALushort_ALubyte3(ALubyte3 val
)
674 { return DecodeUByte3(val
)>>8; }
676 static inline ALint
Conv_ALint_ALbyte(ALbyte val
)
678 static inline ALint
Conv_ALint_ALubyte(ALubyte val
)
679 { return (val
-128)<<24; }
680 static inline ALint
Conv_ALint_ALshort(ALshort val
)
682 static inline ALint
Conv_ALint_ALushort(ALushort val
)
683 { return (val
-32768)<<16; }
684 static inline ALint
Conv_ALint_ALint(ALint val
)
686 static inline ALint
Conv_ALint_ALuint(ALuint val
)
687 { return val
-2147483648u; }
688 static inline ALint
Conv_ALint_ALfloat(ALfloat val
)
690 if(val
> 1.0f
) return 2147483647;
691 if(val
< -1.0f
) return -2147483647-1;
692 return (ALint
)(val
*16777215.0f
) << 7;
694 static inline ALint
Conv_ALint_ALdouble(ALdouble val
)
696 if(val
> 1.0) return 2147483647;
697 if(val
< -1.0) return -2147483647-1;
698 return (ALint
)(val
* 2147483647.0);
700 static inline ALint
Conv_ALint_ALmulaw(ALmulaw val
)
701 { return Conv_ALint_ALshort(DecodeMuLaw(val
)); }
702 static inline ALint
Conv_ALint_ALalaw(ALalaw val
)
703 { return Conv_ALint_ALshort(DecodeALaw(val
)); }
704 static inline ALint
Conv_ALint_ALbyte3(ALbyte3 val
)
705 { return DecodeByte3(val
)<<8; }
706 static inline ALint
Conv_ALint_ALubyte3(ALubyte3 val
)
707 { return (DecodeUByte3(val
)-8388608)<<8; }
709 static inline ALuint
Conv_ALuint_ALbyte(ALbyte val
)
710 { return (val
+128)<<24; }
711 static inline ALuint
Conv_ALuint_ALubyte(ALubyte val
)
713 static inline ALuint
Conv_ALuint_ALshort(ALshort val
)
714 { return (val
+32768)<<16; }
715 static inline ALuint
Conv_ALuint_ALushort(ALushort val
)
717 static inline ALuint
Conv_ALuint_ALint(ALint val
)
718 { return val
+2147483648u; }
719 static inline ALuint
Conv_ALuint_ALuint(ALuint val
)
721 static inline ALuint
Conv_ALuint_ALfloat(ALfloat val
)
723 if(val
> 1.0f
) return 4294967295u;
724 if(val
< -1.0f
) return 0;
725 return ((ALint
)(val
*16777215.0f
)<<7) + 2147483648u;
727 static inline ALuint
Conv_ALuint_ALdouble(ALdouble val
)
729 if(val
> 1.0) return 4294967295u;
730 if(val
< -1.0) return 0;
731 return (ALint
)(val
* 2147483647.0) + 2147483648u;
733 static inline ALuint
Conv_ALuint_ALmulaw(ALmulaw val
)
734 { return Conv_ALuint_ALshort(DecodeMuLaw(val
)); }
735 static inline ALuint
Conv_ALuint_ALalaw(ALalaw val
)
736 { return Conv_ALuint_ALshort(DecodeALaw(val
)); }
737 static inline ALuint
Conv_ALuint_ALbyte3(ALbyte3 val
)
738 { return (DecodeByte3(val
)+8388608)<<8; }
739 static inline ALuint
Conv_ALuint_ALubyte3(ALubyte3 val
)
740 { return DecodeUByte3(val
)<<8; }
742 static inline ALfloat
Conv_ALfloat_ALbyte(ALbyte val
)
743 { return val
* (1.0f
/127.0f
); }
744 static inline ALfloat
Conv_ALfloat_ALubyte(ALubyte val
)
745 { return (val
-128) * (1.0f
/127.0f
); }
746 static inline ALfloat
Conv_ALfloat_ALshort(ALshort val
)
747 { return val
* (1.0f
/32767.0f
); }
748 static inline ALfloat
Conv_ALfloat_ALushort(ALushort val
)
749 { return (val
-32768) * (1.0f
/32767.0f
); }
750 static inline ALfloat
Conv_ALfloat_ALint(ALint val
)
751 { return (ALfloat
)(val
>>7) * (1.0f
/16777215.0f
); }
752 static inline ALfloat
Conv_ALfloat_ALuint(ALuint val
)
753 { return (ALfloat
)((ALint
)(val
>>7)-16777216) * (1.0f
/16777215.0f
); }
754 static inline ALfloat
Conv_ALfloat_ALfloat(ALfloat val
)
755 { return (val
==val
) ? val
: 0.0f
; }
756 static inline ALfloat
Conv_ALfloat_ALdouble(ALdouble val
)
757 { return (val
==val
) ? (ALfloat
)val
: 0.0f
; }
758 static inline ALfloat
Conv_ALfloat_ALmulaw(ALmulaw val
)
759 { return Conv_ALfloat_ALshort(DecodeMuLaw(val
)); }
760 static inline ALfloat
Conv_ALfloat_ALalaw(ALalaw val
)
761 { return Conv_ALfloat_ALshort(DecodeALaw(val
)); }
762 static inline ALfloat
Conv_ALfloat_ALbyte3(ALbyte3 val
)
763 { return (ALfloat
)(DecodeByte3(val
) * (1.0/8388607.0)); }
764 static inline ALfloat
Conv_ALfloat_ALubyte3(ALubyte3 val
)
765 { return (ALfloat
)((DecodeUByte3(val
)-8388608) * (1.0/8388607.0)); }
767 static inline ALdouble
Conv_ALdouble_ALbyte(ALbyte val
)
768 { return val
* (1.0/127.0); }
769 static inline ALdouble
Conv_ALdouble_ALubyte(ALubyte val
)
770 { return (val
-128) * (1.0/127.0); }
771 static inline ALdouble
Conv_ALdouble_ALshort(ALshort val
)
772 { return val
* (1.0/32767.0); }
773 static inline ALdouble
Conv_ALdouble_ALushort(ALushort val
)
774 { return (val
-32768) * (1.0/32767.0); }
775 static inline ALdouble
Conv_ALdouble_ALint(ALint val
)
776 { return val
* (1.0/2147483647.0); }
777 static inline ALdouble
Conv_ALdouble_ALuint(ALuint val
)
778 { return (ALint
)(val
-2147483648u) * (1.0/2147483647.0); }
779 static inline ALdouble
Conv_ALdouble_ALfloat(ALfloat val
)
780 { return (val
==val
) ? val
: 0.0f
; }
781 static inline ALdouble
Conv_ALdouble_ALdouble(ALdouble val
)
782 { return (val
==val
) ? val
: 0.0; }
783 static inline ALdouble
Conv_ALdouble_ALmulaw(ALmulaw val
)
784 { return Conv_ALdouble_ALshort(DecodeMuLaw(val
)); }
785 static inline ALdouble
Conv_ALdouble_ALalaw(ALalaw val
)
786 { return Conv_ALdouble_ALshort(DecodeALaw(val
)); }
787 static inline ALdouble
Conv_ALdouble_ALbyte3(ALbyte3 val
)
788 { return DecodeByte3(val
) * (1.0/8388607.0); }
789 static inline ALdouble
Conv_ALdouble_ALubyte3(ALubyte3 val
)
790 { return (DecodeUByte3(val
)-8388608) * (1.0/8388607.0); }
792 #define DECL_TEMPLATE(T) \
793 static inline ALmulaw Conv_ALmulaw_##T(T val) \
794 { return EncodeMuLaw(Conv_ALshort_##T(val)); }
796 DECL_TEMPLATE(ALbyte
)
797 DECL_TEMPLATE(ALubyte
)
798 DECL_TEMPLATE(ALshort
)
799 DECL_TEMPLATE(ALushort
)
801 DECL_TEMPLATE(ALuint
)
802 DECL_TEMPLATE(ALfloat
)
803 DECL_TEMPLATE(ALdouble
)
804 static inline ALmulaw
Conv_ALmulaw_ALmulaw(ALmulaw val
)
806 DECL_TEMPLATE(ALalaw
)
807 DECL_TEMPLATE(ALbyte3
)
808 DECL_TEMPLATE(ALubyte3
)
812 #define DECL_TEMPLATE(T) \
813 static inline ALalaw Conv_ALalaw_##T(T val) \
814 { return EncodeALaw(Conv_ALshort_##T(val)); }
816 DECL_TEMPLATE(ALbyte
)
817 DECL_TEMPLATE(ALubyte
)
818 DECL_TEMPLATE(ALshort
)
819 DECL_TEMPLATE(ALushort
)
821 DECL_TEMPLATE(ALuint
)
822 DECL_TEMPLATE(ALfloat
)
823 DECL_TEMPLATE(ALdouble
)
824 DECL_TEMPLATE(ALmulaw
)
825 static inline ALalaw
Conv_ALalaw_ALalaw(ALalaw val
)
827 DECL_TEMPLATE(ALbyte3
)
828 DECL_TEMPLATE(ALubyte3
)
832 #define DECL_TEMPLATE(T) \
833 static inline ALbyte3 Conv_ALbyte3_##T(T val) \
834 { return EncodeByte3(Conv_ALint_##T(val)>>8); }
836 DECL_TEMPLATE(ALbyte
)
837 DECL_TEMPLATE(ALubyte
)
838 DECL_TEMPLATE(ALshort
)
839 DECL_TEMPLATE(ALushort
)
841 DECL_TEMPLATE(ALuint
)
842 DECL_TEMPLATE(ALfloat
)
843 DECL_TEMPLATE(ALdouble
)
844 DECL_TEMPLATE(ALmulaw
)
845 DECL_TEMPLATE(ALalaw
)
846 static inline ALbyte3
Conv_ALbyte3_ALbyte3(ALbyte3 val
)
848 DECL_TEMPLATE(ALubyte3
)
852 #define DECL_TEMPLATE(T) \
853 static inline ALubyte3 Conv_ALubyte3_##T(T val) \
854 { return EncodeUByte3(Conv_ALuint_##T(val)>>8); }
856 DECL_TEMPLATE(ALbyte
)
857 DECL_TEMPLATE(ALubyte
)
858 DECL_TEMPLATE(ALshort
)
859 DECL_TEMPLATE(ALushort
)
861 DECL_TEMPLATE(ALuint
)
862 DECL_TEMPLATE(ALfloat
)
863 DECL_TEMPLATE(ALdouble
)
864 DECL_TEMPLATE(ALmulaw
)
865 DECL_TEMPLATE(ALalaw
)
866 DECL_TEMPLATE(ALbyte3
)
867 static inline ALubyte3
Conv_ALubyte3_ALubyte3(ALubyte3 val
)
873 #define DECL_TEMPLATE(T1, T2) \
874 static void Convert_##T1##_##T2(T1 *dst, const T2 *src, ALuint numchans, \
875 ALuint len, ALsizei UNUSED(align)) \
878 for(i = 0;i < len;i++) \
880 for(j = 0;j < numchans;j++) \
881 *(dst++) = Conv_##T1##_##T2(*(src++)); \
885 #define DECL_TEMPLATE2(T) \
886 DECL_TEMPLATE(T, ALbyte) \
887 DECL_TEMPLATE(T, ALubyte) \
888 DECL_TEMPLATE(T, ALshort) \
889 DECL_TEMPLATE(T, ALushort) \
890 DECL_TEMPLATE(T, ALint) \
891 DECL_TEMPLATE(T, ALuint) \
892 DECL_TEMPLATE(T, ALfloat) \
893 DECL_TEMPLATE(T, ALdouble) \
894 DECL_TEMPLATE(T, ALmulaw) \
895 DECL_TEMPLATE(T, ALalaw) \
896 DECL_TEMPLATE(T, ALbyte3) \
897 DECL_TEMPLATE(T, ALubyte3)
899 DECL_TEMPLATE2(ALbyte
)
900 DECL_TEMPLATE2(ALubyte
)
901 DECL_TEMPLATE2(ALshort
)
902 DECL_TEMPLATE2(ALushort
)
903 DECL_TEMPLATE2(ALint
)
904 DECL_TEMPLATE2(ALuint
)
905 DECL_TEMPLATE2(ALfloat
)
906 DECL_TEMPLATE2(ALdouble
)
907 DECL_TEMPLATE2(ALmulaw
)
908 DECL_TEMPLATE2(ALalaw
)
909 DECL_TEMPLATE2(ALbyte3
)
910 DECL_TEMPLATE2(ALubyte3
)
912 #undef DECL_TEMPLATE2
915 #define DECL_TEMPLATE(T) \
916 static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALuint numchans, \
917 ALuint len, ALuint align) \
919 ALsizei byte_align = ((align-1)/2 + 4) * numchans; \
920 DECL_VLA(ALshort, tmp, align*numchans); \
923 assert(align > 0 && (len%align) == 0); \
924 for(i = 0;i < len;i += align) \
926 DecodeIMA4Block(tmp, src, numchans, align); \
929 for(j = 0;j < align;j++) \
931 for(k = 0;k < numchans;k++) \
932 *(dst++) = Conv_##T##_ALshort(tmp[j*numchans + k]); \
937 DECL_TEMPLATE(ALbyte
)
938 DECL_TEMPLATE(ALubyte
)
939 static void Convert_ALshort_ALima4(ALshort
*dst
, const ALima4
*src
, ALuint numchans
,
940 ALuint len
, ALuint align
)
942 ALsizei byte_align
= ((align
-1)/2 + 4) * numchans
;
945 assert(align
> 0 && (len
%align
) == 0);
946 for(i
= 0;i
< len
;i
+= align
)
948 DecodeIMA4Block(dst
, src
, numchans
, align
);
950 dst
+= align
*numchans
;
953 DECL_TEMPLATE(ALushort
)
955 DECL_TEMPLATE(ALuint
)
956 DECL_TEMPLATE(ALfloat
)
957 DECL_TEMPLATE(ALdouble
)
958 DECL_TEMPLATE(ALmulaw
)
959 DECL_TEMPLATE(ALalaw
)
960 DECL_TEMPLATE(ALbyte3
)
961 DECL_TEMPLATE(ALubyte3
)
965 #define DECL_TEMPLATE(T) \
966 static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALuint numchans, \
967 ALuint len, ALuint align) \
969 ALint sample[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \
970 ALint index[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \
971 ALsizei byte_align = ((align-1)/2 + 4) * numchans; \
972 DECL_VLA(ALshort, tmp, align*numchans); \
975 assert(align > 0 && (len%align) == 0); \
976 for(i = 0;i < len;i += align) \
978 for(j = 0;j < align;j++) \
980 for(k = 0;k < numchans;k++) \
981 tmp[j*numchans + k] = Conv_ALshort_##T(*(src++)); \
983 EncodeIMA4Block(dst, tmp, sample, index, numchans, align); \
988 DECL_TEMPLATE(ALbyte
)
989 DECL_TEMPLATE(ALubyte
)
990 static void Convert_ALima4_ALshort(ALima4
*dst
, const ALshort
*src
,
991 ALuint numchans
, ALuint len
, ALuint align
)
993 ALint sample
[MAX_INPUT_CHANNELS
] = {0,0,0,0,0,0,0,0};
994 ALint index
[MAX_INPUT_CHANNELS
] = {0,0,0,0,0,0,0,0};
995 ALsizei byte_align
= ((align
-1)/2 + 4) * numchans
;
998 assert(align
> 0 && (len
%align
) == 0);
999 for(i
= 0;i
< len
;i
+= align
)
1001 EncodeIMA4Block(dst
, src
, sample
, index
, numchans
, align
);
1002 src
+= align
*numchans
;
1006 DECL_TEMPLATE(ALushort
)
1007 DECL_TEMPLATE(ALint
)
1008 DECL_TEMPLATE(ALuint
)
1009 DECL_TEMPLATE(ALfloat
)
1010 DECL_TEMPLATE(ALdouble
)
1011 DECL_TEMPLATE(ALmulaw
)
1012 DECL_TEMPLATE(ALalaw
)
1013 DECL_TEMPLATE(ALbyte3
)
1014 DECL_TEMPLATE(ALubyte3
)
1016 #undef DECL_TEMPLATE
1019 #define DECL_TEMPLATE(T) \
1020 static void Convert_##T##_ALmsadpcm(T *dst, const ALmsadpcm *src, \
1021 ALuint numchans, ALuint len, \
1024 ALsizei byte_align = ((align-2)/2 + 7) * numchans; \
1025 DECL_VLA(ALshort, tmp, align*numchans); \
1028 assert(align > 1 && (len%align) == 0); \
1029 for(i = 0;i < len;i += align) \
1031 DecodeMSADPCMBlock(tmp, src, numchans, align); \
1032 src += byte_align; \
1034 for(j = 0;j < align;j++) \
1036 for(k = 0;k < numchans;k++) \
1037 *(dst++) = Conv_##T##_ALshort(tmp[j*numchans + k]); \
1042 DECL_TEMPLATE(ALbyte
)
1043 DECL_TEMPLATE(ALubyte
)
1044 static void Convert_ALshort_ALmsadpcm(ALshort
*dst
, const ALmsadpcm
*src
,
1045 ALuint numchans
, ALuint len
,
1048 ALsizei byte_align
= ((align
-2)/2 + 7) * numchans
;
1051 assert(align
> 1 && (len
%align
) == 0);
1052 for(i
= 0;i
< len
;i
+= align
)
1054 DecodeMSADPCMBlock(dst
, src
, numchans
, align
);
1056 dst
+= align
*numchans
;
1059 DECL_TEMPLATE(ALushort
)
1060 DECL_TEMPLATE(ALint
)
1061 DECL_TEMPLATE(ALuint
)
1062 DECL_TEMPLATE(ALfloat
)
1063 DECL_TEMPLATE(ALdouble
)
1064 DECL_TEMPLATE(ALmulaw
)
1065 DECL_TEMPLATE(ALalaw
)
1066 DECL_TEMPLATE(ALbyte3
)
1067 DECL_TEMPLATE(ALubyte3
)
1069 #undef DECL_TEMPLATE
1071 #define DECL_TEMPLATE(T) \
1072 static void Convert_ALmsadpcm_##T(ALmsadpcm *dst, const T *src, \
1073 ALuint numchans, ALuint len, ALuint align) \
1075 ALint sample[MAX_INPUT_CHANNELS] = {0,0,0,0,0,0,0,0}; \
1076 ALsizei byte_align = ((align-2)/2 + 7) * numchans; \
1077 DECL_VLA(ALshort, tmp, align*numchans); \
1080 assert(align > 1 && (len%align) == 0); \
1081 for(i = 0;i < len;i += align) \
1083 for(j = 0;j < align;j++) \
1085 for(k = 0;k < numchans;k++) \
1086 tmp[j*numchans + k] = Conv_ALshort_##T(*(src++)); \
1088 EncodeMSADPCMBlock(dst, tmp, sample, numchans, align); \
1089 dst += byte_align; \
1093 DECL_TEMPLATE(ALbyte
)
1094 DECL_TEMPLATE(ALubyte
)
1095 static void Convert_ALmsadpcm_ALshort(ALmsadpcm
*dst
, const ALshort
*src
,
1096 ALuint numchans
, ALuint len
, ALuint align
)
1098 ALint sample
[MAX_INPUT_CHANNELS
] = {0,0,0,0,0,0,0,0};
1099 ALsizei byte_align
= ((align
-2)/2 + 7) * numchans
;
1102 assert(align
> 1 && (len
%align
) == 0);
1103 for(i
= 0;i
< len
;i
+= align
)
1105 EncodeMSADPCMBlock(dst
, src
, sample
, numchans
, align
);
1106 src
+= align
*numchans
;
1110 DECL_TEMPLATE(ALushort
)
1111 DECL_TEMPLATE(ALint
)
1112 DECL_TEMPLATE(ALuint
)
1113 DECL_TEMPLATE(ALfloat
)
1114 DECL_TEMPLATE(ALdouble
)
1115 DECL_TEMPLATE(ALmulaw
)
1116 DECL_TEMPLATE(ALalaw
)
1117 DECL_TEMPLATE(ALbyte3
)
1118 DECL_TEMPLATE(ALubyte3
)
1120 #undef DECL_TEMPLATE
1122 /* NOTE: We don't store compressed samples internally, so these conversions
1123 * should never happen. */
1124 static void Convert_ALima4_ALima4(ALima4
* UNUSED(dst
), const ALima4
* UNUSED(src
),
1125 ALuint
UNUSED(numchans
), ALuint
UNUSED(len
),
1126 ALuint
UNUSED(align
))
1128 ERR("Unexpected IMA4-to-IMA4 conversion!\n");
1131 static void Convert_ALmsadpcm_ALmsadpcm(ALmsadpcm
* UNUSED(dst
), const ALmsadpcm
* UNUSED(src
),
1132 ALuint
UNUSED(numchans
), ALuint
UNUSED(len
),
1133 ALuint
UNUSED(align
))
1135 ERR("Unexpected MSADPCM-to-MSADPCM conversion!\n");
1138 static void Convert_ALmsadpcm_ALima4(ALmsadpcm
* UNUSED(dst
), const ALima4
* UNUSED(src
),
1139 ALuint
UNUSED(numchans
), ALuint
UNUSED(len
),
1140 ALuint
UNUSED(align
))
1142 ERR("Unexpected IMA4-to-MSADPCM conversion!\n");
1145 static void Convert_ALima4_ALmsadpcm(ALima4
* UNUSED(dst
), const ALmsadpcm
* UNUSED(src
),
1146 ALuint
UNUSED(numchans
), ALuint
UNUSED(len
),
1147 ALuint
UNUSED(align
))
1149 ERR("Unexpected MSADPCM-to-IMA4 conversion!\n");
1153 #define DECL_TEMPLATE(T) \
1154 static void Convert_##T(T *dst, const ALvoid *src, enum UserFmtType srcType, \
1155 ALsizei numchans, ALsizei len, ALsizei align) \
1160 Convert_##T##_ALbyte(dst, src, numchans, len, align); \
1162 case UserFmtUByte: \
1163 Convert_##T##_ALubyte(dst, src, numchans, len, align); \
1165 case UserFmtShort: \
1166 Convert_##T##_ALshort(dst, src, numchans, len, align); \
1168 case UserFmtUShort: \
1169 Convert_##T##_ALushort(dst, src, numchans, len, align); \
1172 Convert_##T##_ALint(dst, src, numchans, len, align); \
1175 Convert_##T##_ALuint(dst, src, numchans, len, align); \
1177 case UserFmtFloat: \
1178 Convert_##T##_ALfloat(dst, src, numchans, len, align); \
1180 case UserFmtDouble: \
1181 Convert_##T##_ALdouble(dst, src, numchans, len, align); \
1183 case UserFmtMulaw: \
1184 Convert_##T##_ALmulaw(dst, src, numchans, len, align); \
1187 Convert_##T##_ALalaw(dst, src, numchans, len, align); \
1190 Convert_##T##_ALima4(dst, src, numchans, len, align); \
1192 case UserFmtMSADPCM: \
1193 Convert_##T##_ALmsadpcm(dst, src, numchans, len, align); \
1195 case UserFmtByte3: \
1196 Convert_##T##_ALbyte3(dst, src, numchans, len, align); \
1198 case UserFmtUByte3: \
1199 Convert_##T##_ALubyte3(dst, src, numchans, len, align); \
1204 DECL_TEMPLATE(ALbyte
)
1205 DECL_TEMPLATE(ALubyte
)
1206 DECL_TEMPLATE(ALshort
)
1207 DECL_TEMPLATE(ALushort
)
1208 DECL_TEMPLATE(ALint
)
1209 DECL_TEMPLATE(ALuint
)
1210 DECL_TEMPLATE(ALfloat
)
1211 DECL_TEMPLATE(ALdouble
)
1212 DECL_TEMPLATE(ALmulaw
)
1213 DECL_TEMPLATE(ALalaw
)
1214 DECL_TEMPLATE(ALima4
)
1215 DECL_TEMPLATE(ALmsadpcm
)
1216 DECL_TEMPLATE(ALbyte3
)
1217 DECL_TEMPLATE(ALubyte3
)
1219 #undef DECL_TEMPLATE
1222 void ConvertData(ALvoid
*dst
, enum UserFmtType dstType
, const ALvoid
*src
, enum UserFmtType srcType
, ALsizei numchans
, ALsizei len
, ALsizei align
)
1227 Convert_ALbyte(dst
, src
, srcType
, numchans
, len
, align
);
1230 Convert_ALubyte(dst
, src
, srcType
, numchans
, len
, align
);
1233 Convert_ALshort(dst
, src
, srcType
, numchans
, len
, align
);
1236 Convert_ALushort(dst
, src
, srcType
, numchans
, len
, align
);
1239 Convert_ALint(dst
, src
, srcType
, numchans
, len
, align
);
1242 Convert_ALuint(dst
, src
, srcType
, numchans
, len
, align
);
1245 Convert_ALfloat(dst
, src
, srcType
, numchans
, len
, align
);
1248 Convert_ALdouble(dst
, src
, srcType
, numchans
, len
, align
);
1251 Convert_ALmulaw(dst
, src
, srcType
, numchans
, len
, align
);
1254 Convert_ALalaw(dst
, src
, srcType
, numchans
, len
, align
);
1257 Convert_ALima4(dst
, src
, srcType
, numchans
, len
, align
);
1259 case UserFmtMSADPCM
:
1260 Convert_ALmsadpcm(dst
, src
, srcType
, numchans
, len
, align
);
1263 Convert_ALbyte3(dst
, src
, srcType
, numchans
, len
, align
);
1266 Convert_ALubyte3(dst
, src
, srcType
, numchans
, len
, align
);