summaryrefslogtreecommitdiffstats
path: root/apps/codecs/libmusepack
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-05-07 19:58:34 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-05-07 19:58:34 +0000
commitf2b1f8d768b8edce775cd280b9f24d1998941432 (patch)
tree837265bf08ef877a29de58c0c74f8428a4ed70b2 /apps/codecs/libmusepack
parente4f1bfe1c46e3421961952738294902dddbbe426 (diff)
downloadrockbox-f2b1f8d768b8edce775cd280b9f24d1998941432.tar.gz
rockbox-f2b1f8d768b8edce775cd280b9f24d1998941432.zip
Refactor mpc's requantization to use identical macros for each subframe.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25887 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libmusepack')
-rw-r--r--apps/codecs/libmusepack/mpc_decoder.c177
1 files changed, 76 insertions, 101 deletions
diff --git a/apps/codecs/libmusepack/mpc_decoder.c b/apps/codecs/libmusepack/mpc_decoder.c
index bbc916db8b..9e4ef634bf 100644
--- a/apps/codecs/libmusepack/mpc_decoder.c
+++ b/apps/codecs/libmusepack/mpc_decoder.c
@@ -122,6 +122,57 @@ void mpc_decoder_read_bitstream_sv7(mpc_decoder * d, mpc_bits_reader * r)
void mpc_decoder_read_bitstream_sv8(mpc_decoder * d, mpc_bits_reader * r,
mpc_bool_t is_key_frame);
+//------------------------------------------------------------------------------
+// macros
+//------------------------------------------------------------------------------
+#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; \
+ }
+
+#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++); \
+ }
+
+#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++)); \
+ }
+
+#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++); \
+ }
+
+#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; \
+ }
+
+#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++); \
+ }
+
+#define REQUANT_SILENCE \
+ for (n = 0; n < 36; n++, YL += 32, YR += 32) { \
+ *YR = *YL = 0; \
+ }
+
+
/**
* set the scf indexes for seeking use
* needed only for sv7 seeking
@@ -280,57 +331,22 @@ mpc_decoder_requantisierung(mpc_decoder *d)
if ( d->MS_Flag [Band] ) {
if ( d->Res_L [Band] ) {
if ( d->Res_R [Band] ) { // M!=0, S!=0
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][0] & 0xFF);
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][0] & 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;
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][1] & 0xFF);
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][1] & 0xFF);
- for ( ; n < 24; n++, YL += 32, YR += 32 ) {
- *YL = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++));
- *YR = templ - tempr;
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][2] & 0xFF);
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][2] & 0xFF);
- for ( ; n < 36; n++, YL += 32, YR += 32 ) {
- *YL = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++));
- *YR = templ - tempr;
- }
- } else { // M!=0, S==0
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][0] & 0xFF);
- for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
- *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][1] & 0xFF);
- for ( ; n < 24; n++, YL += 32, YR += 32 ) {
- *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][2] & 0xFF);
- for ( ; n < 36; n++, YL += 32, YR += 32 ) {
- *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- }
+ REQUANT_M1_S1(0);
+ REQUANT_M1_S1(1);
+ REQUANT_M1_S1(2);
+ } else { // M!=0, S==0
+ REQUANT_M1_S0(0);
+ REQUANT_M1_S0(1);
+ REQUANT_M1_S0(2);
}
} else {
- if (d->Res_R[Band]) // M==0, S!=0
+ if ( d->Res_R[Band] ) // M==0, S!=0
{
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][0] & 0xFF);
- for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
- *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++)));
- }
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][1] & 0xFF);
- for ( ; n < 24; n++, YL += 32, YR += 32 ) {
- *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++)));
- }
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][2] & 0xFF);
- for ( ; n < 36; n++, YL += 32, YR += 32 ) {
- *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++)));
- }
- } else { // M==0, S==0
- for ( n = 0; n < 36; n++, YL += 32, YR += 32 ) {
- *YR = *YL = 0;
- }
+ REQUANT_M0_S1(0);
+ REQUANT_M0_S1(1);
+ REQUANT_M0_S1(2);
+ } else { // M==0, S==0
+ REQUANT_SILENCE;
}
}
}
@@ -338,63 +354,22 @@ mpc_decoder_requantisierung(mpc_decoder *d)
else {
if ( d->Res_L [Band] ) {
if ( d->Res_R [Band] ) { // L!=0, R!=0
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][0] & 0xFF);
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][0] & 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++);
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][1] & 0xFF);
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][1] & 0xFF);
- for (; n < 24; n++, YL += 32, YR += 32 ) {
- *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][2] & 0xFF);
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][2] & 0xFF);
- for (; n < 36; n++, YL += 32, YR += 32 ) {
- *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
- }
- } else { // L!=0, R==0
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][0] & 0xFF);
- for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
- *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- *YR = 0;
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][1] & 0xFF);
- for ( ; n < 24; n++, YL += 32, YR += 32 ) {
- *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- *YR = 0;
- }
- facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , d->SCF_Index_L[Band][2] & 0xFF);
- for ( ; n < 36; n++, YL += 32, YR += 32 ) {
- *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
- *YR = 0;
- }
+ REQUANT_L1_R1(0);
+ REQUANT_L1_R1(1);
+ REQUANT_L1_R1(2);
+ } else { // L!=0, R==0
+ REQUANT_L1_R0(0);
+ REQUANT_L1_R0(1);
+ REQUANT_L1_R0(2);
}
}
else {
if ( d->Res_R [Band] ) { // L==0, R!=0
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][0] & 0xFF);
- for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
- *YL = 0;
- *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
- }
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][1] & 0xFF);
- for ( ; n < 24; n++, YL += 32, YR += 32 ) {
- *YL = 0;
- *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
- }
- facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , d->SCF_Index_R[Band][2] & 0xFF);
- for ( ; n < 36; n++, YL += 32, YR += 32 ) {
- *YL = 0;
- *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
- }
- } else { // L==0, R==0
- for ( n = 0; n < 36; n++, YL += 32, YR += 32 ) {
- *YR = *YL = 0;
- }
+ REQUANT_L0_R1(0);
+ REQUANT_L0_R1(1);
+ REQUANT_L0_R1(2);
+ } else { // L==0, R==0
+ REQUANT_SILENCE;
}
}
}