From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B6AD9432AA for ; Sat, 28 May 2022 08:45:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 046B568B56B; Sat, 28 May 2022 11:45:56 +0300 (EEST) Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C62B568AF21 for ; Sat, 28 May 2022 11:45:49 +0300 (EEST) Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-3043b3f7d8fso57931007b3.8 for ; Sat, 28 May 2022 01:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HRs3sZ8r/WR04QRh2ZAkGSbKHQkuJpeuRD8cAywGVzQ=; b=kAp0c51e+pGe1XPNVuBp8bNclt7ZTuDsDy/mRQrBYNv98DJRE6JsUALD2Y5Sc88orq HCsXK0CGsQSuw5Qi+WWUuw/xDcEMWLKeYTYpfFl6pTqxVo+bqqsp/Y7V/uG8ulbzlpL0 /ftf+LqlRwQduJFvQgbTqz3kvbFkOBNGI+VCG2bQUjt8RNA3yWabTdmU4xPdNS6UAjm+ r8ECVCh1cJFFr8chk/QUEROFtI0iV/xanWr1zJM+pT9p3pGeaMDxHw+4OZozNp/ANOog KGSsi8Hb/jIgJBsMGG75FxqKPprxBn4sFmOepQgjHc0hkB9N/kE83bT8/3TOhbctFDrj T/kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HRs3sZ8r/WR04QRh2ZAkGSbKHQkuJpeuRD8cAywGVzQ=; b=69/DEJVzxKbFHkLWqJ4UPKIcWeKhIAp1bINXcq+JY8sm5HG2MpQc7ixURcSUZMUcEk HAk3jda44dj2HqaIJCT6SL/VqAFwSa9fAdDj0nHMmJWoxQCG98qUSLXu1I8BFsx5IFXS VwWyYcJ9uM29+pjvmi9yoDz8krFBTqtZsYK1j27/+3XRWrlMIYHwvpGG8pe/jjbIpB3r HgDXHvg6xC1A3gSxauTEsUlaatk0l3TQ0BysIH1ESooPzOiYlztEYQGyrREvvDgoynUk xUAiCloygevwp8FxOR03q8dsRH6gTeu5VY7Umc05cCIFuhUPu4Tjw7HNKfUG9/ZI7oax 6V4g== X-Gm-Message-State: AOAM530Hb++6qQLy8r3TRGPx19NkiEXatPjOFSSsWEU5Z6awBQ9IduOj WbFHs1wObb5rCZf3ttXgucsh+6NFhcX0oUNNdP5OqvKX X-Google-Smtp-Source: ABdhPJxyjSe5kbhYurLi6qGSNsJw+sHRkkwFmwOoHCiu+r9EaP0tygbAapj/tYtIjQ8Wd6IIMKoO7Zx4Q69Yu/LJJnM= X-Received: by 2002:a81:6704:0:b0:30c:18fb:1926 with SMTP id b4-20020a816704000000b0030c18fb1926mr1203580ywc.516.1653727548585; Sat, 28 May 2022 01:45:48 -0700 (PDT) MIME-Version: 1.0 References: <20220528083921.16538-1-shbisws@gmail.com> In-Reply-To: <20220528083921.16538-1-shbisws@gmail.com> From: Paul B Mahol Date: Sat, 28 May 2022 10:48:36 +0200 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH] avfilter/asrc_sine: Generate full amplitude sine wave. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Santanu Biswas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sat, May 28, 2022 at 10:39 AM Santanu Biswas wrote: > Previously, generating a full amplitude sine wave require to either > use the 'volume' filter in combination with this filter or manually > generate sine wave using 'aevalsrc' (e.g "aevalsrc=sin(2*PI*t*440)"). > This method is not bit-exact; therefore it is much coherent to not > scale the amplitude by 1/8 and keep it as it is. > > I think you are breaking fate tests with this change. Also why this can not be set at start instead of being hardcoded? > Signed-off-by: Santanu Biswas > --- > doc/filters.texi | 2 +- > libavfilter/asrc_sine.c | 8 ++------ > 2 files changed, 3 insertions(+), 7 deletions(-) > > diff --git a/doc/filters.texi b/doc/filters.texi > index 0e10946cca..a42e27b9b5 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -7452,7 +7452,7 @@ Set number of taps for low-pass filter. > > @section sine > > -Generate an audio signal made of a sine wave with amplitude 1/8. > +Generate an audio signal made of a sine wave. > > The audio signal is bit-exact. > > diff --git a/libavfilter/asrc_sine.c b/libavfilter/asrc_sine.c > index c0d8d2265b..6c2f9d40f3 100644 > --- a/libavfilter/asrc_sine.c > +++ b/libavfilter/asrc_sine.c > @@ -83,13 +83,11 @@ static const AVOption sine_options[] = { > AVFILTER_DEFINE_CLASS(sine); > > #define LOG_PERIOD 15 > -#define AMPLITUDE 4095 > -#define AMPLITUDE_SHIFT 3 > > static void make_sin_table(int16_t *sin) > { > unsigned half_pi = 1 << (LOG_PERIOD - 2); > - unsigned ampls = AMPLITUDE << AMPLITUDE_SHIFT; > + unsigned ampls = 32767; > uint64_t unit2 = (uint64_t)(ampls * ampls) << 32; > unsigned step, i, c, s, k, new_k, n2; > > @@ -116,9 +114,7 @@ static void make_sin_table(int16_t *sin) > sin[half_pi - i - step / 2] = (k * c + 0x8000) >> 16; > } > } > - /* Unshift amplitude */ > - for (i = 0; i <= half_pi; i++) > - sin[i] = (sin[i] + (1 << (AMPLITUDE_SHIFT - 1))) >> > AMPLITUDE_SHIFT; > + > /* Use symmetries to fill the other three quarters */ > for (i = 0; i < half_pi; i++) > sin[half_pi * 2 - i] = sin[i]; > -- > 2.35.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".