summaryrefslogtreecommitdiffstats
path: root/sbc
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-10-31 23:55:13 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-10-31 23:55:13 +0100
commit40e63b5f546f8b486c7ec99570eb805ad4afc923 (patch)
tree11068b6bd2d427de2707ec6a38d6d45d50fdddde /sbc
parent397ce1cede76742f5eacc5e1eddae2169b06d7bb (diff)
Fix SBC gain mismatch
Diffstat (limited to 'sbc')
-rw-r--r--sbc/sbc.c4
-rw-r--r--sbc/sbc_tables.h5
2 files changed, 5 insertions, 4 deletions
diff --git a/sbc/sbc.c b/sbc/sbc.c
index 6303421f..7072673e 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -563,7 +563,7 @@ static inline void sbc_synthesize_four(struct sbc_decoder_state *state,
k = (i + 4) & 0xf;
/* Store in output, Q0 */
- frame->pcm_sample[ch][blk * 4 + i] = SCALE4_STAGED2(
+ frame->pcm_sample[ch][blk * 4 + i] = SCALE4_STAGED1(
MULA(v[offset[i] + 0], sbc_proto_4_40m0[idx + 0],
MULA(v[offset[k] + 1], sbc_proto_4_40m1[idx + 0],
MULA(v[offset[i] + 2], sbc_proto_4_40m0[idx + 1],
@@ -609,7 +609,7 @@ static inline void sbc_synthesize_eight(struct sbc_decoder_state *state,
k = (i + 8) & 0xf;
/* Store in output */
- frame->pcm_sample[ch][blk * 8 + i] = SCALE8_STAGED2( // Q0
+ frame->pcm_sample[ch][blk * 8 + i] = SCALE8_STAGED1( // Q0
MULA(state->V[ch][offset[i] + 0], sbc_proto_8_80m0[idx + 0],
MULA(state->V[ch][offset[k] + 1], sbc_proto_8_80m1[idx + 0],
MULA(state->V[ch][offset[i] + 2], sbc_proto_8_80m0[idx + 1],
diff --git a/sbc/sbc_tables.h b/sbc/sbc_tables.h
index 7ac4e68b..f5daaa7f 100644
--- a/sbc/sbc_tables.h
+++ b/sbc/sbc_tables.h
@@ -39,9 +39,10 @@ static const int sbc_offset8[4][8] = {
{ -4, 0, 0, 0, 0, 0, 1, 2 }
};
-#define SP4(val) ASR(val, SCALE_PROTO4_TBL)
+
+#define SP4(val) (((int32_t)(val))/17658) /* Used to be #define SP4(val) ASR(val, SCALE_PROTO4_TBL) but causes wrong gain */
#define SA4(val) ASR(val, SCALE_ANA4_TBL)
-#define SP8(val) ASR(val, SCALE_PROTO8_TBL)
+#define SP8(val) (((int32_t)(val))/57740) /* Used to be #define SP8(val) ASR(val, SCALE_PROTO8_TBL) but causes wrong gain */
#define SA8(val) ASR(val, SCALE_ANA8_TBL)
#define SS4(val) ASR(val, SCALE_SPROTO4_TBL)
#define SS8(val) ASR(val, SCALE_SPROTO8_TBL)