summaryrefslogtreecommitdiffstats
path: root/audio/mixeng.c
diff options
context:
space:
mode:
authorPeter Maydell2020-03-16 14:06:14 +0100
committerPeter Maydell2020-03-16 14:06:14 +0100
commit509f61798b5d1056dfbcbbc64a7c2998740f10d6 (patch)
tree140d946d714d87d8574eeb43f099a2fd9dc669e3 /audio/mixeng.c
parentMerge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200313a'... (diff)
parentaudio: add audiodev format=f32 option documentation (diff)
downloadqemu-509f61798b5d1056dfbcbbc64a7c2998740f10d6.tar.gz
qemu-509f61798b5d1056dfbcbbc64a7c2998740f10d6.tar.xz
qemu-509f61798b5d1056dfbcbbc64a7c2998740f10d6.zip
Merge remote-tracking branch 'remotes/kraxel/tags/audio-20200316-pull-request' into staging
audio: float fixes # gpg: Signature made Mon 16 Mar 2020 11:30:00 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/audio-20200316-pull-request: audio: add audiodev format=f32 option documentation audio: fix saturation nonlinearity in clip_* functions audio: change mixing engine float range to [-1.f, 1.f] audio: consistency changes audio: change naming scheme of FLOAT_CONV macros qapi/audio: add documentation for AudioFormat Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'audio/mixeng.c')
-rw-r--r--audio/mixeng.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/audio/mixeng.c b/audio/mixeng.c
index c14b0d874c..739a500449 100644
--- a/audio/mixeng.c
+++ b/audio/mixeng.c
@@ -268,17 +268,17 @@ f_sample *mixeng_clip[2][2][2][3] = {
};
#ifdef FLOAT_MIXENG
-#define FLOAT_CONV_TO(x) (x)
-#define FLOAT_CONV_FROM(x) (x)
+#define CONV_NATURAL_FLOAT(x) (x)
+#define CLIP_NATURAL_FLOAT(x) (x)
#else
-static const float float_scale = UINT_MAX;
-#define FLOAT_CONV_TO(x) ((x) * float_scale)
+static const float float_scale = UINT_MAX / 2.f;
+#define CONV_NATURAL_FLOAT(x) ((x) * float_scale)
#ifdef RECIPROCAL
-static const float float_scale_reciprocal = 1.f / UINT_MAX;
-#define FLOAT_CONV_FROM(x) ((x) * float_scale_reciprocal)
+static const float float_scale_reciprocal = 2.f / UINT_MAX;
+#define CLIP_NATURAL_FLOAT(x) ((x) * float_scale_reciprocal)
#else
-#define FLOAT_CONV_FROM(x) ((x) / float_scale)
+#define CLIP_NATURAL_FLOAT(x) ((x) / float_scale)
#endif
#endif
@@ -288,7 +288,7 @@ static void conv_natural_float_to_mono(struct st_sample *dst, const void *src,
float *in = (float *)src;
while (samples--) {
- dst->r = dst->l = FLOAT_CONV_TO(*in++);
+ dst->r = dst->l = CONV_NATURAL_FLOAT(*in++);
dst++;
}
}
@@ -299,8 +299,8 @@ static void conv_natural_float_to_stereo(struct st_sample *dst, const void *src,
float *in = (float *)src;
while (samples--) {
- dst->l = FLOAT_CONV_TO(*in++);
- dst->r = FLOAT_CONV_TO(*in++);
+ dst->l = CONV_NATURAL_FLOAT(*in++);
+ dst->r = CONV_NATURAL_FLOAT(*in++);
dst++;
}
}
@@ -316,7 +316,7 @@ static void clip_natural_float_from_mono(void *dst, const struct st_sample *src,
float *out = (float *)dst;
while (samples--) {
- *out++ = FLOAT_CONV_FROM(src->l) + FLOAT_CONV_FROM(src->r);
+ *out++ = CLIP_NATURAL_FLOAT(src->l + src->r);
src++;
}
}
@@ -327,8 +327,8 @@ static void clip_natural_float_from_stereo(
float *out = (float *)dst;
while (samples--) {
- *out++ = FLOAT_CONV_FROM(src->l);
- *out++ = FLOAT_CONV_FROM(src->r);
+ *out++ = CLIP_NATURAL_FLOAT(src->l);
+ *out++ = CLIP_NATURAL_FLOAT(src->r);
src++;
}
}