forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 2
/
audio_utils.h
184 lines (163 loc) · 5.45 KB
/
audio_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AUDIO_UTILS_H
#define AUDIO_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#if defined(__SSE2__)
#define audio_convert_s16_to_float audio_convert_s16_to_float_SSE2
#define audio_convert_float_to_s16 audio_convert_float_to_s16_SSE2
/**
* audio_convert_s16_to_float_SSE2:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* SSE2 implementation callback function.
**/
void audio_convert_s16_to_float_SSE2(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_SSE2:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* SSE2 implementation callback function.
**/
void audio_convert_float_to_s16_SSE2(int16_t *out,
const float *in, size_t samples);
#elif defined(__ALTIVEC__)
#define audio_convert_s16_to_float audio_convert_s16_to_float_altivec
#define audio_convert_float_to_s16 audio_convert_float_to_s16_altivec
/**
* audio_convert_s16_to_float_altivec:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* AltiVec implementation callback function.
**/
void audio_convert_s16_to_float_altivec(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_altivec:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* AltiVec implementation callback function.
**/
void audio_convert_float_to_s16_altivec(int16_t *out,
const float *in, size_t samples);
#elif defined(__ARM_NEON__) && !defined(VITA)
#define audio_convert_s16_to_float audio_convert_s16_to_float_arm
#define audio_convert_float_to_s16 audio_convert_float_to_s16_arm
void (*audio_convert_s16_to_float_arm)(float *out,
const int16_t *in, size_t samples, float gain);
void (*audio_convert_float_to_s16_arm)(int16_t *out,
const float *in, size_t samples);
#elif defined(_MIPS_ARCH_ALLEGREX)
#define audio_convert_s16_to_float audio_convert_s16_to_float_ALLEGREX
#define audio_convert_float_to_s16 audio_convert_float_to_s16_ALLEGREX
/**
* audio_convert_s16_to_float_ALLEGREX:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* MIPS ALLEGREX implementation callback function.
**/
void audio_convert_s16_to_float_ALLEGREX(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_ALLEGREX:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* MIPS ALLEGREX implementation callback function.
**/
void audio_convert_float_to_s16_ALLEGREX(int16_t *out,
const float *in, size_t samples);
#else
#define audio_convert_s16_to_float audio_convert_s16_to_float_C
#define audio_convert_float_to_s16 audio_convert_float_to_s16_C
#endif
/**
* audio_convert_s16_to_float_C:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* C implementation callback function.
**/
void audio_convert_s16_to_float_C(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_C:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* C implementation callback function.
**/
void audio_convert_float_to_s16_C(int16_t *out,
const float *in, size_t samples);
/**
* audio_convert_init_simd:
*
* Sets up function pointers for audio conversion
* functions based on CPU features.
**/
void audio_convert_init_simd(void);
#ifdef __cplusplus
}
#endif
#endif