From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: [PATCH] sbc: ensure 16-byte buffer position alignment for 4 subbands encoding
Date: Mon, 16 Mar 2009 21:35:02 +0200 [thread overview]
Message-ID: <200903162135.02064.siarhei.siamashka@nokia.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 264 bytes --]
Hello,
Buffer position in X array was not always 16-bytes aligned. Strict 16-byte
alignment is strictly required for powerpc altivec simd optimizations because
altivec does not have support for unaligned vector loads at all.
--
Best regards,
Siarhei Siamashka
[-- Attachment #2: 0003-sbc-ensure-16-byte-buffer-position-alignment-for-4.patch --]
[-- Type: text/x-diff, Size: 1831 bytes --]
From b8570469477f1a92089cd12bcf6c07247ca110d4 Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
Date: Mon, 16 Mar 2009 02:27:26 +0200
Subject: [PATCH] sbc: ensure 16-byte buffer position alignment for 4 subbands encoding
Buffer position in X array was not always 16-bytes aligned.
Strict 16-byte alignment is strictly required for powerpc altivec
simd optimizations because altivec does not have support for
unaligned vector loads at all.
---
sbc/sbc.c | 2 +-
sbc/sbc_primitives.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/sbc/sbc.c b/sbc/sbc.c
index a33ed57..f40def8 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -924,7 +924,7 @@ static void sbc_encoder_init(struct sbc_encoder_state *state,
const struct sbc_frame *frame)
{
memset(&state->X, 0, sizeof(state->X));
- state->position = SBC_X_BUFFER_SIZE - frame->subbands * 9;
+ state->position = (SBC_X_BUFFER_SIZE - frame->subbands * 9) & ~7;
sbc_init_primitives(state);
}
diff --git a/sbc/sbc_primitives.c b/sbc/sbc_primitives.c
index 6b0be3f..2105280 100644
--- a/sbc/sbc_primitives.c
+++ b/sbc/sbc_primitives.c
@@ -231,12 +231,12 @@ static SBC_ALWAYS_INLINE int sbc_encoder_process_input_s4_internal(
/* handle X buffer wraparound */
if (position < nsamples) {
if (nchannels > 0)
- memcpy(&X[0][SBC_X_BUFFER_SIZE - 36], &X[0][position],
+ memcpy(&X[0][SBC_X_BUFFER_SIZE - 40], &X[0][position],
36 * sizeof(int16_t));
if (nchannels > 1)
- memcpy(&X[1][SBC_X_BUFFER_SIZE - 36], &X[1][position],
+ memcpy(&X[1][SBC_X_BUFFER_SIZE - 40], &X[1][position],
36 * sizeof(int16_t));
- position = SBC_X_BUFFER_SIZE - 36;
+ position = SBC_X_BUFFER_SIZE - 40;
}
#define PCM(i) (big_endian ? \
--
1.5.6.5
next reply other threads:[~2009-03-16 19:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-16 19:35 Siarhei Siamashka [this message]
2009-03-14 6:17 ` [PATCH] sbc: ensure 16-byte buffer position alignment for 4 subbands encoding 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=200903162135.02064.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