summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-08-27 13:38:17 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-08-27 13:38:17 +0000
commit34207c770a372a5d847fe60423dc82a358faab6b (patch)
treefe0411346eb92520dd7229e3ea91d2684623ff3c
parent22e31062ad9458a148a4e4203fb3aed43e65dfa4 (diff)
Make SBC frame header endian safe
-rw-r--r--sbc/sbcinfo.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sbc/sbcinfo.c b/sbc/sbcinfo.c
index e34f5618..e8fb398f 100644
--- a/sbc/sbcinfo.c
+++ b/sbc/sbcinfo.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <libgen.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
struct sbc_frame_hdr {
uint8_t syncword:8; /* Sync word */
uint8_t subbands:1; /* Subbands */
@@ -44,6 +45,20 @@ struct sbc_frame_hdr {
uint8_t bitpool:8; /* Bitpool */
uint8_t crc_check:8; /* CRC check */
} __attribute__ ((packed));
+#elif __BYTE_ORDER == __BIG_ENDIAN
+struct sbc_frame_hdr {
+ uint8_t syncword:8; /* Sync word */
+ uint8_t sampling_frequency:2; /* Sampling frequency */
+ uint8_t blocks:2; /* Blocks */
+ uint8_t channel_mode:2; /* Channel mode */
+ uint8_t allocation_method:1; /* Allocation method */
+ uint8_t subbands:1; /* Subbands */
+ uint8_t bitpool:8; /* Bitpool */
+ uint8_t crc_check:8; /* CRC check */
+} __attribute__ ((packed));
+#else
+#error "Unknown byte order"
+#endif
static int calc_frame_len(struct sbc_frame_hdr *hdr)
{