summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-31 21:07:17 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-31 21:07:17 +0000
commitf971deed6d3227c5fe8e3e6160d8fcc940acd85f (patch)
tree9819e065a08343929525956801b1115a09cf1021
parent8be79a22fdb785ed7f95f43eb313347ba65ede30 (diff)
downloadrockbox-f971deed6d3227c5fe8e3e6160d8fcc940acd85f.tar.gz
rockbox-f971deed6d3227c5fe8e3e6160d8fcc940acd85f.zip
Housekeeping for libwmapro. Define some multiple used constants, use more precise value for cos(pi/4).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27644 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libwmapro/wmaprodec.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c
index 3431870297..b5540f7872 100644
--- a/apps/codecs/libwmapro/wmaprodec.c
+++ b/apps/codecs/libwmapro/wmaprodec.c
@@ -124,6 +124,11 @@
124#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) 124#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
125#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) 125#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
126 126
127/* Define some multiple used constants */
128#define SQRT2_FRACT24 0x016A09E6 /* 0x016A09E6 = (sqrt(2)*(1<<24)) */
129#define COS_PI4_FRACT16 0x0000B505 /* 0x0000B505 = (cos(pi/4)<<16) */
130#define ONE_FRACT16 0x00010000 /* 0x00010000 = (1<<16) */
131
127/* Enable multichannel for large-memory targets only */ 132/* Enable multichannel for large-memory targets only */
128#if (MEMORYSIZE > 2) 133#if (MEMORYSIZE > 2)
129#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels 134#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels
@@ -646,9 +651,9 @@ static void decode_decorrelation_matrix(WMAProDecodeCtx *s,
646 get_bits1(&s->gb) ? 1.0 : -1.0; 651 get_bits1(&s->gb) ? 1.0 : -1.0;
647 652
648 if(chgroup->decorrelation_matrix[chgroup->num_channels * i + i] > 0) 653 if(chgroup->decorrelation_matrix[chgroup->num_channels * i + i] > 0)
649 chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = 0x10000; 654 chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = ONE_FRACT16;
650 else 655 else
651 chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = -0x10000; 656 chgroup->fixdecorrelation_matrix[chgroup->num_channels * i + i] = -ONE_FRACT16;
652 } 657 }
653 658
654 for (i = 1; i < chgroup->num_channels; i++) { 659 for (i = 1; i < chgroup->num_channels; i++) {
@@ -754,16 +759,16 @@ static int decode_channel_transform(WMAProDecodeCtx* s)
754 } else { 759 } else {
755 chgroup->transform = 1; 760 chgroup->transform = 1;
756 if (s->num_channels == 2) { 761 if (s->num_channels == 2) {
757 chgroup->fixdecorrelation_matrix[0] = 0x10000; 762 chgroup->fixdecorrelation_matrix[0] = ONE_FRACT16;
758 chgroup->fixdecorrelation_matrix[1] = -0x10000; 763 chgroup->fixdecorrelation_matrix[1] = -ONE_FRACT16;
759 chgroup->fixdecorrelation_matrix[2] = 0x10000; 764 chgroup->fixdecorrelation_matrix[2] = ONE_FRACT16;
760 chgroup->fixdecorrelation_matrix[3] = 0x10000; 765 chgroup->fixdecorrelation_matrix[3] = ONE_FRACT16;
761 } else { 766 } else {
762 /** cos(pi/4) */ 767 /** cos(pi/4) */
763 chgroup->fixdecorrelation_matrix[0] = 0xB500; 768 chgroup->fixdecorrelation_matrix[0] = COS_PI4_FRACT16;
764 chgroup->fixdecorrelation_matrix[1] = -0xB500; 769 chgroup->fixdecorrelation_matrix[1] = -COS_PI4_FRACT16;
765 chgroup->fixdecorrelation_matrix[2] = 0xB500; 770 chgroup->fixdecorrelation_matrix[2] = COS_PI4_FRACT16;
766 chgroup->fixdecorrelation_matrix[3] = 0xB500; 771 chgroup->fixdecorrelation_matrix[3] = COS_PI4_FRACT16;
767 } 772 }
768 } 773 }
769 } else if (chgroup->num_channels > 2) { 774 } else if (chgroup->num_channels > 2) {
@@ -858,19 +863,19 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
858 v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); 863 v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
859 if (v1 == HUFF_VEC1_SIZE - 1) 864 if (v1 == HUFF_VEC1_SIZE - 1)
860 v1 += ff_wma_get_large_val(&s->gb); 865 v1 += ff_wma_get_large_val(&s->gb);
861 866
862 vals[i] = v0; 867 vals[i ] = v0;
863 vals[i+1] = v1; 868 vals[i+1] = v1;
864 } else { 869 } else {
865 vals[i] = symbol_to_vec2[idx] >> 4; 870 vals[i ] = symbol_to_vec2[idx] >> 4;
866 vals[i+1] = symbol_to_vec2[idx] & 0xF; 871 vals[i+1] = symbol_to_vec2[idx] & 0xF;
867 } 872 }
868 } 873 }
869 } else { 874 } else {
870 vals[0] = symbol_to_vec4[idx] >> 12; 875 vals[0] = (symbol_to_vec4[idx] >> 12);
871 vals[1] = (symbol_to_vec4[idx] >> 8) & 0xF; 876 vals[1] = (symbol_to_vec4[idx] >> 8) & 0xF;
872 vals[2] = (symbol_to_vec4[idx] >> 4) & 0xF; 877 vals[2] = (symbol_to_vec4[idx] >> 4) & 0xF;
873 vals[3] = symbol_to_vec4[idx] & 0xF; 878 vals[3] = (symbol_to_vec4[idx] ) & 0xF;
874 } 879 }
875 880
876 /** decode sign */ 881 /** decode sign */
@@ -1042,14 +1047,14 @@ static void inverse_channel_transform(WMAProDecodeCtx *s)
1042 } 1047 }
1043 } else if (s->num_channels == 2) { 1048 } else if (s->num_channels == 2) {
1044 1049
1045 /* Scale with sqrt(2). 0x016A09E6 = (sqrt(2)*(1<<24)) */ 1050 /* Scale with sqrt(2) */
1046 int len = FFMIN(sfb[1], s->subframe_len) - sfb[0]; 1051 int len = FFMIN(sfb[1], s->subframe_len) - sfb[0];
1047 vector_fixmul_scalar(ch_data[0] + sfb[0], 1052 vector_fixmul_scalar(ch_data[0] + sfb[0],
1048 ch_data[0] + sfb[0], 1053 ch_data[0] + sfb[0],
1049 0x016A09E6, len); 1054 SQRT2_FRACT24, len);
1050 vector_fixmul_scalar(ch_data[1] + sfb[0], 1055 vector_fixmul_scalar(ch_data[1] + sfb[0],
1051 ch_data[1] + sfb[0], 1056 ch_data[1] + sfb[0],
1052 0x016A09E6, len); 1057 SQRT2_FRACT24, len);
1053 1058
1054 } 1059 }
1055 } 1060 }