Index: sbc/sbc.c =================================================================== RCS file: /cvsroot/bluetooth-alsa/btsco/sbc/sbc.c,v retrieving revision 1.33 diff -u -b -B -w -p -r1.33 sbc.c --- sbc/sbc.c 17 May 2005 06:48:02 -0000 1.33 +++ sbc/sbc.c 18 May 2005 22:32:13 -0000 @@ -391,7 +391,6 @@ static int sbc_unpack_frame(const u_int8 int bits[2][8]; /* bits distribution */ int levels[2][8]; /* levels derived from that */ - double scalefactor[2][8]; /* derived from frame->scale_factors */ if (len < 4) return -1; @@ -525,7 +524,6 @@ static int sbc_unpack_frame(const u_int8 for (ch = 0; ch < frame->channels; ch++) { for (sb = 0; sb < frame->subbands; sb++) { levels[ch][sb] = (1 << bits[ch][sb]) - 1; - scalefactor[ch][sb] = 2 << frame->scale_factor[ch][sb]; } } @@ -534,8 +532,8 @@ static int sbc_unpack_frame(const u_int8 for (sb = 0; sb < frame->subbands; sb++) { if (levels[ch][sb] > 0) { frame->sb_sample[blk][ch][sb] = - scalefactor[ch][sb] * ((frame->audio_sample[blk][ch][sb] * 2.0 + 1.0) / - levels[ch][sb] - 1.0); + (((frame->audio_sample[blk][ch][sb] << 1) | 1) << frame->scale_factor[ch][sb])/(float)levels[ch][sb] + - (1 << frame->scale_factor[ch][sb]); } else { frame->sb_sample[blk][ch][sb] = 0; } @@ -547,10 +545,11 @@ static int sbc_unpack_frame(const u_int8 for (blk = 0; blk < frame->blocks; blk++) { for (sb = 0; sb < frame->subbands; sb++) { if (frame->join & (0x01 << sb)) { - frame->sb_sample[blk][0][sb] = + double temp = frame->sb_sample[blk][0][sb] + frame->sb_sample[blk][1][sb]; frame->sb_sample[blk][1][sb] = - frame->sb_sample[blk][0][sb] - 2 * frame->sb_sample[blk][1][sb]; + frame->sb_sample[blk][0][sb] - frame->sb_sample[blk][1][sb]; + frame->sb_sample[blk][0][sb] = temp; } } }