diff options
author | Michael Giacomelli <giac2000@hotmail.com> | 2007-08-06 01:43:09 +0000 |
---|---|---|
committer | Michael Giacomelli <giac2000@hotmail.com> | 2007-08-06 01:43:09 +0000 |
commit | 98f0d7787906e91d50c3f1d435df9fd8fcaccc31 (patch) | |
tree | 0b351b1100bb8e1bde8d665f44385a2bb93ebb41 /apps | |
parent | b1fa2f44a2c05997268bdac8d6d85d723e4e85a3 (diff) | |
download | rockbox-98f0d7787906e91d50c3f1d435df9fd8fcaccc31.tar.gz rockbox-98f0d7787906e91d50c3f1d435df9fd8fcaccc31.zip |
Clean up VLC functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14206 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/libwma/bitstream.c | 19 | ||||
-rw-r--r-- | apps/codecs/libwma/wmadeci.c | 21 |
2 files changed, 16 insertions, 24 deletions
diff --git a/apps/codecs/libwma/bitstream.c b/apps/codecs/libwma/bitstream.c index bce7ee2ae6..78b078adc7 100644 --- a/apps/codecs/libwma/bitstream.c +++ b/apps/codecs/libwma/bitstream.c | |||
@@ -119,8 +119,7 @@ static int build_table(VLC *vlc, int table_nb_bits, | |||
119 | const void *codes, int codes_wrap, int codes_size, | 119 | const void *codes, int codes_wrap, int codes_size, |
120 | uint32_t code_prefix, int n_prefix) | 120 | uint32_t code_prefix, int n_prefix) |
121 | { | 121 | { |
122 | int i, j, k, n, table_size, table_index, nb, n1, index; | 122 | int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2; |
123 | uint32_t code_prefix2; | ||
124 | uint32_t code; | 123 | uint32_t code; |
125 | int flags = 0; | 124 | int flags = 0; |
126 | VLC_TYPE (*table)[2]; | 125 | VLC_TYPE (*table)[2]; |
@@ -153,10 +152,10 @@ static int build_table(VLC *vlc, int table_nb_bits, | |||
153 | /* if code matches the prefix, it is in the table */ | 152 | /* if code matches the prefix, it is in the table */ |
154 | n -= n_prefix; | 153 | n -= n_prefix; |
155 | if(flags & INIT_VLC_LE) | 154 | if(flags & INIT_VLC_LE) |
156 | code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (uint32_t)( (1 << n_prefix)-1)); | 155 | code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (uint32_t)(1 << n_prefix)-1); |
157 | else | 156 | else |
158 | code_prefix2= code >> n; | 157 | code_prefix2= code >> n; |
159 | if (n > 0 && code_prefix2 == code_prefix) { | 158 | if (n > 0 && (int)code_prefix2 == code_prefix) { |
160 | if (n <= table_nb_bits) { | 159 | if (n <= table_nb_bits) { |
161 | /* no need to add another table */ | 160 | /* no need to add another table */ |
162 | j = (code << (table_nb_bits - n)) & (table_size - 1); | 161 | j = (code << (table_nb_bits - n)) & (table_size - 1); |
@@ -165,11 +164,10 @@ static int build_table(VLC *vlc, int table_nb_bits, | |||
165 | if(flags & INIT_VLC_LE) | 164 | if(flags & INIT_VLC_LE) |
166 | j = (code >> n_prefix) + (k<<n); | 165 | j = (code >> n_prefix) + (k<<n); |
167 | #ifdef DEBUG_VLC | 166 | #ifdef DEBUG_VLC |
168 | av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", | 167 | av_log(NULL, 0, "%4x: code=%d n=%d\n", |
169 | j, i, n); | 168 | j, i, n); |
170 | #endif | 169 | #endif |
171 | if (table[j][1] /*bits*/ != 0) { | 170 | if (table[j][1] /*bits*/ != 0) { |
172 | // av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); | ||
173 | return -1; | 171 | return -1; |
174 | } | 172 | } |
175 | table[j][1] = n; //bits | 173 | table[j][1] = n; //bits |
@@ -180,7 +178,7 @@ static int build_table(VLC *vlc, int table_nb_bits, | |||
180 | n -= table_nb_bits; | 178 | n -= table_nb_bits; |
181 | j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1); | 179 | j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1); |
182 | #ifdef DEBUG_VLC | 180 | #ifdef DEBUG_VLC |
183 | printf("%4x: n=%d (subtable)\n", | 181 | av_log(NULL, 0,"%4x: n=%d (subtable)\n", |
184 | j, n); | 182 | j, n); |
185 | #endif | 183 | #endif |
186 | /* compute table size */ | 184 | /* compute table size */ |
@@ -267,9 +265,4 @@ int init_vlc(VLC *vlc, int nb_bits, int nb_codes, | |||
267 | return flags; | 265 | return flags; |
268 | } | 266 | } |
269 | 267 | ||
270 | /* | 268 | |
271 | void free_vlc(VLC *vlc) | ||
272 | { | ||
273 | av_free(vlc->table); | ||
274 | } | ||
275 | */ | ||
diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c index f14fbc8197..b867e5c6f1 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c | |||
@@ -30,10 +30,10 @@ | |||
30 | #include "bitstream.h" | 30 | #include "bitstream.h" |
31 | 31 | ||
32 | 32 | ||
33 | #define VLCBITS 9 | 33 | #define VLCBITS 7 /*7 is the lowest without glitching*/ |
34 | #define VLCMAX ((22+VLCBITS-1)/VLCBITS) | 34 | #define VLCMAX ((22+VLCBITS-1)/VLCBITS) |
35 | 35 | ||
36 | #define EXPVLCBITS 9 | 36 | #define EXPVLCBITS 7 |
37 | #define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS) | 37 | #define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS) |
38 | 38 | ||
39 | #define HGAINVLCBITS 9 | 39 | #define HGAINVLCBITS 9 |
@@ -140,11 +140,12 @@ uint16_t runtab0[1336], runtab1[1336], levtab0[1336], levtab1[1336]; | |||
140 | 140 | ||
141 | FFTComplex mdct_tmp[1] ; /* dummy var */ | 141 | FFTComplex mdct_tmp[1] ; /* dummy var */ |
142 | 142 | ||
143 | //may also be too large by ~ 1KB each? | 143 | |
144 | static VLC_TYPE vlcbuf1[6144][2]; | 144 | /*putting these in IRAM actually makes PP slower*/ |
145 | static VLC_TYPE vlcbuf2[3584][2]; | 145 | VLC_TYPE vlcbuf1[2550][2]; |
146 | static VLC_TYPE vlcbuf3[1536][2] IBSS_ATTR; //small so lets try iram | 146 | VLC_TYPE vlcbuf2[2550][2]; |
147 | static VLC_TYPE vlcbuf4[540][2]; | 147 | VLC_TYPE vlcbuf3[360][2]; |
148 | VLC_TYPE vlcbuf4[540][2]; | ||
148 | 149 | ||
149 | 150 | ||
150 | 151 | ||
@@ -877,8 +878,7 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) | |||
877 | #endif | 878 | #endif |
878 | 879 | ||
879 | s->hgain_vlc.table = vlcbuf4; | 880 | s->hgain_vlc.table = vlcbuf4; |
880 | s->hgain_vlc.table_allocated = 540; | 881 | init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(hgain_huffbits), |
881 | init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits), | ||
882 | hgain_huffbits, 1, 1, | 882 | hgain_huffbits, 1, 1, |
883 | hgain_huffcodes, 2, 2, 0); | 883 | hgain_huffcodes, 2, 2, 0); |
884 | } | 884 | } |
@@ -887,9 +887,8 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) | |||
887 | { | 887 | { |
888 | 888 | ||
889 | s->exp_vlc.table = vlcbuf3; | 889 | s->exp_vlc.table = vlcbuf3; |
890 | s->exp_vlc.table_allocated = 1536; | ||
891 | 890 | ||
892 | init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits), | 891 | init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(scale_huffbits), |
893 | scale_huffbits, 1, 1, | 892 | scale_huffbits, 1, 1, |
894 | scale_huffcodes, 4, 4, 0); | 893 | scale_huffcodes, 4, 4, 0); |
895 | } | 894 | } |