summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Midgley <bmidgley@xmission.com>2007-12-14 00:13:07 +0000
committerBrad Midgley <bmidgley@xmission.com>2007-12-14 00:13:07 +0000
commitc5e43eefcc34641b875f2565c1c4b5b4616d3f58 (patch)
tree14d246b847f2ee061c6c55b302e6aabe30123e46
parentf77777a5ab50a1f49f0717776d92e1337f09422b (diff)
downloadbluez-c5e43eefcc34641b875f2565c1c4b5b4616d3f58.tar.gz
roll back the shift-in-place bitpack optimization while we figure out if
it tickles a bug or creates a bug for 4 subbands
-rw-r--r--sbc/sbc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sbc/sbc.c b/sbc/sbc.c
index 647760bba..86efadcfb 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -1154,20 +1154,19 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
(uint16_t) ((((frame->sb_sample_f[blk][ch][sb]*levels[ch][sb]) >>
(frame->scale_factor[ch][sb] + 1)) +
levels[ch][sb]) >> 1);
- audio_sample <<= 16 - bits[ch][sb];
for (bit = 0; bit < bits[ch][sb]; bit++) {
- data[produced >> 3] <<= 1;
- if(audio_sample & 0x8000)
- data[produced >> 3] |= 0x1;
- audio_sample <<= 1;
+ 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));
produced++;
}
}
}
}
}
- /* align the last byte */
- if(produced % 8) data[produced >> 3] <<= 8 - (produced % 8);
return (produced + 7) >> 3;
}