From 452c5b2197b0c2572ee4c31d973d6896f08f2631 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Fri, 7 May 2010 21:36:55 +0000 Subject: Unroll mpc's requantization loops for some (minor) speed up. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25891 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libmusepack/mpc_decoder.c | 79 ++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 19 deletions(-) (limited to 'apps/codecs/libmusepack') diff --git a/apps/codecs/libmusepack/mpc_decoder.c b/apps/codecs/libmusepack/mpc_decoder.c index 9e4ef634bf..f403673818 100644 --- a/apps/codecs/libmusepack/mpc_decoder.c +++ b/apps/codecs/libmusepack/mpc_decoder.c @@ -125,54 +125,95 @@ void mpc_decoder_read_bitstream_sv8(mpc_decoder * d, mpc_bits_reader * r, //------------------------------------------------------------------------------ // macros //------------------------------------------------------------------------------ +#define REQUANT_M1_S1_SAMPLES(IDX) \ + *(YL+=IDX) = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); \ + *(YR+=IDX) = templ - tempr; + #define REQUANT_M1_S1(SUBFRAME) \ facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n++, YL += 32, YR += 32) { \ - *YL = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); \ - *YR = templ - tempr; \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_M1_S1_SAMPLES( 0); \ + REQUANT_M1_S1_SAMPLES(32); \ + REQUANT_M1_S1_SAMPLES(32); \ + REQUANT_M1_S1_SAMPLES(32); \ } +#define REQUANT_M1_S0_SAMPLES(IDX) \ + *(YR+=IDX) = *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); + #define REQUANT_M1_S0(SUBFRAME) \ facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n++, YL += 32, YR += 32) { \ - *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_M1_S0_SAMPLES( 0); \ + REQUANT_M1_S0_SAMPLES(32); \ + REQUANT_M1_S0_SAMPLES(32); \ + REQUANT_M1_S0_SAMPLES(32); \ } +#define REQUANT_M0_S1_SAMPLES(IDX) \ + *(YR+=IDX) = -(*(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); + #define REQUANT_M0_S1(SUBFRAME) \ facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n++, YL += 32, YR += 32) { \ - *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*R++)); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_M0_S1_SAMPLES( 0); \ + REQUANT_M0_S1_SAMPLES(32); \ + REQUANT_M0_S1_SAMPLES(32); \ + REQUANT_M0_S1_SAMPLES(32); \ } +#define REQUANT_L1_R1_SAMPLES(IDX) \ + *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ + *(YR+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++); + #define REQUANT_L1_R1(SUBFRAME) \ facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n++, YL += 32, YR += 32) { \ - *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ - *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_L1_R1_SAMPLES( 0); \ + REQUANT_L1_R1_SAMPLES(32); \ + REQUANT_L1_R1_SAMPLES(32); \ + REQUANT_L1_R1_SAMPLES(32); \ } +#define REQUANT_L1_R0_SAMPLES(IDX) \ + *(YL+=IDX) = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ + *(YR+=IDX) = 0; + #define REQUANT_L1_R0(SUBFRAME) \ facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n++, YL += 32, YR += 32) { \ - *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++); \ - *YR = 0; \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_L1_R0_SAMPLES( 0); \ + REQUANT_L1_R0_SAMPLES(32); \ + REQUANT_L1_R0_SAMPLES(32); \ + REQUANT_L1_R0_SAMPLES(32); \ } +#define REQUANT_L0_R1_SAMPLES(IDX) \ + *(YL+=IDX) = 0; \ + *(YR+=IDX) = MPC_MULTIPLY_FLOAT_INT(facR,*R++); + #define REQUANT_L0_R1(SUBFRAME) \ facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][SUBFRAME] & 0xFF); \ - for (n = 0; n < 12; n++, YL += 32, YR += 32) { \ - *YL = 0; \ - *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++); \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_L0_R1_SAMPLES( 0); \ + REQUANT_L0_R1_SAMPLES(32); \ + REQUANT_L0_R1_SAMPLES(32); \ + REQUANT_L0_R1_SAMPLES(32); \ } +#define REQUANT_SILENCE_SAMPLES(IDX) \ + *(YR+=IDX) = *(YL+=IDX) = 0; + #define REQUANT_SILENCE \ - for (n = 0; n < 36; n++, YL += 32, YR += 32) { \ - *YR = *YL = 0; \ + for (n = 0; n < 12; n+=4, YL += 32, YR += 32) { \ + REQUANT_SILENCE_SAMPLES( 0); \ + REQUANT_SILENCE_SAMPLES(32); \ + REQUANT_SILENCE_SAMPLES(32); \ + REQUANT_SILENCE_SAMPLES(32); \ } - /** * set the scf indexes for seeking use * needed only for sv7 seeking -- cgit v1.2.3