public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
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 17:55:29 +0200	[thread overview]
Message-ID: <200901051755.29164.siarhei.siamashka@nokia.com> (raw)
In-Reply-To: <d89ddf300901050736n2615d812r85c8cc1d5df36898@mail.gmail.com>

On Monday 05 January 2009 17:36:57 ext Brad Midgley wrote:
> Siarhei
>
> > SBC encoder contains the following fragment:
> >> #if __BYTE_ORDER == __LITTLE_ENDIAN
> >>                       if (sbc->endian == SBC_BE)
> >> #elif __BYTE_ORDER == __BIG_ENDIAN
> >>                       if (sbc->endian == SBC_LE)
> >> #else
> >> #error "Unknown byte order"
> >> #endif
> >>                               s = (ptr[0] & 0xff) << 8 | (ptr[1] &
> >> 0xff); else
> >>                               s = (ptr[0] & 0xff) | (ptr[1] & 0xff) <<
> >> 8;
> >
> > This does not look right. Because as far as I can see, it will work
> > differently on big and little endian systems
>
> I tested it some time ago on powerpc and I know Marcel also has a
> powerpc for testing. I'll need to update my machine for bluez 4.x.
>
> The logic here seems to be to swap bytes if the endian set in the sbc
> struct does not match host endian.

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 second line contains a portable endian neutral read of little endian
data into native format:
>                               s = (ptr[0] & 0xff) | (ptr[1] & 0xff) <<8;

If __BYTE_ORDER is defined as __LITTLE_ENDIAN, the first line is used when
sbc->endian == SBC_BE. But if __BYTE_ORDER is set to __BIG_ENDIAN, the
logic is reversed.

The behaviour and the end result seems to be different for the big endian
and little endian systems. This can be probably easily tested by encoding the
same file by sbcenc on big and little endian systems and comparing results.

-- 
Best regards,
Siarhei Siamashka

  reply	other threads:[~2009-01-05 15:55 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 [this message]
2009-01-05 16:25     ` Brad Midgley
2009-01-05 16:29       ` Brad Midgley
2009-01-05 18:19       ` Siarhei Siamashka
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=200901051755.29164.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