From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: [PATCH] sbc: fix for overflow bug in quantization code
Date: Wed, 17 Dec 2008 22:43:27 +0200 [thread overview]
Message-ID: <200812172243.27442.siarhei.siamashka@nokia.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 384 bytes --]
Hello all,
This simple patch resolves one more SBC encoding quality issue. Now SBC
audio encoding quality should be fine in almost all cases after applying it
together with a new 8 subband filter.
The patch conflicts with the bitstream packing optimization, but I hope that
after all the encoding quality problems are fixed, we can get back to it.
Best regards,
Siarhei Siamashka
[-- Attachment #2: 0001-sbc-fix-for-overflow-bug-in-quantization-code.patch --]
[-- Type: text/x-diff, Size: 1194 bytes --]
>From 12088ac2053709bf89c3c84d47aef46b7f2da475 Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
Date: Wed, 17 Dec 2008 22:32:11 +0200
Subject: [PATCH] sbc: fix for overflow bug in quantization code
The result of multiplication does not always fit into 32-bits. Using 64-bit
calculations helps to avoid overflows and sound quality problems in encoded
audio. Overflows are more likely to show up when using high values for
bitpool setting.
Signed-off-by: Siarhei Siamashka <siarhei.siamashka@nokia.com>
---
sbc/sbc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sbc/sbc.c b/sbc/sbc.c
index 7072673..6624921 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1085,7 +1085,7 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
for (sb = 0; sb < frame->subbands; sb++) {
if (levels[ch][sb] > 0) {
audio_sample =
- (uint16_t) ((((frame->sb_sample_f[blk][ch][sb]*levels[ch][sb]) >>
+ (uint16_t) (((((int64_t)frame->sb_sample_f[blk][ch][sb]*levels[ch][sb]) >>
(frame->scale_factor[ch][sb] + 1)) +
levels[ch][sb]) >> 1);
audio_sample <<= 16 - bits[ch][sb];
--
1.5.6.5
next reply other threads:[~2008-12-17 20:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-17 20:43 Siarhei Siamashka [this message]
2008-12-18 22:59 ` [PATCH] sbc: fix for overflow bug in quantization code Marcel Holtmann
2008-12-19 21:25 ` Siarhei Siamashka
2008-12-19 22:23 ` Luiz Augusto von Dentz
2008-12-19 22:51 ` Brad Midgley
2008-12-22 11:37 ` Siarhei Siamashka
2008-12-22 12:29 ` Marcel Holtmann
2008-12-22 17:50 ` Luiz Augusto von Dentz
2008-12-29 10:22 ` Siarhei Siamashka
2008-12-29 10:33 ` Marcel Holtmann
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=200812172243.27442.siarhei.siamashka@nokia.com \
--to=siarhei.siamashka@nokia.com \
--cc=linux-bluetooth@vger.kernel.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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox