From: Marton Balint <cus@passwd.hu>
To: ffmpeg-devel@ffmpeg.org
Cc: Marton Balint <cus@passwd.hu>
Subject: [FFmpeg-devel] [PATCH 1/2] swresample/resample: fix rounding errors with filter_size=1 and phase_shift=0
Date: Tue, 27 Feb 2024 10:48:09 +0100
Message-ID: <20240227094810.1182-1-cus@passwd.hu> (raw)
In-Reply-To: <20240226221940.GV6420@pb2>
Depending on input chunk size noticable corrpution was hearable, here is an
example command line:
ffplay -f lavfi -i "sine=440:r=8000:samples_per_frame=32,aresample=24000:filter_size=1:phase_shift=0"
Fix this by rounding the fixed point fractions up instead of down.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libswresample/resample.c | 4 ++--
tests/fate/libswresample.mak | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libswresample/resample.c b/libswresample/resample.c
index bd54a7002f..17cebad01b 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -357,8 +357,8 @@ static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, A
*consumed = 0;
if (c->filter_length == 1 && c->phase_count == 1) {
- int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*c->index;
- int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
+ int64_t index2= (1LL<<32)*c->frac/c->src_incr + (1LL<<32)*c->index + 1;
+ int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr + 1;
int new_size = (src_size * (int64_t)c->src_incr - c->frac + c->dst_incr - 1) / c->dst_incr;
dst_size = FFMAX(FFMIN(dst_size, new_size), 0);
diff --git a/tests/fate/libswresample.mak b/tests/fate/libswresample.mak
index 2fc55ea61a..0971a6b3ba 100644
--- a/tests/fate/libswresample.mak
+++ b/tests/fate/libswresample.mak
@@ -347,13 +347,13 @@ endef
fate-swr-resample_nn-fltp-44100-8000: CMP_TARGET = 591.03
fate-swr-resample_nn-fltp-44100-8000: SIZE_TOLERANCE = 529200 - 20486
-fate-swr-resample_nn-fltp-8000-44100: CMP_TARGET = 3163.32
+fate-swr-resample_nn-fltp-8000-44100: CMP_TARGET = 3156.61
fate-swr-resample_nn-fltp-8000-44100: SIZE_TOLERANCE = 96000 - 20480
fate-swr-resample_nn-s16p-44100-8000: CMP_TARGET = 590.98
fate-swr-resample_nn-s16p-44100-8000: SIZE_TOLERANCE = 529200 - 20486
-fate-swr-resample_nn-s16p-8000-44100: CMP_TARGET = 3163.39
+fate-swr-resample_nn-s16p-8000-44100: CMP_TARGET = 3156.61
fate-swr-resample_nn-s16p-8000-44100: SIZE_TOLERANCE = 96000 - 20480
define ARESAMPLE_ASYNC
--
2.35.3
_______________________________________________
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".
next prev parent reply other threads:[~2024-02-27 9:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 0:45 [FFmpeg-devel] [PATCH 1/4] fate: never generate auto-generated references Marton Balint
2024-02-26 0:45 ` [FFmpeg-devel] [PATCH 2/4] swresample/resample: rework resample_one function to work the same way as the others Marton Balint
2024-02-26 22:19 ` Michael Niedermayer
2024-02-27 9:48 ` Marton Balint [this message]
2024-02-27 9:48 ` [FFmpeg-devel] [PATCH 2/2] " Marton Balint
2024-02-27 17:54 ` Michael Niedermayer
2024-02-27 20:50 ` Marton Balint
2024-02-28 22:45 ` Michael Niedermayer
2024-02-29 0:19 ` Marton Balint
2024-02-29 12:22 ` Michael Niedermayer
2024-02-29 17:55 ` Marton Balint
2024-03-01 3:30 ` Michael Niedermayer
2024-03-01 22:24 ` Marton Balint
2024-02-27 17:53 ` [FFmpeg-devel] [PATCH 1/2] swresample/resample: fix rounding errors with filter_size=1 and phase_shift=0 Michael Niedermayer
2024-02-26 0:45 ` [FFmpeg-devel] [PATCH 3/4] fate/libswresample: force number of samples for the input of aresample async tests Marton Balint
2024-02-26 0:45 ` [FFmpeg-devel] [PATCH 4/4] avformat/wavdec: dynamically set max_size by default Marton Balint
2024-02-28 23:12 ` Andreas Rheinhardt
2024-02-29 0:18 ` Marton Balint
2024-03-01 22:30 ` Marton Balint
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240227094810.1182-1-cus@passwd.hu \
--to=cus@passwd.hu \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git