[FFmpeg-cvslog] avfilter/src_avsynctest: fix beep amplitude scaling

Paul B Mahol git at videolan.org
Wed May 10 13:59:35 EEST 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed May 10 11:34:31 2023 +0200| [5e7042fa31c59e99969ad580d45e588d54d1f1e3] | committer: Paul B Mahol

avfilter/src_avsynctest: fix beep amplitude scaling

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e7042fa31c59e99969ad580d45e588d54d1f1e3
---

 libavfilter/src_avsynctest.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavfilter/src_avsynctest.c b/libavfilter/src_avsynctest.c
index 78e4a2ba50..cfdf1bc78e 100644
--- a/libavfilter/src_avsynctest.c
+++ b/libavfilter/src_avsynctest.c
@@ -170,7 +170,7 @@ static av_cold int config_props(AVFilterLink *outlink)
 
 #define FPI 0x8000
 
-static int32_t sin32(int32_t x, int shift)
+static int32_t sin32(int32_t x, AVRational scale)
 {
     const double pi = M_PI;
     const int32_t a = ((2.0 * pi) * (1 << 24));
@@ -194,7 +194,8 @@ static int32_t sin32(int32_t x, int shift)
     result = a + t2;
     result *= x;
     result += (1U << 31);
-    result >>= (32 - shift);
+    result >>= 17;
+    result = av_rescale(result, scale.num, scale.den);
 
     return result;
 }
@@ -203,7 +204,7 @@ static int audio_frame(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     AVSyncTestContext *s = ctx->priv;
-    const int a = lrintf(s->amplitude * 15);
+    const AVRational a = av_d2q(s->amplitude, 32768);
     int64_t duration[2];
     int64_t delta;
     AVFrame *out;



More information about the ffmpeg-cvslog mailing list