{"id":2229389,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229389/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260428081303.990973-14-marcandre.lureau@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260428081303.990973-14-marcandre.lureau@redhat.com>","date":"2026-04-28T08:13:00","name":"[PULL,13/15] audio: Use unsigned PCM bias","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0cc9218c7c56b4c3a4aef1b09b79b8c378061400","submitter":{"id":66774,"url":"http://patchwork.ozlabs.org/api/1.1/people/66774/?format=json","name":"Marc-André Lureau","email":"marcandre.lureau@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260428081303.990973-14-marcandre.lureau@redhat.com/mbox/","series":[{"id":501785,"url":"http://patchwork.ozlabs.org/api/1.1/series/501785/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501785","date":"2026-04-28T08:12:48","name":"[PULL,01/15] ui: move FONT_WIDTH/HEIGHT to vgafont.h","version":1,"mbox":"http://patchwork.ozlabs.org/series/501785/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229389/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229389/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=YfqUTIe5;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4YCX71jqz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 18:15:36 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wHdap-0007Nb-Cy; Tue, 28 Apr 2026 04:14:55 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1wHdaU-0006oE-PI\n for qemu-devel@nongnu.org; Tue, 28 Apr 2026 04:14:36 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.129.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1wHdaT-0006AK-1b\n for qemu-devel@nongnu.org; Tue, 28 Apr 2026 04:14:34 -0400","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-wKHKDJdlOJCTK1bjJnrX0Q-1; Tue,\n 28 Apr 2026 04:14:28 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id C31FE195609E; Tue, 28 Apr 2026 08:14:27 +0000 (UTC)","from localhost (unknown [10.44.24.6])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id A5C4119560B7; Tue, 28 Apr 2026 08:14:26 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777364072;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=msfcYbXdPoxDb4VF0TVAMI3ngZnG5gWrGEoAA3b9h/I=;\n b=YfqUTIe5Z6c9Kk4qVSWyxgfqXHhTfx15usWAKYtHTzXY6GJi+3QSCub9CZ/rNyMnd3hdWJ\n bqBu0UgMaKha6Pe7IlNTmf5XNHOK5WWVFWNM6B76iwP+Cdu505SgJ5he0MejhT/hDe5O0J\n lol5WSzzxBW/Q+l6fLlLN3FqqNjRKQg=","X-MC-Unique":"wKHKDJdlOJCTK1bjJnrX0Q-1","X-Mimecast-MFC-AGG-ID":"wKHKDJdlOJCTK1bjJnrX0Q_1777364067","From":"marcandre.lureau@redhat.com","To":"qemu-devel@nongnu.org","Cc":"peter.maydell@linaro.org, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>,\n Gerd Hoffmann <kraxel@redhat.com>,\n =?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>","Subject":"[PULL 13/15] audio: Use unsigned PCM bias","Date":"Tue, 28 Apr 2026 12:13:00 +0400","Message-ID":"<20260428081303.990973-14-marcandre.lureau@redhat.com>","In-Reply-To":"<20260428081303.990973-1-marcandre.lureau@redhat.com>","References":"<20260428081303.990973-1-marcandre.lureau@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12","Received-SPF":"pass client-ip=170.10.129.124;\n envelope-from=marcandre.lureau@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>\n\nClang warns for the uint32_t clip_ instantiations because HALF cannot be\nrepresented with mixeng_real:\n\n[1115/2559] Compiling C object libqemuaudio.a.p/audio_mixeng.c.o\nIn file included from ../../qemu/audio/mixeng.c:147:\n../../qemu/audio/mixeng_template.h:68:70: warning: implicit conversion from 'unsigned int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]\n   68 |     return ENDIAN_CONVERT((IN_T)((v * ((mixeng_real)IN_MAX / 2.f)) + HALF));\n      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~\n../../qemu/audio/mixeng_template.h:31:22: note: expanded from macro 'HALF'\n   31 | #define HALF (IN_MAX >> 1)\n      |                      ^\n../../qemu/audio/mixeng.c:146:28: note: expanded from macro 'ENDIAN_CONVERT'\n  146 | #define ENDIAN_CONVERT(v) (v)\n      |                            ^\nIn file included from ../../qemu/audio/mixeng.c:152:\n../../qemu/audio/mixeng_template.h:68:70: warning: implicit conversion from 'unsigned int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]\n   68 |     return ENDIAN_CONVERT((IN_T)((v * ((mixeng_real)IN_MAX / 2.f)) + HALF));\n      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~\n../../qemu/audio/mixeng_template.h:31:22: note: expanded from macro 'HALF'\n   31 | #define HALF (IN_MAX >> 1)\n      |                      ^\n../../qemu/audio/mixeng.c:151:36: note: expanded from macro 'ENDIAN_CONVERT'\n  151 | #define ENDIAN_CONVERT(v) bswap32 (v)\n      |                           ~~~~~~~~~^~\n/Users/person/v/qemu/include/qemu/bswap.h:10:39: note: expanded from macro 'bswap32'\n   10 | #define bswap32(_x) __builtin_bswap32(_x)\n      |                                       ^~\n2 warnings generated.\n\nHALF is not the right value here anyway. IN_MAX is odd, so the integer\nsample range has two middle codes. Unsigned PCM normally uses the upper\nmiddle code as the \"bias\": 0x80, 0x8000, or 0x80000000. HALF is instead\ndefined as the lower middle code: 0x7f, 0x7fff, or 0x7fffffff.\n\nReplace HALF with BIAS, defined as the upper middle code. This fixes the\nwarnings, since the value can be exactly represented with mixeng_real.\n\nSigned-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>\nAcked-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nMessage-Id: <20260423-audio-v1-3-e1d6b65c76f9@rsg.ci.i.u-tokyo.ac.jp>\n---\n audio/mixeng_template.h | 16 +++++++---------\n 1 file changed, 7 insertions(+), 9 deletions(-)","diff":"diff --git a/audio/mixeng_template.h b/audio/mixeng_template.h\nindex 5b0014bdd9a..6db742188ed 100644\n--- a/audio/mixeng_template.h\n+++ b/audio/mixeng_template.h\n@@ -28,7 +28,7 @@\n  */\n \n #ifndef SIGNED\n-#define HALF (IN_MAX >> 1)\n+#define BIAS ((IN_T)1 << (SHIFT - 1))\n #endif\n \n #define ET glue (ENDIAN_CONVERSION, glue (glue (glue (_, ITYPE), BSIZE), _t))\n@@ -43,13 +43,13 @@ static inline mixeng_real glue (conv_, ET) (IN_T v)\n #ifdef SIGNED\n     return nv * (2.f / ((mixeng_real)IN_MAX - IN_MIN));\n #else\n-    return ((mixeng_real)nv - HALF) * (2.f / (mixeng_real)IN_MAX);\n+    return ((mixeng_real)nv - BIAS) * (1.f / BIAS);\n #endif\n #else  /* !RECIPROCAL */\n #ifdef SIGNED\n     return nv / (((mixeng_real)IN_MAX - IN_MIN) / 2.f);\n #else\n-    return ((mixeng_real)nv - HALF) / ((mixeng_real)IN_MAX / 2.f);\n+    return ((mixeng_real)nv - BIAS) / BIAS;\n #endif\n #endif\n }\n@@ -65,9 +65,7 @@ static inline IN_T glue (clip_, ET) (mixeng_real v)\n #ifdef SIGNED\n     return ENDIAN_CONVERT((IN_T)(v * (((mixeng_real)IN_MAX - IN_MIN) / 2.f)));\n #else\n-    return ENDIAN_CONVERT(MIN((int64_t)((v * ((mixeng_real)IN_MAX / 2.f)) +\n-                                        HALF),\n-                              IN_MAX));\n+    return ENDIAN_CONVERT(MIN((int64_t)(v * BIAS) + BIAS, IN_MAX));\n #endif\n }\n \n@@ -79,7 +77,7 @@ static inline int64_t glue (conv_, ET) (IN_T v)\n #ifdef SIGNED\n     return ((int64_t) nv) << (32 - SHIFT);\n #else\n-    return ((int64_t) nv - HALF) << (32 - SHIFT);\n+    return ((int64_t) nv - BIAS) << (32 - SHIFT);\n #endif\n }\n \n@@ -94,7 +92,7 @@ static inline IN_T glue (clip_, ET) (int64_t v)\n #ifdef SIGNED\n     return ENDIAN_CONVERT ((IN_T) (v >> (32 - SHIFT)));\n #else\n-    return ENDIAN_CONVERT ((IN_T) ((v >> (32 - SHIFT)) + HALF));\n+    return ENDIAN_CONVERT((IN_T)((v >> (32 - SHIFT)) + BIAS));\n #endif\n }\n #endif\n@@ -150,5 +148,5 @@ static void glue (glue (clip_, ET), _from_mono)\n }\n \n #undef ET\n-#undef HALF\n+#undef BIAS\n #undef IN_T\n","prefixes":["PULL","13/15"]}