summaryrefslogtreecommitdiffstats
path: root/sbc
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-08-21 21:32:09 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-08-21 21:32:09 +0000
commitb1618922db92f9bc65b0841f66eb71742bc1b553 (patch)
tree401dbbda10d88248b2dfd3c9961363f7f6b121d4 /sbc
parent38c5be0cc3029bf78445be15470d18343a5b4dae (diff)
Add swap member to sbc struct and fix pcm plugin to not swap the buffer.
Diffstat (limited to 'sbc')
-rw-r--r--sbc/sbc.c18
-rw-r--r--sbc/sbc.h1
-rw-r--r--sbc/sbcdec.c1
-rw-r--r--sbc/sbcenc.c1
4 files changed, 18 insertions, 3 deletions
diff --git a/sbc/sbc.c b/sbc/sbc.c
index d485a5fd..d27c1e9a 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1289,6 +1289,7 @@ int sbc_init(sbc_t *sbc, unsigned long flags)
sbc->subbands = 8;
sbc->blocks = 16;
sbc->bitpool = 32;
+ sbc->swap = 0;
return 0;
}
@@ -1341,8 +1342,14 @@ int sbc_decode(sbc_t *sbc, void *data, int count)
for (ch = 0; ch < priv->frame.channels; ch++) {
int16_t s;
s = priv->frame.pcm_sample[ch][i];
- *ptr++ = (s & 0xff00) >> 8;
- *ptr++ = (s & 0x00ff);
+
+ if (sbc->swap) {
+ *ptr++ = (s & 0xff00) >> 8;
+ *ptr++ = (s & 0x00ff);
+ } else {
+ *ptr++ = (s & 0x00ff);
+ *ptr++ = (s & 0xff00) >> 8;
+ }
}
}
@@ -1387,7 +1394,12 @@ int sbc_encode(sbc_t *sbc, void *data, int count)
for (i = 0; i < priv->frame.subbands * priv->frame.blocks; i++) {
for (ch = 0; ch < sbc->channels; ch++) {
- int16_t s = (ptr[0] & 0xff) << 8 | (ptr[1] & 0xff);
+ int16_t s;
+
+ if (sbc->swap)
+ s = (ptr[0] & 0xff) << 8 | (ptr[1] & 0xff);
+ else
+ s = (ptr[0] & 0xff) | (ptr[1] & 0xff) << 8;
ptr += 2;
priv->frame.pcm_sample[ch][i] = s;
}
diff --git a/sbc/sbc.h b/sbc/sbc.h
index 70881c12..11d9740d 100644
--- a/sbc/sbc.h
+++ b/sbc/sbc.h
@@ -40,6 +40,7 @@ struct sbc_struct {
int blocks;
int subbands;
int bitpool;
+ int swap;
void *data;
int size;
diff --git a/sbc/sbcdec.c b/sbc/sbcdec.c
index b5305550..d84a631b 100644
--- a/sbc/sbcdec.c
+++ b/sbc/sbcdec.c
@@ -90,6 +90,7 @@ static void decode(char *filename, char *audiodevice, int tofile)
}
sbc_init(&sbc, 0L);
+ sbc.swap = 1;
framelen = sbc_decode(&sbc, stream, streamlen);
printf("%d Hz, %d channels\n", sbc.rate, sbc.channels);
diff --git a/sbc/sbcenc.c b/sbc/sbcenc.c
index 8919fb92..2334f8d3 100644
--- a/sbc/sbcenc.c
+++ b/sbc/sbcenc.c
@@ -144,6 +144,7 @@ static void encode(char *filename, int subbands, int joint)
sbc.channels = BE_INT(au_hdr->channels);
sbc.subbands = subbands;
sbc.joint = joint;
+ sbc.swap = 1;
count = BE_INT(au_hdr->data_size);
size = len - BE_INT(au_hdr->hdr_size);
memmove(buf, buf + BE_INT(au_hdr->hdr_size), size);