diff options
-rw-r--r-- | apps/plugins/mp3_encoder.c | 303 |
1 files changed, 130 insertions, 173 deletions
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index fe417ce180..9b5b8d70e9 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c | |||
@@ -29,11 +29,11 @@ enum e_byte_order { order_unknown, order_bigEndian, order_littleEndian }; | |||
29 | typedef struct { | 29 | typedef struct { |
30 | int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */ | 30 | int type; /* 0=(MPEG2 - 22.05,24,16kHz) 1=(MPEG1 - 44.1,48,32kHz) */ |
31 | int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */ | 31 | int mode; /* 0=stereo, 1=jstereo, 2=dual, 3=mono */ |
32 | int bitrate; | ||
33 | int padding; | 32 | int padding; |
34 | int num_bands; | ||
35 | long bitr_id; | 33 | long bitr_id; |
36 | int smpl_id; | 34 | int smpl_id; |
35 | uint16_t bitrate; | ||
36 | uint8_t num_bands; | ||
37 | } mpeg_t; | 37 | } mpeg_t; |
38 | 38 | ||
39 | /* Side information */ | 39 | /* Side information */ |
@@ -42,13 +42,13 @@ typedef struct { | |||
42 | int count1; /* number of 0-1-quadruples */ | 42 | int count1; /* number of 0-1-quadruples */ |
43 | uint32_t global_gain; | 43 | uint32_t global_gain; |
44 | uint32_t table_select[4]; | 44 | uint32_t table_select[4]; |
45 | uint32_t region_0_1; | ||
46 | uint32_t address1; | 45 | uint32_t address1; |
47 | uint32_t address2; | 46 | uint32_t address2; |
48 | uint32_t address3; | 47 | uint32_t address3; |
49 | long quantStep; | 48 | long quantStep; |
50 | long additStep; | 49 | long additStep; |
51 | uint32_t max_val; | 50 | uint32_t max_val; |
51 | uint8_t region_0_1; | ||
52 | } side_info_t; | 52 | } side_info_t; |
53 | 53 | ||
54 | typedef struct { | 54 | typedef struct { |
@@ -64,7 +64,7 @@ typedef struct { | |||
64 | int channels; | 64 | int channels; |
65 | int granules; | 65 | int granules; |
66 | int resample; | 66 | int resample; |
67 | long samplerate; | 67 | uint16_t samplerate; |
68 | } config_t; | 68 | } config_t; |
69 | 69 | ||
70 | typedef struct { | 70 | typedef struct { |
@@ -73,15 +73,15 @@ typedef struct { | |||
73 | } BF_Data; | 73 | } BF_Data; |
74 | 74 | ||
75 | struct huffcodetab { | 75 | struct huffcodetab { |
76 | int len; /* max. index */ | 76 | const uint8_t len; /* max. index */ |
77 | const uint8_t *table; /* pointer to array[len][len] */ | 77 | const uint8_t const *table; /* pointer to array[len][len] */ |
78 | const uint8_t *hlen; /* pointer to array[len][len] */ | 78 | const uint8_t const *hlen; /* pointer to array[len][len] */ |
79 | }; | 79 | }; |
80 | 80 | ||
81 | struct huffcodebig { | 81 | struct huffcodebig { |
82 | int len; /* max. index */ | 82 | const uint8_t len; /* max. index */ |
83 | int linbits; /* number of linbits */ | 83 | const uint8_t linbits; /* number of linbits */ |
84 | int linmax; /* max number stored in linbits */ | 84 | const uint16_t linmax; /* max number stored in linbits */ |
85 | }; | 85 | }; |
86 | 86 | ||
87 | #define shft4(x) ((x + 8) >> 4) | 87 | #define shft4(x) ((x + 8) >> 4) |
@@ -92,99 +92,102 @@ struct huffcodebig { | |||
92 | #define shft_n(x,n) ((x) >> n) | 92 | #define shft_n(x,n) ((x) >> n) |
93 | #define SQRT 724 /* sqrt(2) * 512 */ | 93 | #define SQRT 724 /* sqrt(2) * 512 */ |
94 | 94 | ||
95 | static short mfbuf [2*(1152+512)] IBSS_ATTR; /* 3328 Bytes */ | 95 | static short mfbuf [2*(1152+512)] IBSS_ATTR; /* 6656 Bytes */ |
96 | static int sb_data [2][2][18][SBLIMIT] IBSS_ATTR; /* 13824 Bytes */ | 96 | static int sb_data [2][2][18][SBLIMIT] IBSS_ATTR; /* 9216 Bytes */ |
97 | static int mdct_freq [SAMPL2] IBSS_ATTR; /* 2304 Bytes */ | 97 | static int mdct_freq [SAMPL2] IBSS_ATTR; /* 2304 Bytes */ |
98 | static char mdct_sign [SAMPL2] IBSS_ATTR; /* 576 Bytes */ | 98 | static char mdct_sign [SAMPL2] IBSS_ATTR; /* 576 Bytes */ |
99 | static short enc_data [SAMPL2] IBSS_ATTR; /* 1152 Bytes */ | 99 | static short enc_data [SAMPL2] IBSS_ATTR; /* 1152 Bytes */ |
100 | static uint32_t scalefac [23] IBSS_ATTR; /* 92 Bytes */ | ||
101 | static BF_Data CodedData IBSS_ATTR; /* 1056 Bytes */ | 100 | static BF_Data CodedData IBSS_ATTR; /* 1056 Bytes */ |
102 | static int ca [8] IBSS_ATTR; /* 32 Bytes */ | 101 | |
103 | static int cs [8] IBSS_ATTR; /* 32 Bytes */ | 102 | static const uint16_t sfBand[6][23] ICONST_ATTR; |
104 | static int cx [9] IBSS_ATTR; /* 36 Bytes */ | 103 | static const uint16_t const *scalefac ICONST_ATTR; |
105 | static int win [18][4] IBSS_ATTR; /* 288 Bytes */ | 104 | |
106 | static short enwindow [15*27+24] IBSS_ATTR; /* 862 Bytes */ | 105 | static const int16_t ca [8] ICONST_ATTR; /* 16 Bytes */ |
107 | static short int2idx [4096] IBSS_ATTR; /* 8192 Bytes */ | 106 | static const uint16_t cs [8] ICONST_ATTR; /* 16 Bytes */ |
108 | static uint8_t ht_count [2][2][16] IBSS_ATTR; /* 64 Bytes */ | 107 | static const int16_t cx [9] ICONST_ATTR; /* 18 Bytes */ |
109 | static uint32_t tab01 [ 16] IBSS_ATTR; /* 64 Bytes */ | 108 | static const int16_t win [18][4] ICONST_ATTR; /* 144 Bytes */ |
110 | static uint32_t tab23 [ 9] IBSS_ATTR; /* 36 Bytes */ | 109 | static const int16_t enwindow [15*27+24] ICONST_ATTR; /* 862 Bytes */ |
111 | static uint32_t tab56 [ 16] IBSS_ATTR; /* 64 Bytes */ | 110 | static const uint16_t int2idx [4096] ICONST_ATTR; /* 8192 Bytes */ |
112 | static uint32_t tab1315 [256] IBSS_ATTR; /* 1024 Bytes */ | 111 | static const uint8_t ht_count[2][2][16] ICONST_ATTR; /* 64 Bytes */ |
113 | static uint32_t tab1624 [256] IBSS_ATTR; /* 1024 Bytes */ | 112 | static const uint32_t tab01 [ 16] ICONST_ATTR; /* 64 Bytes */ |
114 | static uint32_t tab789 [ 36] IBSS_ATTR; /* 144 Bytes */ | 113 | static const uint32_t tab23 [ 9] ICONST_ATTR; /* 36 Bytes */ |
115 | static uint32_t tabABC [ 64] IBSS_ATTR; /* 256 Bytes */ | 114 | static const uint32_t tab56 [ 16] ICONST_ATTR; /* 64 Bytes */ |
116 | static uint8_t t1HB [ 4] IBSS_ATTR; | 115 | static const uint32_t tab1315 [256] ICONST_ATTR; /* 1024 Bytes */ |
117 | static uint8_t t2HB [ 9] IBSS_ATTR; | 116 | static const uint32_t tab1624 [256] ICONST_ATTR; /* 1024 Bytes */ |
118 | static uint8_t t3HB [ 9] IBSS_ATTR; | 117 | static const uint32_t tab789 [ 36] ICONST_ATTR; /* 144 Bytes */ |
119 | static uint8_t t5HB [ 16] IBSS_ATTR; | 118 | static const uint32_t tabABC [ 64] ICONST_ATTR; /* 256 Bytes */ |
120 | static uint8_t t6HB [ 16] IBSS_ATTR; | 119 | static const uint8_t t1HB [ 4] ICONST_ATTR; |
121 | static uint8_t t7HB [ 36] IBSS_ATTR; | 120 | static const uint8_t t2HB [ 9] ICONST_ATTR; |
122 | static uint8_t t8HB [ 36] IBSS_ATTR; | 121 | static const uint8_t t3HB [ 9] ICONST_ATTR; |
123 | static uint8_t t9HB [ 36] IBSS_ATTR; | 122 | static const uint8_t t5HB [ 16] ICONST_ATTR; |
124 | static uint8_t t10HB [ 64] IBSS_ATTR; | 123 | static const uint8_t t6HB [ 16] ICONST_ATTR; |
125 | static uint8_t t11HB [ 64] IBSS_ATTR; | 124 | static const uint8_t t7HB [ 36] ICONST_ATTR; |
126 | static uint8_t t12HB [ 64] IBSS_ATTR; | 125 | static const uint8_t t8HB [ 36] ICONST_ATTR; |
127 | static uint8_t t13HB [256] IBSS_ATTR; | 126 | static const uint8_t t9HB [ 36] ICONST_ATTR; |
128 | static uint8_t t15HB [256] IBSS_ATTR; | 127 | static const uint8_t t10HB [ 64] ICONST_ATTR; |
129 | static uint16_t t16HB [256] IBSS_ATTR; | 128 | static const uint8_t t11HB [ 64] ICONST_ATTR; |
130 | static uint16_t t24HB [256] IBSS_ATTR; | 129 | static const uint8_t t12HB [ 64] ICONST_ATTR; |
131 | static uint8_t t1l [ 8] IBSS_ATTR; | 130 | static const uint8_t t13HB [256] ICONST_ATTR; |
132 | static uint8_t t2l [ 9] IBSS_ATTR; | 131 | static const uint8_t t15HB [256] ICONST_ATTR; |
133 | static uint8_t t3l [ 9] IBSS_ATTR; | 132 | static const uint16_t t16HB [256] ICONST_ATTR; |
134 | static uint8_t t5l [ 16] IBSS_ATTR; | 133 | static const uint16_t t24HB [256] ICONST_ATTR; |
135 | static uint8_t t6l [ 16] IBSS_ATTR; | 134 | static const uint8_t t1l [ 8] ICONST_ATTR; |
136 | static uint8_t t7l [ 36] IBSS_ATTR; | 135 | static const uint8_t t2l [ 9] ICONST_ATTR; |
137 | static uint8_t t8l [ 36] IBSS_ATTR; | 136 | static const uint8_t t3l [ 9] ICONST_ATTR; |
138 | static uint8_t t9l [ 36] IBSS_ATTR; | 137 | static const uint8_t t5l [ 16] ICONST_ATTR; |
139 | static uint8_t t10l [ 64] IBSS_ATTR; | 138 | static const uint8_t t6l [ 16] ICONST_ATTR; |
140 | static uint8_t t11l [ 64] IBSS_ATTR; | 139 | static const uint8_t t7l [ 36] ICONST_ATTR; |
141 | static uint8_t t12l [ 64] IBSS_ATTR; | 140 | static const uint8_t t8l [ 36] ICONST_ATTR; |
142 | static uint8_t t13l [256] IBSS_ATTR; | 141 | static const uint8_t t9l [ 36] ICONST_ATTR; |
143 | static uint8_t t15l [256] IBSS_ATTR; | 142 | static const uint8_t t10l [ 64] ICONST_ATTR; |
144 | static uint8_t t16l [256] IBSS_ATTR; | 143 | static const uint8_t t11l [ 64] ICONST_ATTR; |
145 | static uint8_t t24l [256] IBSS_ATTR; | 144 | static const uint8_t t12l [ 64] ICONST_ATTR; |
146 | static struct huffcodetab ht [HTN] IBSS_ATTR; | 145 | static const uint8_t t13l [256] ICONST_ATTR; |
147 | 146 | static const uint8_t t15l [256] ICONST_ATTR; | |
148 | static const uint8_t ht_count_const[2][2][16] = | 147 | static const uint8_t t16l [256] ICONST_ATTR; |
148 | static const uint8_t t24l [256] ICONST_ATTR; | ||
149 | static struct huffcodetab ht [HTN] IDATA_ATTR; | ||
150 | |||
151 | static const uint8_t ht_count[2][2][16] = | ||
149 | { { { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1 }, /* table0 */ | 152 | { { { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1 }, /* table0 */ |
150 | { 1, 5, 5, 7, 5, 8, 7, 9, 5, 7, 7, 9, 7, 9, 9,10 } }, /* hleng0 */ | 153 | { 1, 5, 5, 7, 5, 8, 7, 9, 5, 7, 7, 9, 7, 9, 9,10 } }, /* hleng0 */ |
151 | { {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, /* table1 */ | 154 | { {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, /* table1 */ |
152 | { 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 } } }; /* hleng1 */ | 155 | { 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 } } }; /* hleng1 */ |
153 | 156 | ||
154 | static const uint8_t t1HB_const[4] = {1,1,1,0}; | 157 | static const uint8_t t1HB[4] = {1,1,1,0}; |
155 | static const uint8_t t2HB_const[9] = {1,2,1,3,1,1,3,2,0}; | 158 | static const uint8_t t2HB[9] = {1,2,1,3,1,1,3,2,0}; |
156 | static const uint8_t t3HB_const[9] = {3,2,1,1,1,1,3,2,0}; | 159 | static const uint8_t t3HB[9] = {3,2,1,1,1,1,3,2,0}; |
157 | static const uint8_t t5HB_const[16] = {1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0}; | 160 | static const uint8_t t5HB[16] = {1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0}; |
158 | static const uint8_t t6HB_const[16] = {7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0}; | 161 | static const uint8_t t6HB[16] = {7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0}; |
159 | 162 | ||
160 | static const uint8_t t7HB_const[36] = | 163 | static const uint8_t t7HB[36] = |
161 | { 1, 2,10,19,16,10, 3, 3, 7,10, 5, 3,11, 4,13,17, 8, 4, | 164 | { 1, 2,10,19,16,10, 3, 3, 7,10, 5, 3,11, 4,13,17, 8, 4, |
162 | 12,11,18,15,11, 2, 7, 6, 9,14, 3, 1, 6, 4, 5, 3, 2, 0 }; | 165 | 12,11,18,15,11, 2, 7, 6, 9,14, 3, 1, 6, 4, 5, 3, 2, 0 }; |
163 | 166 | ||
164 | static const uint8_t t8HB_const[36] = | 167 | static const uint8_t t8HB[36] = |
165 | { 3, 4, 6,18,12, 5, 5, 1, 2,16, 9, 3, 7, 3, 5,14, 7, 3, | 168 | { 3, 4, 6,18,12, 5, 5, 1, 2,16, 9, 3, 7, 3, 5,14, 7, 3, |
166 | 19,17,15,13,10, 4,13, 5, 8,11, 5, 1,12, 4, 4, 1, 1, 0 }; | 169 | 19,17,15,13,10, 4,13, 5, 8,11, 5, 1,12, 4, 4, 1, 1, 0 }; |
167 | 170 | ||
168 | static const uint8_t t9HB_const[36] = | 171 | static const uint8_t t9HB[36] = |
169 | { 7, 5, 9,14,15, 7, 6, 4, 5, 5, 6, 7, 7, 6, 8, 8, 8, 5, | 172 | { 7, 5, 9,14,15, 7, 6, 4, 5, 5, 6, 7, 7, 6, 8, 8, 8, 5, |
170 | 15, 6, 9,10, 5, 1,11, 7, 9, 6, 4, 1,14, 4, 6, 2, 6, 0 }; | 173 | 15, 6, 9,10, 5, 1,11, 7, 9, 6, 4, 1,14, 4, 6, 2, 6, 0 }; |
171 | 174 | ||
172 | static const uint8_t t10HB_const[64] = | 175 | static const uint8_t t10HB[64] = |
173 | {1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32, | 176 | {1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32, |
174 | 40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22, | 177 | 40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22, |
175 | 41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0 }; | 178 | 41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0 }; |
176 | 179 | ||
177 | static const uint8_t t11HB_const[64] = | 180 | static const uint8_t t11HB[64] = |
178 | {3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30, | 181 | {3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30, |
179 | 31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26, | 182 | 31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26, |
180 | 32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0 }; | 183 | 32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0 }; |
181 | 184 | ||
182 | static const uint8_t t12HB_const[64] = | 185 | static const uint8_t t12HB[64] = |
183 | {9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21, | 186 | {9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21, |
184 | 30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17, | 187 | 30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17, |
185 | 31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0 }; | 188 | 31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0 }; |
186 | 189 | ||
187 | static const uint8_t t13HB_const[256] = | 190 | static const uint8_t t13HB[256] = |
188 | {1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32, | 191 | {1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32, |
189 | 24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56, | 192 | 24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56, |
190 | 79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53, | 193 | 79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53, |
@@ -196,7 +199,7 @@ static const uint8_t t13HB_const[256] = | |||
196 | 45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13, | 199 | 45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13, |
197 | 10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1 }; | 200 | 10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1 }; |
198 | 201 | ||
199 | static const uint8_t t15HB_const[256] = | 202 | static const uint8_t t15HB[256] = |
200 | {7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51, | 203 | {7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51, |
201 | 42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28, | 204 | 42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28, |
202 | 25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69, | 205 | 25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69, |
@@ -208,7 +211,7 @@ static const uint8_t t15HB_const[256] = | |||
208 | 24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47, | 211 | 24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47, |
209 | 43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0}; | 212 | 43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0}; |
210 | 213 | ||
211 | static const uint16_t t16HB_const[256] = | 214 | static const uint16_t t16HB[256] = |
212 | {1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47, | 215 | {1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47, |
213 | 83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209, | 216 | 83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209, |
214 | 206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65, | 217 | 206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65, |
@@ -223,7 +226,7 @@ static const uint16_t t16HB_const[256] = | |||
223 | 358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3, | 226 | 358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3, |
224 | 1,3}; | 227 | 1,3}; |
225 | 228 | ||
226 | static const uint16_t t24HB_const[256] = | 229 | static const uint16_t t24HB[256] = |
227 | {15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71, | 230 | {15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71, |
228 | 130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194, | 231 | 130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194, |
229 | 182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293, | 232 | 182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293, |
@@ -238,7 +241,7 @@ static const uint16_t t24HB_const[256] = | |||
238 | 374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360, | 241 | 374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360, |
239 | 358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3}; | 242 | 358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3}; |
240 | 243 | ||
241 | static const uint32_t tab1315_const[256] = | 244 | static const uint32_t tab1315[256] = |
242 | { 0x010003,0x050005,0x070006,0x080008,0x090008,0x0a0009,0x0a000a,0x0b000a, | 245 | { 0x010003,0x050005,0x070006,0x080008,0x090008,0x0a0009,0x0a000a,0x0b000a, |
243 | 0x0a000a,0x0b000b,0x0c000b,0x0c000c,0x0d000c,0x0d000c,0x0e000d,0x0e000e, | 246 | 0x0a000a,0x0b000b,0x0c000b,0x0c000c,0x0d000c,0x0d000c,0x0e000d,0x0e000e, |
244 | 0x040005,0x060005,0x080007,0x090008,0x0a0009,0x0a0009,0x0b000a,0x0b000a, | 247 | 0x040005,0x060005,0x080007,0x090008,0x0a0009,0x0a0009,0x0b000a,0x0b000a, |
@@ -272,18 +275,18 @@ static const uint32_t tab1315_const[256] = | |||
272 | 0x0d000d,0x0e000d,0x0f000d,0x10000d,0x10000d,0x10000d,0x11000d,0x10000e, | 275 | 0x0d000d,0x0e000d,0x0f000d,0x10000d,0x10000d,0x10000d,0x11000d,0x10000e, |
273 | 0x11000e,0x11000e,0x12000e,0x12000e,0x15000f,0x14000f,0x15000f,0x12000f }; | 276 | 0x11000e,0x11000e,0x12000e,0x12000e,0x15000f,0x14000f,0x15000f,0x12000f }; |
274 | 277 | ||
275 | static const uint32_t tab01_const[16] = | 278 | static const uint32_t tab01[16] = |
276 | { 0x10004,0x50005,0x50005,0x70006,0x50005,0x80006,0x70006,0x90007, | 279 | { 0x10004,0x50005,0x50005,0x70006,0x50005,0x80006,0x70006,0x90007, |
277 | 0x50005,0x70006,0x70006,0x90007,0x70006,0x90007,0x90007,0xa0008 }; | 280 | 0x50005,0x70006,0x70006,0x90007,0x70006,0x90007,0x90007,0xa0008 }; |
278 | 281 | ||
279 | static const uint32_t tab23_const[ 9] = | 282 | static const uint32_t tab23[ 9] = |
280 | { 0x10002,0x40003,0x70007,0x40004,0x50004,0x70007,0x60006,0x70007,0x80008 }; | 283 | { 0x10002,0x40003,0x70007,0x40004,0x50004,0x70007,0x60006,0x70007,0x80008 }; |
281 | 284 | ||
282 | static const uint32_t tab56_const[16] = | 285 | static const uint32_t tab56[16] = |
283 | { 0x10003,0x40004,0x70006,0x80008,0x40004,0x50004,0x80006,0x90007, | 286 | { 0x10003,0x40004,0x70006,0x80008,0x40004,0x50004,0x80006,0x90007, |
284 | 0x70005,0x80006,0x90007,0xa0008,0x80007,0x80007,0x90008,0xa0009 }; | 287 | 0x70005,0x80006,0x90007,0xa0008,0x80007,0x80007,0x90008,0xa0009 }; |
285 | 288 | ||
286 | static const uint32_t tab789_const[36] = | 289 | static const uint32_t tab789[36] = |
287 | {0x00100803,0x00401004,0x00701c06,0x00902407,0x00902409,0x00a0280a,0x00401004, | 290 | {0x00100803,0x00401004,0x00701c06,0x00902407,0x00902409,0x00a0280a,0x00401004, |
288 | 0x00601005,0x00801806,0x00902807,0x00902808,0x00a0280a,0x00701c05,0x00701806, | 291 | 0x00601005,0x00801806,0x00902807,0x00902808,0x00a0280a,0x00701c05,0x00701806, |
289 | 0x00902007,0x00a02808,0x00a02809,0x00b02c0a,0x00802407,0x00902807,0x00a02808, | 292 | 0x00902007,0x00a02808,0x00a02809,0x00b02c0a,0x00802407,0x00902807,0x00a02808, |
@@ -291,7 +294,7 @@ static const uint32_t tab789_const[36] = | |||
291 | 0x00b0300a,0x00c0300b,0x00902809,0x00a02809,0x00b02c0a,0x00c02c0a,0x00c0340b, | 294 | 0x00b0300a,0x00c0300b,0x00902809,0x00a02809,0x00b02c0a,0x00c02c0a,0x00c0340b, |
292 | 0x00c0340b}; | 295 | 0x00c0340b}; |
293 | 296 | ||
294 | static const uint32_t tabABC_const[64] = | 297 | static const uint32_t tabABC[64] = |
295 | {0x00100804,0x00401004,0x00701806,0x00902008,0x00a02409,0x00a0280a,0x00a0240a, | 298 | {0x00100804,0x00401004,0x00701806,0x00902008,0x00a02409,0x00a0280a,0x00a0240a, |
296 | 0x00b0280a,0x00401004,0x00601405,0x00801806,0x00902007,0x00a02809,0x00b02809, | 299 | 0x00b0280a,0x00401004,0x00601405,0x00801806,0x00902007,0x00a02809,0x00b02809, |
297 | 0x00a0240a,0x00a0280a,0x00701806,0x00801c06,0x00902007,0x00a02408,0x00b02809, | 300 | 0x00a0240a,0x00a0280a,0x00701806,0x00801c06,0x00902007,0x00a02408,0x00b02809, |
@@ -303,7 +306,7 @@ static const uint32_t tabABC_const[64] = | |||
303 | 0x00a0240a,0x00a0240a,0x00b0280a,0x00c02c0b,0x00c0300b,0x00d0300b,0x00d0300b, | 306 | 0x00a0240a,0x00a0240a,0x00b0280a,0x00c02c0b,0x00c0300b,0x00d0300b,0x00d0300b, |
304 | 0x00d0300c}; | 307 | 0x00d0300c}; |
305 | 308 | ||
306 | static const uint32_t tab1624_const[256] = | 309 | static const uint32_t tab1624[256] = |
307 | {0x00010004,0x00050005,0x00070007,0x00090008,0x000a0009,0x000a000a,0x000b000a, | 310 | {0x00010004,0x00050005,0x00070007,0x00090008,0x000a0009,0x000a000a,0x000b000a, |
308 | 0x000b000b,0x000c000b,0x000c000c,0x000c000c,0x000d000c,0x000d000c,0x000d000c, | 311 | 0x000b000b,0x000c000b,0x000c000c,0x000c000c,0x000d000c,0x000d000c,0x000d000c, |
309 | 0x000e000d,0x000a000a,0x00040005,0x00060006,0x00080007,0x00090008,0x000a0009, | 312 | 0x000e000d,0x000a000a,0x00040005,0x00060006,0x00080007,0x00090008,0x000a0009, |
@@ -342,34 +345,34 @@ static const uint32_t tab1624_const[256] = | |||
342 | 0x000c0009,0x000c0009,0x000c0009,0x000d0009,0x000d0009,0x000d0009,0x000d000a, | 345 | 0x000c0009,0x000c0009,0x000c0009,0x000d0009,0x000d0009,0x000d0009,0x000d000a, |
343 | 0x000d000a,0x000d000a,0x000d000a,0x000a0006}; | 346 | 0x000d000a,0x000d000a,0x000d000a,0x000a0006}; |
344 | 347 | ||
345 | static const uint8_t t1l_const[8] = {1,3,2,3,1,4,3,5}; | 348 | static const uint8_t t1l[8] = {1,3,2,3,1,4,3,5}; |
346 | static const uint8_t t2l_const[9] = {1,3,6,3,3,5,5,5,6}; | 349 | static const uint8_t t2l[9] = {1,3,6,3,3,5,5,5,6}; |
347 | static const uint8_t t3l_const[9] = {2,2,6,3,2,5,5,5,6}; | 350 | static const uint8_t t3l[9] = {2,2,6,3,2,5,5,5,6}; |
348 | static const uint8_t t5l_const[16] = {1,3,6,7,3,3,6,7,6,6,7,8,7,6,7,8}; | 351 | static const uint8_t t5l[16] = {1,3,6,7,3,3,6,7,6,6,7,8,7,6,7,8}; |
349 | static const uint8_t t6l_const[16] = {3,3,5,7,3,2,4,5,4,4,5,6,6,5,6,7}; | 352 | static const uint8_t t6l[16] = {3,3,5,7,3,2,4,5,4,4,5,6,6,5,6,7}; |
350 | 353 | ||
351 | static const uint8_t t7l_const[36] = | 354 | static const uint8_t t7l[36] = |
352 | {1,3,6,8,8,9,3,4,6,7,7,8,6,5,7,8,8,9,7,7,8,9,9,9,7,7,8,9,9,10,8,8,9,10,10,10}; | 355 | {1,3,6,8,8,9,3,4,6,7,7,8,6,5,7,8,8,9,7,7,8,9,9,9,7,7,8,9,9,10,8,8,9,10,10,10}; |
353 | 356 | ||
354 | static const uint8_t t8l_const[36] = | 357 | static const uint8_t t8l[36] = |
355 | {2,3,6,8,8,9,3,2,4,8,8,8,6,4,6,8,8,9,8,8,8,9,9,10,8,7,8,9,10,10,9,8,9,9,11,11}; | 358 | {2,3,6,8,8,9,3,2,4,8,8,8,6,4,6,8,8,9,8,8,8,9,9,10,8,7,8,9,10,10,9,8,9,9,11,11}; |
356 | 359 | ||
357 | static const uint8_t t9l_const[36] = | 360 | static const uint8_t t9l[36] = |
358 | {3,3,5,6,8,9,3,3,4,5,6,8,4,4,5,6,7,8,6,5,6,7,7,8,7,6,7,7,8,9,8,7,8,8,9,9}; | 361 | {3,3,5,6,8,9,3,3,4,5,6,8,4,4,5,6,7,8,6,5,6,7,7,8,7,6,7,7,8,9,8,7,8,8,9,9}; |
359 | 362 | ||
360 | static const uint8_t t10l_const[64] = | 363 | static const uint8_t t10[64] = |
361 | {1,3,6,8,9,9,9,10,3,4,6,7,8,9,8,8,6,6,7,8,9,10,9,9,7,7,8,9,10,10,9,10,8,8,9,10, | 364 | {1,3,6,8,9,9,9,10,3,4,6,7,8,9,8,8,6,6,7,8,9,10,9,9,7,7,8,9,10,10,9,10,8,8,9,10, |
362 | 10,10,10,10,9,9,10,10,11,11,10,11,8,8,9,10,10,10,11,11,9,8,9,10,10,11,11,11}; | 365 | 10,10,10,10,9,9,10,10,11,11,10,11,8,8,9,10,10,10,11,11,9,8,9,10,10,11,11,11}; |
363 | 366 | ||
364 | static const uint8_t t11l_const[64] = | 367 | static const uint8_t t11l[64] = |
365 | {2,3,5,7,8,9,8,9,3,3,4,6,8,8,7,8,5,5,6,7,8,9,8,8,7,6,7,9,8,10,8,9,8,8,8,9,9,10, | 368 | {2,3,5,7,8,9,8,9,3,3,4,6,8,8,7,8,5,5,6,7,8,9,8,8,7,6,7,9,8,10,8,9,8,8,8,9,9,10, |
366 | 9,10,8,8,9,10,10,11,10,11,8,7,7,8,9,10,10,10,8,7,8,9,10,10,10,10}; | 369 | 9,10,8,8,9,10,10,11,10,11,8,7,7,8,9,10,10,10,8,7,8,9,10,10,10,10}; |
367 | 370 | ||
368 | static const uint8_t t12l_const[64] = | 371 | static const uint8_t t12l[64] = |
369 | {4,3,5,7,8,9,9,9,3,3,4,5,7,7,8,8,5,4,5,6,7,8,7,8,6,5,6,6,7,8,8,8,7,6,7,7,8, | 372 | {4,3,5,7,8,9,9,9,3,3,4,5,7,7,8,8,5,4,5,6,7,8,7,8,6,5,6,6,7,8,8,8,7,6,7,7,8, |
370 | 8,8,9,8,7,8,8,8,9,8,9,8,7,7,8,8,9,9,10,9,8,8,9,9,9,9,10}; | 373 | 8,8,9,8,7,8,8,8,9,8,9,8,7,7,8,8,9,9,10,9,8,8,9,9,9,9,10}; |
371 | 374 | ||
372 | static const uint8_t t13l_const[256] = | 375 | static const uint8_t t13l[256] = |
373 | {1,4,6,7,8,9,9,10,9,10,11,11,12,12,13,13,3,4,6,7,8,8,9,9,9,9,10,10,11,12,12,12, | 376 | {1,4,6,7,8,9,9,10,9,10,11,11,12,12,13,13,3,4,6,7,8,8,9,9,9,9,10,10,11,12,12,12, |
374 | 6,6,7,8,9,9,10,10,9,10,10,11,11,12,13,13,7,7,8,9,9,10,10,10,10,11,11,11,11,12, | 377 | 6,6,7,8,9,9,10,10,9,10,10,11,11,12,13,13,7,7,8,9,9,10,10,10,10,11,11,11,11,12, |
375 | 13,13,8,7,9,9,10,10,11,11,10,11,11,12,12,13,13,14,9,8,9,10,10,10,11,11,11,11, | 378 | 13,13,8,7,9,9,10,10,11,11,10,11,11,12,12,13,13,14,9,8,9,10,10,10,11,11,11,11, |
@@ -381,7 +384,7 @@ static const uint8_t t13l_const[256] = | |||
381 | 16,16,13,12,12,13,13,13,15,14,14,17,15,15,15,17,16,16,12,12,13,14,14,14,15,14, | 384 | 16,16,13,12,12,13,13,13,15,14,14,17,15,15,15,17,16,16,12,12,13,14,14,14,15,14, |
382 | 15,15,16,16,19,18,19,16}; | 385 | 15,15,16,16,19,18,19,16}; |
383 | 386 | ||
384 | static const uint8_t t15l_const[256] = | 387 | static const uint8_t t15l[256] = |
385 | {3,4,5,7,7,8,9,9,9,10,10,11,11,11,12,13,4,3,5,6,7,7,8,8,8,9,9,10,10,10,11,11,5, | 388 | {3,4,5,7,7,8,9,9,9,10,10,11,11,11,12,13,4,3,5,6,7,7,8,8,8,9,9,10,10,10,11,11,5, |
386 | 5,5,6,7,7,8,8,8,9,9,10,10,11,11,11,6,6,6,7,7,8,8,9,9,9,10,10,10,11,11,11,7,6, | 389 | 5,5,6,7,7,8,8,8,9,9,10,10,11,11,11,6,6,6,7,7,8,8,9,9,9,10,10,10,11,11,11,7,6, |
387 | 7,7,8,8,9,9,9,9,10,10,10,11,11,11,8,7,7,8,8,8,9,9,9,9,10,10,11,11,11,12,9,7,8, | 390 | 7,7,8,8,9,9,9,9,10,10,10,11,11,11,8,7,7,8,8,8,9,9,9,9,10,10,11,11,11,12,9,7,8, |
@@ -392,7 +395,7 @@ static const uint8_t t15l_const[256] = | |||
392 | 11,11,11,11,12,12,12,12,12,13,13,12,11,11,11,11,11,11,11,12,12,12,12,13,13,12, | 395 | 11,11,11,11,12,12,12,12,12,13,13,12,11,11,11,11,11,11,11,12,12,12,12,13,13,12, |
393 | 13,12,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13}; | 396 | 13,12,11,11,11,11,11,11,12,12,12,12,12,13,13,13,13}; |
394 | 397 | ||
395 | static const uint8_t t16l_const[256] = | 398 | static const uint8_t t16l[256] = |
396 | {1,4,6,8,9,9,10,10,11,11,11,12,12,12,13,9,3,4,6,7,8,9,9,9,10,10,10,11,12,11,12, | 399 | {1,4,6,8,9,9,10,10,11,11,11,12,12,12,13,9,3,4,6,7,8,9,9,9,10,10,10,11,12,11,12, |
397 | 8,6,6,7,8,9,9,10,10,11,10,11,11,11,12,12,9,8,7,8,9,9,10,10,10,11,11,12,12,12, | 400 | 8,6,6,7,8,9,9,10,10,11,10,11,11,11,12,12,9,8,7,8,9,9,10,10,10,11,11,12,12,12, |
398 | 13,13,10,9,8,9,9,10,10,11,11,11,12,12,12,13,13,13,9,9,8,9,9,10,11,11,12,11,12, | 401 | 13,13,10,9,8,9,9,10,10,11,11,11,12,12,12,13,13,13,9,9,8,9,9,10,11,11,12,11,12, |
@@ -404,7 +407,7 @@ static const uint8_t t16l_const[256] = | |||
404 | 17,15,11,13,13,11,12,14,14,13,14,14,15,16,15,17,15,14,11,9,8,8,9,9,10,10,10, | 407 | 17,15,11,13,13,11,12,14,14,13,14,14,15,16,15,17,15,14,11,9,8,8,9,9,10,10,10, |
405 | 11,11,11,11,11,11,11,8}; | 408 | 11,11,11,11,11,11,11,8}; |
406 | 409 | ||
407 | static const uint8_t t24l_const[256] = | 410 | static const uint8_t t24l[256] = |
408 | {4,4,6,7,8,9,9,10,10,11,11,11,11,11,12,9,4,4,5,6,7,8,8,9,9,9,10,10,10,10,10,8, | 411 | {4,4,6,7,8,9,9,10,10,11,11,11,11,11,12,9,4,4,5,6,7,8,8,9,9,9,10,10,10,10,10,8, |
409 | 6,5,6,7,7,8,8,9,9,9,9,10,10,10,11,7,7,6,7,7,8,8,8,9,9,9,9,10,10,10,10,7,8,7,7, | 412 | 6,5,6,7,7,8,8,9,9,9,9,10,10,10,11,7,7,6,7,7,8,8,8,9,9,9,9,10,10,10,10,7,8,7,7, |
410 | 8,8,8,8,9,9,9,10,10,10,10,11,7,9,7,8,8,8,8,9,9,9,9,10,10,10,10,10,7,9,8,8,8,8, | 413 | 8,8,8,8,9,9,9,10,10,10,10,11,7,9,7,8,8,8,8,9,9,9,9,10,10,10,10,10,7,9,8,8,8,8, |
@@ -415,7 +418,7 @@ static const uint8_t t24l_const[256] = | |||
415 | 11,11,11,11,11,11,8,12,10,10,10,10,10,10,11,11,11,11,11,11,11,11,8,8,7,7,7,7, | 418 | 11,11,11,11,11,11,8,12,10,10,10,10,10,10,11,11,11,11,11,11,11,11,8,8,7,7,7,7, |
416 | 7,7,7,7,7,7,8,8,8,8,4}; | 419 | 7,7,7,7,7,7,8,8,8,8,4}; |
417 | 420 | ||
418 | static const struct huffcodetab ht_const[HTN] = | 421 | static struct huffcodetab ht[HTN] = |
419 | { { 0, NULL, NULL}, /* Apparently not used */ | 422 | { { 0, NULL, NULL}, /* Apparently not used */ |
420 | { 2, t1HB, t1l}, | 423 | { 2, t1HB, t1l}, |
421 | { 3, t2HB, t2l}, | 424 | { 3, t2HB, t2l}, |
@@ -453,8 +456,8 @@ static const struct huffcodebig ht_big[HTN] = | |||
453 | 456 | ||
454 | static const struct | 457 | static const struct |
455 | { | 458 | { |
456 | uint32_t region0_cnt; | 459 | const uint8_t region0_cnt; |
457 | uint32_t region1_cnt; | 460 | const uint8_t region1_cnt; |
458 | } subdv_table[23] = | 461 | } subdv_table[23] = |
459 | { {0, 0}, /* 0 bands */ | 462 | { {0, 0}, /* 0 bands */ |
460 | {0, 0}, /* 1 bands */ | 463 | {0, 0}, /* 1 bands */ |
@@ -481,7 +484,7 @@ static const struct | |||
481 | {6, 7}, /* 22 bands */ | 484 | {6, 7}, /* 22 bands */ |
482 | }; | 485 | }; |
483 | 486 | ||
484 | static const uint32_t sfBand[6][23] = | 487 | static const uint16_t sfBand[6][23] = |
485 | { | 488 | { |
486 | /* Table B.2.b: 22.05 kHz */ | 489 | /* Table B.2.b: 22.05 kHz */ |
487 | {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, | 490 | {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, |
@@ -497,7 +500,7 @@ static const uint32_t sfBand[6][23] = | |||
497 | {0,4, 8,12,16,20,24,30,36,44,54,66, 82,102,126,156,194,240,296,364,448,550,576} }; | 500 | {0,4, 8,12,16,20,24,30,36,44,54,66, 82,102,126,156,194,240,296,364,448,550,576} }; |
498 | 501 | ||
499 | 502 | ||
500 | static const short int2idx_const[4096] = /* int2idx[i] = sqrt(i*sqrt(i)); */ | 503 | static const uint16_t int2idx[4096] = /* int2idx[i] = sqrt(i*sqrt(i)); */ |
501 | { | 504 | { |
502 | 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, | 505 | 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, |
503 | 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, | 506 | 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, |
@@ -705,33 +708,33 @@ static const short int2idx_const[4096] = /* int2idx[i] = sqrt(i*sqrt(i)); */ | |||
705 | 509,509,509,509,509,509,509,509,509,509,510,510,510,510,510,510,510,510,510,510, | 708 | 509,509,509,509,509,509,509,509,509,509,510,510,510,510,510,510,510,510,510,510, |
706 | 510,511,511,511,511,511,511,511,511,511,511,512,512,512,512,512 }; | 709 | 510,511,511,511,511,511,511,511,511,511,511,512,512,512,512,512 }; |
707 | 710 | ||
708 | static const int order[32] = | 711 | static const uint8_t order[32] = |
709 | { 0, 1, 16, 17, 8, 9, 24, 25, 4, 5, 20, 21, 12, 13, 28, 29, | 712 | { 0, 1, 16, 17, 8, 9, 24, 25, 4, 5, 20, 21, 12, 13, 28, 29, |
710 | 2, 3, 18, 19,10,11, 26, 27, 6, 7, 22, 23, 14, 15, 30, 31 }; | 713 | 2, 3, 18, 19,10,11, 26, 27, 6, 7, 22, 23, 14, 15, 30, 31 }; |
711 | 714 | ||
712 | static const long sampr_index[2][3] = | 715 | static const uint16_t sampr_index[2][3] = |
713 | { { 22050, 24000, 16000 }, /* MPEG 2 */ | 716 | { { 22050, 24000, 16000 }, /* MPEG 2 */ |
714 | { 44100, 48000, 32000 } }; /* MPEG 1 */ | 717 | { 44100, 48000, 32000 } }; /* MPEG 1 */ |
715 | 718 | ||
716 | static const long bitr_index[2][15] = | 719 | static const uint16_t bitr_index[2][15] = |
717 | { {0, 8,16,24,32,40,48,56, 64, 80, 96,112,128,144,160}, /* MPEG 2 */ | 720 | { {0, 8,16,24,32,40,48,56, 64, 80, 96,112,128,144,160}, /* MPEG 2 */ |
718 | {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320} }; /* MPEG 1 */ | 721 | {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320} }; /* MPEG 1 */ |
719 | 722 | ||
720 | static const int num_bands[3][15] = | 723 | static const uint8_t num_bands[3][15] = |
721 | { {0,10,10,10,10,12,14,16, 20, 22, 24, 26, 28, 30, 32}, | 724 | { {0,10,10,10,10,12,14,16, 20, 22, 24, 26, 28, 30, 32}, |
722 | {0,10,10,10,10,10,12,14, 18, 24, 26, 28, 30, 32, 32}, | 725 | {0,10,10,10,10,10,12,14, 18, 24, 26, 28, 30, 32, 32}, |
723 | {0,10,12,14,18,24,26,28, 30, 32, 32, 32, 32, 32, 32} }; | 726 | {0,10,12,14,18,24,26,28, 30, 32, 32, 32, 32, 32, 32} }; |
724 | 727 | ||
725 | static const int cx_const[9] = | 728 | static const int16_t cx[9] = |
726 | { 16135, 10531, 5604, 15396, -2845,-12551, 14189, 8192, 16384 }; | 729 | { 16135, 10531, 5604, 15396, -2845,-12551, 14189, 8192, 16384 }; |
727 | 730 | ||
728 | static const int ca_const[8] = | 731 | static const int16_t ca[8] = |
729 | {-16859,-15458,-10269, -5961, -3099, -1342, -465, -121 }; | 732 | {-16859,-15458,-10269, -5961, -3099, -1342, -465, -121 }; |
730 | 733 | ||
731 | static const int cs_const[8] = | 734 | static const uint16_t cs[8] = |
732 | { 28098, 28893, 31117, 32221, 32621, 32740, 32765, 32768 }; | 735 | { 28098, 28893, 31117, 32221, 32621, 32740, 32765, 32768 }; |
733 | 736 | ||
734 | static const short enwindow_const[15*27+24] = | 737 | static const int16_t enwindow[15*27+24] = |
735 | { 0, 65, 593, 1766, 22228, 2115, 611, 62, | 738 | { 0, 65, 593, 1766, 22228, 2115, 611, 62, |
736 | 8, 119, 1419, 10564,-11659,-1635,-154, -9, | 739 | 8, 119, 1419, 10564,-11659,-1635,-154, -9, |
737 | -8, -119,-1419,-10564, 11659, 1635, 154, 9, 464, 100, 91, | 740 | -8, -119,-1419,-10564, 11659, 1635, 154, 9, 464, 100, 91, |
@@ -782,7 +785,7 @@ static const short enwindow_const[15*27+24] = | |||
782 | 21226,-21226,10604,-10604,1860,-1860,1458,-1458,576,-576,130,-130,60,-60,8,-8 | 785 | 21226,-21226,10604,-10604,1860,-1860,1458,-1458,576,-576,130,-130,60,-60,8,-8 |
783 | }; | 786 | }; |
784 | 787 | ||
785 | static const int win_const[18][4] = { | 788 | static const int16_t win[18][4] = { |
786 | { -3072, -134, -146, 3352 }, | 789 | { -3072, -134, -146, 3352 }, |
787 | { -2747, -362, -471, 3579 }, | 790 | { -2747, -362, -471, 3579 }, |
788 | { -2387, -529, -831, 3747 }, | 791 | { -2387, -529, -831, 3747 }, |
@@ -805,7 +808,8 @@ static const int win_const[18][4] = { | |||
805 | 808 | ||
806 | static const char* wav_filename; | 809 | static const char* wav_filename; |
807 | static int mp3file, wavfile, wav_size, frames; | 810 | static int mp3file, wavfile, wav_size, frames; |
808 | static uint32_t enc_buffer[16384]; /* storage for 65536 Bytes */ | 811 | static void *enc_buffer; |
812 | static size_t enc_buffer_size; | ||
809 | static int enc_chunk = 0; /* encode chunk counter */ | 813 | static int enc_chunk = 0; /* encode chunk counter */ |
810 | static int enc_size; | 814 | static int enc_size; |
811 | static config_t cfg; | 815 | static config_t cfg; |
@@ -1100,9 +1104,9 @@ int HuffmanCode(short *ix, char *xr_sign, uint32_t begin, uint32_t end, int tabl | |||
1100 | 1104 | ||
1101 | if( table > 15 ) | 1105 | if( table > 15 ) |
1102 | { /* ESC-table is used */ | 1106 | { /* ESC-table is used */ |
1103 | uint32_t linbits = ht_big[table-16].linbits; | 1107 | uint32_t linbits = ht_big[table-16].linbits; |
1104 | uint16_t *hffcode = table < 24 ? t16HB : t24HB; | 1108 | const uint16_t *hffcode = table < 24 ? t16HB : t24HB; |
1105 | uint8_t *hlen = table < 24 ? t16l : t24l; | 1109 | const uint8_t *hlen = table < 24 ? t16l : t24l; |
1106 | 1110 | ||
1107 | for(i=begin; i<end; i+=2) | 1111 | for(i=begin; i<end; i+=2) |
1108 | { | 1112 | { |
@@ -1564,7 +1568,8 @@ void window_subband1(short *wk, int sb0[SBLIMIT], int sb1[SBLIMIT]) ICODE_ATTR; | |||
1564 | void window_subband1(short *wk, int sb0[SBLIMIT], int sb1[SBLIMIT]) | 1568 | void window_subband1(short *wk, int sb0[SBLIMIT], int sb1[SBLIMIT]) |
1565 | { | 1569 | { |
1566 | int k, i, u, v; | 1570 | int k, i, u, v; |
1567 | short *wp, *x1, *x2; | 1571 | short *x1, *x2; |
1572 | short const *wp; | ||
1568 | 1573 | ||
1569 | #ifdef CPU_COLDFIRE | 1574 | #ifdef CPU_COLDFIRE |
1570 | int s0, s1, t0, t1; | 1575 | int s0, s1, t0, t1; |
@@ -1824,7 +1829,7 @@ void window_subband2(short *x1, int a[SBLIMIT]) ICODE_ATTR; | |||
1824 | void window_subband2(short *x1, int a[SBLIMIT]) | 1829 | void window_subband2(short *x1, int a[SBLIMIT]) |
1825 | { | 1830 | { |
1826 | int xr; | 1831 | int xr; |
1827 | short *wp = enwindow; | 1832 | short const *wp = enwindow; |
1828 | short *x2 = x1 - 124; | 1833 | short *x2 = x1 - 124; |
1829 | 1834 | ||
1830 | wp += 27 * 15; | 1835 | wp += 27 * 15; |
@@ -2011,7 +2016,7 @@ void mdct_long(int *out, int *in) | |||
2011 | out[16] = ct - st; | 2016 | out[16] = ct - st; |
2012 | } | 2017 | } |
2013 | 2018 | ||
2014 | static int find_bitrate_index(int type, int bitrate) | 2019 | static int find_bitrate_index(int type, uint16_t bitrate) |
2015 | { | 2020 | { |
2016 | int i; | 2021 | int i; |
2017 | 2022 | ||
@@ -2022,7 +2027,7 @@ static int find_bitrate_index(int type, int bitrate) | |||
2022 | return i; | 2027 | return i; |
2023 | } | 2028 | } |
2024 | 2029 | ||
2025 | static int find_samplerate_index(long freq, int *mp3_type) | 2030 | static int find_samplerate_index(uint16_t freq, int *mp3_type) |
2026 | { | 2031 | { |
2027 | int mpg, rate; | 2032 | int mpg, rate; |
2028 | 2033 | ||
@@ -2037,7 +2042,7 @@ static int find_samplerate_index(long freq, int *mp3_type) | |||
2037 | return 0; | 2042 | return 0; |
2038 | } | 2043 | } |
2039 | 2044 | ||
2040 | void init_mp3_encoder_engine(bool stereo, int bitrate, int sample_rate) | 2045 | void init_mp3_encoder_engine(bool stereo, int bitrate, uint16_t sample_rate) |
2041 | { | 2046 | { |
2042 | uint32_t avg_byte_per_frame; | 2047 | uint32_t avg_byte_per_frame; |
2043 | 2048 | ||
@@ -2067,57 +2072,7 @@ void init_mp3_encoder_engine(bool stereo, int bitrate, int sample_rate) | |||
2067 | cfg.mpg.bitr_id = find_bitrate_index(cfg.mpg.type, cfg.mpg.bitrate); | 2072 | cfg.mpg.bitr_id = find_bitrate_index(cfg.mpg.type, cfg.mpg.bitrate); |
2068 | cfg.mpg.num_bands = num_bands[stereo ? cfg.mpg.type : 2][cfg.mpg.bitr_id]; | 2073 | cfg.mpg.num_bands = num_bands[stereo ? cfg.mpg.type : 2][cfg.mpg.bitr_id]; |
2069 | 2074 | ||
2070 | memcpy(scalefac, sfBand[cfg.mpg.smpl_id + 3*cfg.mpg.type], sizeof(scalefac)); | 2075 | scalefac = sfBand[cfg.mpg.smpl_id + 3*cfg.mpg.type]; |
2071 | memset(mfbuf , 0 , sizeof(mfbuf )); | ||
2072 | memset(mdct_freq , 0 , sizeof(mdct_freq )); | ||
2073 | memset(enc_data , 0 , sizeof(enc_data )); | ||
2074 | memset(sb_data , 0 , sizeof(sb_data )); | ||
2075 | memset(&CodedData, 0 , sizeof(CodedData )); | ||
2076 | memcpy(ca , ca_const , sizeof(ca )); | ||
2077 | memcpy(cs , cs_const , sizeof(cs )); | ||
2078 | memcpy(cx , cx_const , sizeof(cx )); | ||
2079 | memcpy(win , win_const , sizeof(win )); | ||
2080 | memcpy(enwindow , enwindow_const , sizeof(enwindow )); | ||
2081 | memcpy(int2idx , int2idx_const , sizeof(int2idx )); | ||
2082 | memcpy(ht_count , ht_count_const , sizeof(ht_count )); | ||
2083 | memcpy( tab01 , tab01_const , sizeof(tab01 )); | ||
2084 | memcpy( tab23 , tab23_const , sizeof(tab23 )); | ||
2085 | memcpy( tab56 , tab56_const , sizeof(tab56 )); | ||
2086 | memcpy( tab1315 , tab1315_const , sizeof(tab1315 )); | ||
2087 | memcpy( tab1624 , tab1624_const , sizeof(tab1624 )); | ||
2088 | memcpy( tab789 , tab789_const , sizeof(tab789 )); | ||
2089 | memcpy( tabABC , tabABC_const , sizeof(tabABC )); | ||
2090 | memcpy( t1HB , t1HB_const , sizeof(t1HB )); | ||
2091 | memcpy( t2HB , t2HB_const , sizeof(t2HB )); | ||
2092 | memcpy( t3HB , t3HB_const , sizeof(t3HB )); | ||
2093 | memcpy( t5HB , t5HB_const , sizeof(t5HB )); | ||
2094 | memcpy( t6HB , t6HB_const , sizeof(t6HB )); | ||
2095 | memcpy( t7HB , t7HB_const , sizeof(t7HB )); | ||
2096 | memcpy( t8HB , t8HB_const , sizeof(t8HB )); | ||
2097 | memcpy( t9HB , t9HB_const , sizeof(t9HB )); | ||
2098 | memcpy(t10HB , t10HB_const , sizeof(t10HB )); | ||
2099 | memcpy(t11HB , t11HB_const , sizeof(t11HB )); | ||
2100 | memcpy(t12HB , t12HB_const , sizeof(t12HB )); | ||
2101 | memcpy(t13HB , t13HB_const , sizeof(t13HB )); | ||
2102 | memcpy(t15HB , t15HB_const , sizeof(t15HB )); | ||
2103 | memcpy(t16HB , t16HB_const , sizeof(t16HB )); | ||
2104 | memcpy(t24HB , t24HB_const , sizeof(t24HB )); | ||
2105 | memcpy( t1l , t1l_const , sizeof(t1l )); | ||
2106 | memcpy( t2l , t2l_const , sizeof(t2l )); | ||
2107 | memcpy( t3l , t3l_const , sizeof(t3l )); | ||
2108 | memcpy( t5l , t5l_const , sizeof(t5l )); | ||
2109 | memcpy( t6l , t6l_const , sizeof(t6l )); | ||
2110 | memcpy( t7l , t7l_const , sizeof(t7l )); | ||
2111 | memcpy( t8l , t8l_const , sizeof(t8l )); | ||
2112 | memcpy( t9l , t9l_const , sizeof(t9l )); | ||
2113 | memcpy(t10l , t10l_const , sizeof(t10l )); | ||
2114 | memcpy(t11l , t11l_const , sizeof(t11l )); | ||
2115 | memcpy(t12l , t12l_const , sizeof(t12l )); | ||
2116 | memcpy(t13l , t13l_const , sizeof(t13l )); | ||
2117 | memcpy(t15l , t15l_const , sizeof(t15l )); | ||
2118 | memcpy(t16l , t16l_const , sizeof(t16l )); | ||
2119 | memcpy(t24l , t24l_const , sizeof(t24l )); | ||
2120 | memcpy(ht , ht_const , sizeof(ht )); | ||
2121 | 2076 | ||
2122 | ht[ 0].table = NULL; ht[ 0].hlen = NULL; /* Apparently not used */ | 2077 | ht[ 0].table = NULL; ht[ 0].hlen = NULL; /* Apparently not used */ |
2123 | ht[ 1].table = t1HB; ht[ 1].hlen = t1l; | 2078 | ht[ 1].table = t1HB; ht[ 1].hlen = t1l; |
@@ -2377,7 +2332,7 @@ void compress(void) | |||
2377 | for(i=0; i<(enc_size+3)/4; i++) | 2332 | for(i=0; i<(enc_size+3)/4; i++) |
2378 | CodedData.bbuf[i] = myswap32(CodedData.bbuf[i]); | 2333 | CodedData.bbuf[i] = myswap32(CodedData.bbuf[i]); |
2379 | 2334 | ||
2380 | if(enc_chunk + enc_size > 65536) | 2335 | if(enc_chunk + enc_size > (int)enc_buffer_size) |
2381 | { | 2336 | { |
2382 | /* copy iram mp3 buffer to sdram/file */ | 2337 | /* copy iram mp3 buffer to sdram/file */ |
2383 | rb->write(mp3file, enc_buffer, enc_chunk & ~3); | 2338 | rb->write(mp3file, enc_buffer, enc_chunk & ~3); |
@@ -2385,7 +2340,7 @@ void compress(void) | |||
2385 | enc_chunk &= 3; | 2340 | enc_chunk &= 3; |
2386 | } | 2341 | } |
2387 | 2342 | ||
2388 | memcpy((char*)enc_buffer + enc_chunk, CodedData.bbuf, enc_size); | 2343 | memcpy(enc_buffer + enc_chunk, CodedData.bbuf, enc_size); |
2389 | enc_chunk += enc_size; | 2344 | enc_chunk += enc_size; |
2390 | frames++; | 2345 | frames++; |
2391 | } | 2346 | } |
@@ -2554,6 +2509,8 @@ enum plugin_status plugin_start(const void* parameter) | |||
2554 | 2509 | ||
2555 | PLUGIN_IRAM_INIT(rb) | 2510 | PLUGIN_IRAM_INIT(rb) |
2556 | 2511 | ||
2512 | enc_buffer = rb->plugin_get_audio_buffer(&enc_buffer_size); | ||
2513 | |||
2557 | #ifdef CPU_COLDFIRE | 2514 | #ifdef CPU_COLDFIRE |
2558 | coldfire_set_macsr(0); /* integer mode */ | 2515 | coldfire_set_macsr(0); /* integer mode */ |
2559 | #endif | 2516 | #endif |