summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Midgley <bmidgley@xmission.com>2007-12-14 06:43:06 +0000
committerBrad Midgley <bmidgley@xmission.com>2007-12-14 06:43:06 +0000
commit9a14d423e7def6933b4df4bae8e9185a62b346ea (patch)
tree729cc1d3b44af742b0d660a0fa597dbc5a8937d5
parentc1ce3b25c4981ae88218fa46921969260b3afc43 (diff)
push in-place-shift optimization up into scalefactors section
-rw-r--r--sbc/sbc.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/sbc/sbc.c b/sbc/sbc.c
index a192ad83..36f6696b 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1123,23 +1123,29 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
produced += frame->subbands;
crc_pos += frame->subbands;
+
+ /* this is temporary until we use an in-place shift above */
+ if(produced % 8) {
+ data[produced >> 3] >>= 8 - (produced % 8);
+ crc_header[crc_pos >> 3] >>= 8 - (crc_pos % 8);
+ }
}
for (ch = 0; ch < frame->channels; ch++) {
for (sb = 0; sb < frame->subbands; sb++) {
- if (produced % 8 == 0)
- data[produced / 8] = 0;
- data[produced >> 3] |= ((frame->scale_factor[ch][sb] & 0x0F) << (4 - (produced % 8)));
- crc_header[crc_pos >> 3] |= ((frame->scale_factor[ch][sb] & 0x0F) << (4 - (crc_pos % 8)));
+ data[produced >> 3] <<= 4;
+ crc_header[crc_pos >> 3] <<= 4;
+ data[produced >> 3] |= frame->scale_factor[ch][sb] & 0x0F;
+ crc_header[crc_pos >> 3] |= frame->scale_factor[ch][sb] & 0x0F;
produced += 4;
crc_pos += 4;
}
}
- /* this is temporary until we use an in-place shift above */
- if(produced % 8)
- data[produced >> 3] >>= 8 - (produced % 8);
+ /* align the last crc byte */
+ if(crc_pos % 8)
+ crc_header[crc_pos >> 3] <<= 8 - (crc_pos % 8);
data[3] = sbc_crc8(crc_header, crc_pos);