summaryrefslogtreecommitdiffstats
path: root/sbc/sbcenc.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-02-19 19:47:25 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-02-19 19:47:25 +0000
commitce342bf2524b69b19ea5a4ad604faf1aa40ad19c (patch)
treebfc6130a2e8ddc83ad883f42e31b4f1e8b41f599 /sbc/sbcenc.c
parenta8bdd2f6be0cdb932110290f3534a525d99c5031 (diff)
Introduce sbc new API.
Diffstat (limited to 'sbc/sbcenc.c')
-rw-r--r--sbc/sbcenc.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/sbc/sbcenc.c b/sbc/sbcenc.c
index cf5e1533..e17f8fdb 100644
--- a/sbc/sbcenc.c
+++ b/sbc/sbcenc.c
@@ -140,11 +140,31 @@ static void encode(char *filename, int subbands, int joint)
sbc_init(&sbc, 0L);
- sbc.rate = BE_INT(au_hdr->sample_rate);
- sbc.channels = BE_INT(au_hdr->channels);
- sbc.subbands = subbands;
- sbc.joint = joint;
- sbc.swap = 1;
+ switch (BE_INT(au_hdr->sample_rate)) {
+ case 16000:
+ sbc.frequency = SBC_FREQ_16000;
+ break;
+ case 32000:
+ sbc.frequency = SBC_FREQ_32000;
+ break;
+ case 44100:
+ sbc.frequency = SBC_FREQ_44100;
+ break;
+ case 48000:
+ sbc.frequency = SBC_FREQ_48000;
+ break;
+ }
+
+ sbc.subbands = subbands == 4 ? SBC_SB_4 : SBC_SB_8;
+
+ if (BE_INT(au_hdr->channels) == 1)
+ sbc.mode = SBC_MODE_MONO;
+ else if (joint)
+ sbc.mode = SBC_MODE_JOINT_STEREO;
+ else
+ sbc.mode = SBC_MODE_STEREO;
+
+ sbc.endian = SBC_BE;
count = BE_INT(au_hdr->data_size);
size = len - BE_INT(au_hdr->hdr_size);
memmove(input, input + BE_INT(au_hdr->hdr_size), size);