From nobody Sat Jul 12 06:02:38 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085611; cv=none; d=zohomail.com; s=zohoarc; b=SQ9kQZzLa7XG/m1bIgAGtodx1xhxvEmBvkSsSGBlmN0i4B2rRQ+/WqzEjfmwC9xbFrf8acxMDy1FSq4NFzylfyxhTbMFQbE5LZ54dppeCTiJL9wtcsyzjWbvqbFP6/jgUwA+Hwnmp3sTExWd1rFvYAcTjo8jXyMIw1Gq6W6bWgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085611; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sQ9+mo9N6X1dx7pB9GOrfGo4mTgvCi6rRd/ddPf4sk8=; b=K9Agjt4XMW8dcY+nr10jlXWuqrcKEzVe+H9o3WMibHkCXNeuJqmaHEjPz0lyg+uaISTRMh05hd04Bby1N/u2XozKAGmVvrLPNWeju9sFxiS4nRjoupZtu1O1rx0B8qCeq4g1zm/4SbuRQqObvRXd7zVKQa4lfL1ND2tmR/1XeaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085611676350.29622212149354; Sun, 5 Mar 2023 22:53:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4im-0005FQ-P6; Mon, 06 Mar 2023 01:53:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4il-00057C-25 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4ij-0000cs-Iz for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:18 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-l5lh--aBPlKbJgv0fEymUw-1; Mon, 06 Mar 2023 01:53:12 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A9A4803513; Mon, 6 Mar 2023 06:53:12 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7416F40C10FA; Mon, 6 Mar 2023 06:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQ9+mo9N6X1dx7pB9GOrfGo4mTgvCi6rRd/ddPf4sk8=; b=f0vwBkZP96swREZ6KaUzQHXkMcUn7muu1VpAT326LAI2ldedBjr84rczxIFpzoQhI404Oq T0OylF9flm7ffXWIMRPl74VPKMuje/rypCI0epY+hv+gzOWuWAaoirPo1cMaleZ7x42kOy XT0qIihgppGHzViPC0h5f+IoH8+zMNs= X-MC-Unique: l5lh--aBPlKbJgv0fEymUw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 15/27] audio: make the resampling code greedy Date: Mon, 6 Mar 2023 10:51:50 +0400 Message-Id: <20230306065202.2160066-16-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085613103100003 From: Volker R=C3=BCmelin Read the maximum possible number of audio frames instead of the minimum necessary number of frames when the audio stream is downsampled and the output buffer is limited. This makes the function symmetrical to upsampling when the input buffer is limited. The maximum possible number of frames is written here. With this change it's easier to calculate the exact number of audio frames the resample function will read or write. These two functions will be introduced later. Acked-by: Mark Cave-Ayland Acked-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-3-vr_qemu@t-online.de> --- audio/rate_template.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/audio/rate_template.h b/audio/rate_template.h index b432719ebb..6648f0d2e5 100644 --- a/audio/rate_template.h +++ b/audio/rate_template.h @@ -40,8 +40,6 @@ void NAME (void *opaque, struct st_sample *ibuf, struct s= t_sample *obuf, int64_t t; #endif =20 - ilast =3D rate->ilast; - istart =3D ibuf; iend =3D ibuf + *isamp; =20 @@ -59,15 +57,17 @@ void NAME (void *opaque, struct st_sample *ibuf, struct= st_sample *obuf, return; } =20 - while (obuf < oend) { + /* without input samples, there's nothing to do */ + if (ibuf >=3D iend) { + *osamp =3D 0; + return; + } =20 - /* Safety catch to make sure we have input samples. */ - if (ibuf >=3D iend) { - break; - } + ilast =3D rate->ilast; =20 - /* read as many input samples so that ipos > opos */ + while (true) { =20 + /* read as many input samples so that ipos > opos */ while (rate->ipos <=3D (rate->opos >> 32)) { ilast =3D *ibuf++; rate->ipos++; @@ -78,6 +78,11 @@ void NAME (void *opaque, struct st_sample *ibuf, struct = st_sample *obuf, } } =20 + /* make sure that the next output sample can be written */ + if (obuf >=3D oend) { + break; + } + icur =3D *ibuf; =20 /* wrap ipos and opos around long before they overflow */ --=20 2.39.2