summaryrefslogtreecommitdiff
path: root/apps/codecs/libmusepack/requant.c
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2008-05-10 15:15:10 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2008-05-10 15:15:10 +0000
commita7a2baa97f8ee7c4d1b751d66f095120b9f62778 (patch)
tree6a1aa6bfe374f54ff6bce704f56e172994ea9443 /apps/codecs/libmusepack/requant.c
parent27bb9986f6e0bfc8f21a2dc1317accd2c6097048 (diff)
downloadrockbox-a7a2baa97f8ee7c4d1b751d66f095120b9f62778.tar.gz
rockbox-a7a2baa97f8ee7c4d1b751d66f095120b9f62778.zip
Some changes for musepack: Disable SV4-SV6 support (I guess I am the only one who oned such). Remove tabs, perform some minor code beautification and add ICONST_ATTR to some requantization constants.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17438 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libmusepack/requant.c')
-rw-r--r--apps/codecs/libmusepack/requant.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/apps/codecs/libmusepack/requant.c b/apps/codecs/libmusepack/requant.c
index 6b77585d32..3282286d74 100644
--- a/apps/codecs/libmusepack/requant.c
+++ b/apps/codecs/libmusepack/requant.c
@@ -41,7 +41,7 @@
41 41
42/* C O N S T A N T S */ 42/* C O N S T A N T S */
43// bits per sample for chosen quantizer 43// bits per sample for chosen quantizer
44const mpc_uint32_t Res_bit [18] = { 44const mpc_uint32_t Res_bit [18] ICONST_ATTR = {
45 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 45 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
46}; 46};
47 47
@@ -50,7 +50,7 @@ const mpc_uint32_t Res_bit [18] = {
50 50
51#define _(X) MAKE_MPC_SAMPLE_EX(X,14) 51#define _(X) MAKE_MPC_SAMPLE_EX(X,14)
52 52
53const MPC_SAMPLE_FORMAT __Cc [1 + 18] = { 53const MPC_SAMPLE_FORMAT __Cc [1 + 18] ICONST_ATTR = {
54 _(111.285962475327f), // 32768/2/255*sqrt(3) 54 _(111.285962475327f), // 32768/2/255*sqrt(3)
55 _(65536.000000000000f), _(21845.333333333332f), _(13107.200000000001f), _(9362.285714285713f), 55 _(65536.000000000000f), _(21845.333333333332f), _(13107.200000000001f), _(9362.285714285713f),
56 _(7281.777777777777f), _(4369.066666666666f), _(2114.064516129032f), _(1040.253968253968f), 56 _(7281.777777777777f), _(4369.066666666666f), _(2114.064516129032f), _(1040.253968253968f),
@@ -63,7 +63,7 @@ const MPC_SAMPLE_FORMAT __Cc [1 + 18] = {
63 63
64// offset for requantization 64// offset for requantization
65// 2*D+1 = steps of quantizer 65// 2*D+1 = steps of quantizer
66const mpc_int32_t __Dc [1 + 18] = { 66const mpc_int32_t __Dc [1 + 18] ICONST_ATTR = {
67 2, 67 2,
68 0, 1, 2, 3, 4, 7, 15, 31, 63, 68 0, 1, 2, 3, 4, 7, 15, 31, 63,
69 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767 69 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767
@@ -72,12 +72,12 @@ const mpc_int32_t __Dc [1 + 18] = {
72#ifdef MPC_FIXED_POINT 72#ifdef MPC_FIXED_POINT
73static mpc_uint32_t find_shift(double fval) 73static mpc_uint32_t find_shift(double fval)
74{ 74{
75 mpc_int64_t val = (mpc_int64_t)fval; 75 mpc_int64_t val = (mpc_int64_t)fval;
76 mpc_uint32_t ptr = 0; 76 mpc_uint32_t ptr = 0;
77 if (val<0) val = -val; 77 if (val<0) val = -val;
78 while(val) {val>>=1;ptr++;} 78 while(val) {val>>=1;ptr++;}
79 79
80 return ptr > 31 ? 0 : 31 - ptr; 80 return ptr > 31 ? 0 : 31 - ptr;
81} 81}
82#endif 82#endif
83 83
@@ -92,22 +92,22 @@ mpc_decoder_scale_output(mpc_decoder *d, double factor)
92 double f1; 92 double f1;
93 double f2; 93 double f2;
94#ifndef MPC_FIXED_POINT 94#ifndef MPC_FIXED_POINT
95 factor *= 1.0 / (double)(1<<(MPC_FIXED_POINT_SHIFT-1)); 95 factor *= 1.0 / (double)(1<<(MPC_FIXED_POINT_SHIFT-1));
96#else 96#else
97 factor *= 1.0 / (double)(1<<(16 - MPC_FIXED_POINT_SHIFT)); 97 factor *= 1.0 / (double)(1<<(16 - MPC_FIXED_POINT_SHIFT));
98#endif 98#endif
99 f1 = f2 = factor; 99 f1 = f2 = factor;
100 100
101 // handles +1.58...-98.41 dB, where's scf[n] / scf[n-1] = 1.20050805774840750476 101 // handles +1.58...-98.41 dB, where's scf[n] / scf[n-1] = 1.20050805774840750476
102 102
103 SET_SCF(1,factor); 103 SET_SCF(1,factor);
104 104
105 f1 *= 0.83298066476582673961; 105 f1 *= 0.83298066476582673961;
106 f2 *= 1/0.83298066476582673961; 106 f2 *= 1/0.83298066476582673961;
107 107
108 for ( n = 1; n <= 128; n++ ) { 108 for ( n = 1; n <= 128; n++ ) {
109 SET_SCF((unsigned char)(1+n),f1); 109 SET_SCF((unsigned char)(1+n),f1);
110 SET_SCF((unsigned char)(1-n),f2); 110 SET_SCF((unsigned char)(1-n),f2);
111 f1 *= 0.83298066476582673961; 111 f1 *= 0.83298066476582673961;
112 f2 *= 1/0.83298066476582673961; 112 f2 *= 1/0.83298066476582673961;
113 } 113 }