OSDN Git Service

sbc: Fix for SBC encoding with block sizes other than 16
authorSiarhei Siamashka <siarhei.siamashka@nokia.com>
Thu, 29 Jan 2009 16:15:31 +0000 (18:15 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 30 Jul 2012 02:48:28 +0000 (19:48 -0700)
Thanks to Christian Hoene for finding and reporting the
problem. This regression was intruduced in commit
19af3c49e61aa046375497108e05a3a0605da158

sbc/sbc.c

index 8a2d782..29f1d14 100644 (file)
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -651,30 +651,37 @@ static int sbc_analyze_audio(struct sbc_encoder_state *state,
                                struct sbc_frame *frame)
 {
        int ch, blk;
+       int16_t *x;
 
        switch (frame->subbands) {
        case 4:
-               for (ch = 0; ch < frame->channels; ch++)
+               for (ch = 0; ch < frame->channels; ch++) {
+                       x = &state->X[ch][state->position - 16 +
+                                                       frame->blocks * 4];
                        for (blk = 0; blk < frame->blocks; blk += 4) {
                                state->sbc_analyze_4b_4s(
-                                       &state->X[ch][state->position +
-                                                       48 - blk * 4],
+                                       x,
                                        frame->sb_sample_f[blk][ch],
                                        frame->sb_sample_f[blk + 1][ch] -
                                        frame->sb_sample_f[blk][ch]);
+                               x -= 16;
                        }
+               }
                return frame->blocks * 4;
 
        case 8:
-               for (ch = 0; ch < frame->channels; ch++)
+               for (ch = 0; ch < frame->channels; ch++) {
+                       x = &state->X[ch][state->position - 32 +
+                                                       frame->blocks * 8];
                        for (blk = 0; blk < frame->blocks; blk += 4) {
                                state->sbc_analyze_4b_8s(
-                                       &state->X[ch][state->position +
-                                                       96 - blk * 8],
+                                       x,
                                        frame->sb_sample_f[blk][ch],
                                        frame->sb_sample_f[blk + 1][ch] -
                                        frame->sb_sample_f[blk][ch]);
+                               x -= 32;
                        }
+               }
                return frame->blocks * 8;
 
        default: