From: Siarhei Siamashka <siarhei.siamashka@nokia.com>
To: "ext Brad Midgley" <bmidgley@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: SBC big endian issues?
Date: Mon, 5 Jan 2009 20:19:15 +0200 [thread overview]
Message-ID: <200901052019.15656.siarhei.siamashka@nokia.com> (raw)
In-Reply-To: <d89ddf300901050825h1654c869l22563783beeee7a8@mail.gmail.com>
On Monday 05 January 2009 18:25:24 ext Brad Midgley wrote:
> Siarhei
>
> > The logic is that the first line contains a portable endian neutral read
> > of
> >
> > big endian data into native format:
> >> s = (ptr[0] & 0xff) << 8 | (ptr[1] &
> >> 0xff);
>
> the intent is to swap bytes using this first statement if either
>
> - host order is little endian and the ptr array is stored big endian
> - host order is big endian and the ptr array is stored little endian
>
> the second case could be done with a cast to a 16-bit int rather than
> bit arithmetic.
>
> We don't exercise all the various cases.
No, it's a bit different. There is no 'swap byte' operation here, but just
portable reading of data in big endian format.
Let's suppose that we have the following two bytes in memory:
0x12 0x34
This equals to 0x1234 for big endian systems or 0x3412 for little endian
systems if you read data via int16_t * pointer.
But in the case of SBC, data is read one byte at a time and results in the
same value regardless of the endianness of the system. It will be always
0x1234 and this is generally a portable, but slow way of reading big endian
data (host system endian order does not matter).
So unless __BYTE_ORDER is somehow defined to be __LITTLE_ENDIAN on big
endian systems (two bugs which cancel each other ;-) ), the code from SBC is
supposed to work incorrectly and sbcenc should produce broken files
with distorted sound (though somewhat resembling the original file). I just
want somebody to verify this on real big endian hardware.
PS. I'm interested in this code because it is very slow and needs to be
optimized. In the case of single channel and no endian conversion, just
memcpy can be used. Other cases can be improved too.
--
Best regards,
Siarhei Siamashka
next prev parent reply other threads:[~2009-01-05 18:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-05 8:15 SBC big endian issues? Siarhei Siamashka
2009-01-05 15:36 ` Brad Midgley
2009-01-05 15:55 ` Siarhei Siamashka
2009-01-05 16:25 ` Brad Midgley
2009-01-05 16:29 ` Brad Midgley
2009-01-05 18:19 ` Siarhei Siamashka [this message]
2009-01-05 19:26 ` Brad Midgley
2009-01-07 12:40 ` Siarhei Siamashka
2009-01-07 13:43 ` Marcel Holtmann
2009-01-16 17:23 ` Siarhei Siamashka
2009-01-16 22:02 ` Luiz Augusto von Dentz
2009-01-17 18:10 ` Siarhei Siamashka
2009-01-19 11:26 ` Siarhei Siamashka
2009-01-19 12:05 ` Marcel Holtmann
2009-01-20 6:22 ` [Patch] SAP client plugin framework Liu, Raymond
2009-01-22 5:05 ` Liu, Raymond
2009-01-19 15:02 ` SBC big endian issues? Brad Midgley
2009-01-20 10:20 ` Siarhei Siamashka
2009-01-20 11:13 ` Siarhei Siamashka
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=200901052019.15656.siarhei.siamashka@nokia.com \
--to=siarhei.siamashka@nokia.com \
--cc=bmidgley@gmail.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