summaryrefslogtreecommitdiffstats
path: root/sbc
diff options
context:
space:
mode:
authorBrad Midgley <bmidgley@xmission.com>2007-11-30 01:20:01 +0000
committerBrad Midgley <bmidgley@xmission.com>2007-11-30 01:20:01 +0000
commit76e595a98b7b73ee54ae17e6162f05ad81c9b654 (patch)
tree3385bcb5b4db32b30b7cd2ec8118e050487a80fc /sbc
parent4161e8201ea54fe605b2aa14d864e0bad941c5d8 (diff)
change inner loop bit packing to use shift-in-place instead of complex ops
Diffstat (limited to 'sbc')
-rw-r--r--sbc/sbc.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sbc/sbc.c b/sbc/sbc.c
index 904227b5..a785c48d 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1162,20 +1162,21 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
audio_sample = 0;
if (bits[ch][sb] != 0) {
+ audio_sample <<= 16 - bits[ch][sb];
for (bit = 0; bit < bits[ch][sb]; bit++) {
- int b; /* A bit */
- if (produced % 8 == 0)
- data[produced >> 3] = 0;
- b = ((audio_sample) >>
- (bits[ch][sb] - bit - 1)) & 0x01;
- data[produced >> 3] |= b << (7 - (produced % 8));
+ data[produced >> 3] <<= 1;
+ if(audio_sample & 0x8000)
+ data[produced >> 3] |= 0x1;
+ audio_sample <<= 1;
produced++;
}
}
}
}
}
-
+ /* align the last byte */
+ if(produced % 8) data[produced >> 3] <<= 8 - (produced % 8);
+
return (produced + 7) >> 3;
}