From patchwork Sun Mar 8 19:33:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 11425811 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41AA613A4 for ; Sun, 8 Mar 2020 19:34:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 167EE2067C for ; Sun, 8 Mar 2020 19:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 167EE2067C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1gj-00037w-Qw for patchwork-qemu-devel@patchwork.kernel.org; Sun, 08 Mar 2020 15:34:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37217) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1g4-0002M1-8L for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jB1g3-0006yr-5E for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:32 -0400 Received: from mailout10.t-online.de ([194.25.134.21]:49888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jB1g2-0006wP-Vk for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:31 -0400 Received: from fwd06.aul.t-online.de (fwd06.aul.t-online.de [172.20.26.150]) by mailout10.t-online.de (Postfix) with SMTP id 14FAE4165D96; Sun, 8 Mar 2020 20:33:29 +0100 (CET) Received: from linpower.localnet (XReU-mZZQhI6NGU+UoUy87MrAIlOqJbOOXetIVaUTayBZ-aL+q3mTM4XvB0LV+sQpf@[79.208.31.100]) by fwd06.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jB1fu-1l2zU80; Sun, 8 Mar 2020 20:33:22 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 928792000A6; Sun, 8 Mar 2020 20:33:21 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Eric Blake , Markus Armbruster Subject: [PATCH v2 1/6] qapi/audio: add documentation for AudioFormat Date: Sun, 8 Mar 2020 20:33:16 +0100 Message-Id: <20200308193321.20668-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> References: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> MIME-Version: 1.0 X-ID: XReU-mZZQhI6NGU+UoUy87MrAIlOqJbOOXetIVaUTayBZ-aL+q3mTM4XvB0LV+sQpf X-TOI-MSGID: 74427376-a2b6-4fac-85d0-4a967bf350b2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.21 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle , Howard Spoelstra , Mark Cave-Ayland , QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The review for patch ed2a4a7941 "audio: proper support for float samples in mixeng" suggested this would be a good idea. Acked-by: Markus Armbruster Signed-off-by: Volker Rümelin Tested-by: John Arbuckle --- qapi/audio.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qapi/audio.json b/qapi/audio.json index d8c507cced..c31251f45b 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -273,6 +273,20 @@ # # An enumeration of possible audio formats. # +# @u8: unsigned 8 bit integer +# +# @s8: signed 8 bit integer +# +# @u16: unsigned 16 bit integer +# +# @s16: signed 16 bit integer +# +# @u32: unsigned 32 bit integer +# +# @s32: signed 32 bit integer +# +# @f32: single precision floating-point (since 5.0) +# # Since: 4.0 ## { 'enum': 'AudioFormat', From patchwork Sun Mar 8 19:33:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 11425813 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF27614BC for ; Sun, 8 Mar 2020 19:34:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A075F2067C for ; Sun, 8 Mar 2020 19:34:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A075F2067C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1gn-0003DM-Qc for patchwork-qemu-devel@patchwork.kernel.org; Sun, 08 Mar 2020 15:34:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37235) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1g5-0002M8-BM for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jB1g3-0006yz-Ab for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:32 -0400 Received: from mailout09.t-online.de ([194.25.134.84]:48622) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jB1g3-0006wU-0p for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:31 -0400 Received: from fwd25.aul.t-online.de (fwd25.aul.t-online.de [172.20.26.130]) by mailout09.t-online.de (Postfix) with SMTP id 19EDE4230EEB; Sun, 8 Mar 2020 20:33:29 +0100 (CET) Received: from linpower.localnet (GWwSMcZCohoZDM9rI++fNADFZQEoH8vN3SJNnetaZW4WDBrCd9lH8gqyjD6HFGTwwa@[79.208.31.100]) by fwd25.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jB1fw-1s6DFQ0; Sun, 8 Mar 2020 20:33:24 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 94C5D200637; Sun, 8 Mar 2020 20:33:21 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Eric Blake , Markus Armbruster Subject: [PATCH v2 2/6] audio: change naming scheme of FLOAT_CONV macros Date: Sun, 8 Mar 2020 20:33:17 +0100 Message-Id: <20200308193321.20668-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> References: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> MIME-Version: 1.0 X-ID: GWwSMcZCohoZDM9rI++fNADFZQEoH8vN3SJNnetaZW4WDBrCd9lH8gqyjD6HFGTwwa X-TOI-MSGID: b5b192e7-bc73-4bf1-bcc8-50842ebb173f X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.84 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle , Howard Spoelstra , Mark Cave-Ayland , QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This patch changes the naming scheme of the FLOAT_CONV_TO and FLOAT_CONV_FROM macros to the scheme used in mixeng_template.h. Signed-off-by: Volker Rümelin --- audio/mixeng.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/audio/mixeng.c b/audio/mixeng.c index c14b0d874c..b57fad83bf 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) +#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) +#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) + CLIP_NATURAL_FLOAT(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++; } } From patchwork Sun Mar 8 19:33:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 11425819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A41F14BC for ; Sun, 8 Mar 2020 19:37:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A5E720675 for ; Sun, 8 Mar 2020 19:37:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A5E720675 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1jW-0006bs-9U for patchwork-qemu-devel@patchwork.kernel.org; Sun, 08 Mar 2020 15:37:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37245) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1g5-0002M9-Ns for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jB1g3-0006zD-S3 for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:33 -0400 Received: from mailout10.t-online.de ([194.25.134.21]:49904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jB1g3-0006yO-M8 for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:31 -0400 Received: from fwd21.aul.t-online.de (fwd21.aul.t-online.de [172.20.27.66]) by mailout10.t-online.de (Postfix) with SMTP id C08114165D92; Sun, 8 Mar 2020 20:33:30 +0100 (CET) Received: from linpower.localnet (rfXi7EZcYhEYaecl9IiV6vn0SfQ5qcJ2B5vqiHMlset2WbpnC2qcATxOtNr2iJUwwm@[79.208.31.100]) by fwd21.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jB1fz-2eqGjw0; Sun, 8 Mar 2020 20:33:27 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 95A842006CD; Sun, 8 Mar 2020 20:33:21 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Eric Blake , Markus Armbruster Subject: [PATCH v2 3/6] audio: consistency changes Date: Sun, 8 Mar 2020 20:33:18 +0100 Message-Id: <20200308193321.20668-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> References: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> MIME-Version: 1.0 X-ID: rfXi7EZcYhEYaecl9IiV6vn0SfQ5qcJ2B5vqiHMlset2WbpnC2qcATxOtNr2iJUwwm X-TOI-MSGID: 4f0e0210-3d2d-468a-a782-98d07c436075 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.21 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle , Howard Spoelstra , Mark Cave-Ayland , QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Change the clip_natural_float_from_mono() function in audio/mixeng.c to be consistent with the clip_*_from_mono() functions in audio/mixeng_template.h. Signed-off-by: Volker Rümelin --- audio/mixeng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/mixeng.c b/audio/mixeng.c index b57fad83bf..725b529be7 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -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++ = CLIP_NATURAL_FLOAT(src->l) + CLIP_NATURAL_FLOAT(src->r); + *out++ = CLIP_NATURAL_FLOAT(src->l + src->r); src++; } } From patchwork Sun Mar 8 19:33:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 11425815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E49E13A4 for ; Sun, 8 Mar 2020 19:35:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6ECEE2067C for ; Sun, 8 Mar 2020 19:35:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ECEE2067C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1iI-0004x9-L6 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 08 Mar 2020 15:35:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37232) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1g5-0002M3-4Q for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jB1g4-0006zS-2I for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:33 -0400 Received: from mailout03.t-online.de ([194.25.134.81]:34764) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jB1g3-0006y8-O0 for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:32 -0400 Received: from fwd30.aul.t-online.de (fwd30.aul.t-online.de [172.20.26.135]) by mailout03.t-online.de (Postfix) with SMTP id 3BF4B427E7BA; Sun, 8 Mar 2020 20:33:30 +0100 (CET) Received: from linpower.localnet (bKrPuwZpghIMNnwLloP6R4aXGWFA3l4WO3GmYYVfqsj5gGep5BSwUkf0Y5u7mHrgLk@[79.208.31.100]) by fwd30.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jB1g2-3QOuAq0; Sun, 8 Mar 2020 20:33:30 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 978482006CE; Sun, 8 Mar 2020 20:33:21 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Eric Blake , Markus Armbruster Subject: [PATCH v2 4/6] audio: change mixing engine float range to [-1.f, 1.f] Date: Sun, 8 Mar 2020 20:33:19 +0100 Message-Id: <20200308193321.20668-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> References: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> MIME-Version: 1.0 X-ID: bKrPuwZpghIMNnwLloP6R4aXGWFA3l4WO3GmYYVfqsj5gGep5BSwUkf0Y5u7mHrgLk X-TOI-MSGID: 89289e91-17ab-489f-bae7-5654794d4ba6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle , Howard Spoelstra , Mark Cave-Ayland , QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Currently the internal float range of the mixing engine is [-.5f, .5f]. PulseAudio, SDL2 and libasound use a [-1.f, 1.f] range. This means with float samples the audio playback volume is 6dB too low and audio recording signals will be clipped in most cases. To avoid another scaling factor in the conv_natural_float_* and clip_natural_float_* functions with FLOAT_MIXENG defined this patch changes the mixing engine float range to [-1.f, 1.f]. Signed-off-by: Volker Rümelin --- audio/mixeng.c | 4 ++-- audio/mixeng_template.h | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/audio/mixeng.c b/audio/mixeng.c index 725b529be7..739a500449 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -271,11 +271,11 @@ f_sample *mixeng_clip[2][2][2][3] = { #define CONV_NATURAL_FLOAT(x) (x) #define CLIP_NATURAL_FLOAT(x) (x) #else -static const float float_scale = UINT_MAX; +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; +static const float float_scale_reciprocal = 2.f / UINT_MAX; #define CLIP_NATURAL_FLOAT(x) ((x) * float_scale_reciprocal) #else #define CLIP_NATURAL_FLOAT(x) ((x) / float_scale) diff --git a/audio/mixeng_template.h b/audio/mixeng_template.h index 77cc89b9e8..fc8e1d4d9e 100644 --- a/audio/mixeng_template.h +++ b/audio/mixeng_template.h @@ -41,32 +41,31 @@ static inline mixeng_real glue (conv_, ET) (IN_T v) #ifdef RECIPROCAL #ifdef SIGNED - return nv * (1.f / (mixeng_real) (IN_MAX - IN_MIN)); + return nv * (2.f / ((mixeng_real)IN_MAX - IN_MIN)); #else - return (nv - HALF) * (1.f / (mixeng_real) IN_MAX); + return (nv - HALF) * (2.f / (mixeng_real)IN_MAX); #endif #else /* !RECIPROCAL */ #ifdef SIGNED - return nv / (mixeng_real) ((mixeng_real) IN_MAX - IN_MIN); + return nv / (((mixeng_real)IN_MAX - IN_MIN) / 2.f); #else - return (nv - HALF) / (mixeng_real) IN_MAX; + return (nv - HALF) / ((mixeng_real)IN_MAX / 2.f); #endif #endif } static inline IN_T glue (clip_, ET) (mixeng_real v) { - if (v >= 0.5) { + if (v >= 1.f) { return IN_MAX; - } - else if (v < -0.5) { + } else if (v < -1.f) { return IN_MIN; } #ifdef SIGNED - return ENDIAN_CONVERT ((IN_T) (v * ((mixeng_real) IN_MAX - IN_MIN))); + return ENDIAN_CONVERT((IN_T)(v * (((mixeng_real)IN_MAX - IN_MIN) / 2.f))); #else - return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF)); + return ENDIAN_CONVERT((IN_T)((v * ((mixeng_real)IN_MAX / 2.f)) + HALF)); #endif } From patchwork Sun Mar 8 19:33:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 11425817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A38F1731 for ; Sun, 8 Mar 2020 19:35:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B4862067C for ; Sun, 8 Mar 2020 19:35:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B4862067C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1iJ-0004yi-6q for patchwork-qemu-devel@patchwork.kernel.org; Sun, 08 Mar 2020 15:35:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37267) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1g9-0002Rk-RQ for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jB1g8-000723-UQ for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:37 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:48954) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jB1g8-00071Z-OI for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:36 -0400 Received: from fwd24.aul.t-online.de (fwd24.aul.t-online.de [172.20.26.129]) by mailout06.t-online.de (Postfix) with SMTP id 6CF10417E467; Sun, 8 Mar 2020 20:33:35 +0100 (CET) Received: from linpower.localnet (rXpqIYZfohqLY+clO6MgLyQ3aZgR2oSiY7BLQbrYIZnbOIaXplSPlwfrDvRRXsLZPv@[79.208.31.100]) by fwd24.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jB1g4-1Samyu0; Sun, 8 Mar 2020 20:33:32 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 99A702006D0; Sun, 8 Mar 2020 20:33:21 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Eric Blake , Markus Armbruster Subject: [PATCH v2 5/6] audio: fix saturation nonlinearity in clip_* functions Date: Sun, 8 Mar 2020 20:33:20 +0100 Message-Id: <20200308193321.20668-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> References: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> MIME-Version: 1.0 X-ID: rXpqIYZfohqLY+clO6MgLyQ3aZgR2oSiY7BLQbrYIZnbOIaXplSPlwfrDvRRXsLZPv X-TOI-MSGID: ea02d5cd-b794-468a-8c7a-c5530fe25ba6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.19 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle , Howard Spoelstra , Mark Cave-Ayland , QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The current positive limit for the saturation nonlinearity is only correct if the type of the result has 8 bits or less. Signed-off-by: Volker Rümelin --- audio/mixeng_template.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/audio/mixeng_template.h b/audio/mixeng_template.h index fc8e1d4d9e..bc8509e423 100644 --- a/audio/mixeng_template.h +++ b/audio/mixeng_template.h @@ -83,10 +83,9 @@ static inline int64_t glue (conv_, ET) (IN_T v) static inline IN_T glue (clip_, ET) (int64_t v) { - if (v >= 0x7f000000) { + if (v >= 0x7fffffffLL) { return IN_MAX; - } - else if (v < -2147483648LL) { + } else if (v < -2147483648LL) { return IN_MIN; } From patchwork Sun Mar 8 19:33:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 11425821 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 944E313A4 for ; Sun, 8 Mar 2020 19:37:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74C7320675 for ; Sun, 8 Mar 2020 19:37:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74C7320675 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:32820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1jY-0006fh-Ms for patchwork-qemu-devel@patchwork.kernel.org; Sun, 08 Mar 2020 15:37:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37278) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jB1gF-0002b1-SY for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jB1gD-00074I-VI for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:43 -0400 Received: from mailout04.t-online.de ([194.25.134.18]:59386) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jB1gD-00073f-PT for qemu-devel@nongnu.org; Sun, 08 Mar 2020 15:33:41 -0400 Received: from fwd23.aul.t-online.de (fwd23.aul.t-online.de [172.20.26.128]) by mailout04.t-online.de (Postfix) with SMTP id 7A76241FBAE9; Sun, 8 Mar 2020 20:33:40 +0100 (CET) Received: from linpower.localnet (ZGIpCEZfYhOFuRT-iXyhPwadEndrGEIus5q6UampyI1dAeVKSKH820GPUD2w-jhZUD@[79.208.31.100]) by fwd23.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jB1g7-4CbgkS0; Sun, 8 Mar 2020 20:33:35 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 9BC152006D1; Sun, 8 Mar 2020 20:33:21 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann , Eric Blake , Markus Armbruster Subject: [PATCH v2 6/6] audio: add audiodev format=f32 option documentation Date: Sun, 8 Mar 2020 20:33:21 +0100 Message-Id: <20200308193321.20668-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> References: <2a4ade5f-d39b-3094-578f-6cced4650720@t-online.de> MIME-Version: 1.0 X-ID: ZGIpCEZfYhOFuRT-iXyhPwadEndrGEIus5q6UampyI1dAeVKSKH820GPUD2w-jhZUD X-TOI-MSGID: d23c3cc6-9297-41cf-8435-c13075e488a8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.18 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle , Howard Spoelstra , Mark Cave-Ayland , QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The documentaion for -audiodev format=f32 option was missing. Signed-off-by: Volker Rümelin --- qemu-options.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index f9fefd43be..2919eddf4d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -551,7 +551,7 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, " in|out.frequency= frequency to use with fixed settings\n" " in|out.channels= number of channels to use with fixed settings\n" " in|out.format= sample format to use with fixed settings\n" - " valid values: s8, s16, s32, u8, u16, u32\n" + " valid values: s8, s16, s32, u8, u16, u32, f32\n" " in|out.voices= number of voices to use\n" " in|out.buffer-length= length of buffer in microseconds\n" "-audiodev none,id=id,[,prop[=value][,...]]\n" @@ -647,7 +647,7 @@ SRST ``in|out.format=format`` Specify the sample format to use when using fixed-settings. Valid values are: ``s8``, ``s16``, ``s32``, ``u8``, ``u16``, - ``u32``. Default is ``s16``. + ``u32``, ``f32``. Default is ``s16``. ``in|out.voices=voices`` Specify the number of voices to use. Default is 1.