summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2010-08-04 22:29:50 +0000
committerMohamed Tarek <mt@rockbox.org>2010-08-04 22:29:50 +0000
commit3bbbb9639587fa17df470e605cda6ebd1a3af021 (patch)
tree5fe4e540263b986521403d462db4d02f28b2b84d
parent83be40f7d355e7af8db12f5854ada831a8c68e8e (diff)
downloadrockbox-3bbbb9639587fa17df470e605cda6ebd1a3af021.tar.gz
rockbox-3bbbb9639587fa17df470e605cda6ebd1a3af021.zip
Use codeclib's mdct in wmapro. Input coeffs to the transform needed to be scaled down first by (log2(frame_size) - 3). Increases decoding speed by 1.3MHz on PP5022 and saves ~32KB that were previously needed by the mdct tables. (FS#11511 by Buschel and myself)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27701 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libwmapro/SOURCES1
-rw-r--r--apps/codecs/libwmapro/mdct_tables.c3
-rw-r--r--apps/codecs/libwmapro/mdct_tables.h3
-rw-r--r--apps/codecs/libwmapro/wma.c15
-rw-r--r--apps/codecs/libwmapro/wmaprodec.c17
5 files changed, 27 insertions, 12 deletions
diff --git a/apps/codecs/libwmapro/SOURCES b/apps/codecs/libwmapro/SOURCES
index ce4bfc234d..296f26ab7f 100644
--- a/apps/codecs/libwmapro/SOURCES
+++ b/apps/codecs/libwmapro/SOURCES
@@ -2,4 +2,3 @@ wmaprodec.c
2wma.c 2wma.c
3mdct_tables.c 3mdct_tables.c
4../lib/ffmpeg_bitstream.c 4../lib/ffmpeg_bitstream.c
5wmapro_mdct.c
diff --git a/apps/codecs/libwmapro/mdct_tables.c b/apps/codecs/libwmapro/mdct_tables.c
index dd8b2a451c..edb15a4159 100644
--- a/apps/codecs/libwmapro/mdct_tables.c
+++ b/apps/codecs/libwmapro/mdct_tables.c
@@ -1378,6 +1378,7 @@ const int32_t *sine_windows[6] = {
1378 the table should be in s.31 format, but in wma pro, all the tables are scaled 1378 the table should be in s.31 format, but in wma pro, all the tables are scaled
1379 down to preserve energy in the signal, so this downscaling is equivalent to 1379 down to preserve energy in the signal, so this downscaling is equivalent to
1380 having the tables in ~s15.16 instead. */ 1380 having the tables in ~s15.16 instead. */
1381/* rockbox: not used
1381const int32_t sincos_lookup_wmap[8064] = { 1382const int32_t sincos_lookup_wmap[8064] = {
1382 0x0000011C, 0x00016A09, 0x000009FE, 0x000169E6, 1383 0x0000011C, 0x00016A09, 0x000009FE, 0x000169E6,
1383 0x000012DF, 0x0001698B, 0x00001BBD, 0x000168F9, 1384 0x000012DF, 0x0001698B, 0x00001BBD, 0x000168F9,
@@ -3387,4 +3388,4 @@ const int32_t sincos_lookup_wmap[8064] = {
3387 0x00003FFD, 0x00000112, 0x00003FFD, 0x00000106, 3388 0x00003FFD, 0x00000112, 0x00003FFD, 0x00000106,
3388 0x00003FFE 3389 0x00003FFE
3389}; 3390};
3390 3391*/
diff --git a/apps/codecs/libwmapro/mdct_tables.h b/apps/codecs/libwmapro/mdct_tables.h
index f40bf70fcf..5e54868b01 100644
--- a/apps/codecs/libwmapro/mdct_tables.h
+++ b/apps/codecs/libwmapro/mdct_tables.h
@@ -3,7 +3,8 @@
3#include <inttypes.h> 3#include <inttypes.h>
4 4
5extern const int32_t *sine_windows[6]; 5extern const int32_t *sine_windows[6];
6/* rockbox: not used
6extern const int32_t sincos_lookup_wmap[8064]; 7extern const int32_t sincos_lookup_wmap[8064];
7 8*/
8#endif /* _MDCT_TABLES_H_ */ 9#endif /* _MDCT_TABLES_H_ */
9 10
diff --git a/apps/codecs/libwmapro/wma.c b/apps/codecs/libwmapro/wma.c
index 64ec2405ae..83cec89a4c 100644
--- a/apps/codecs/libwmapro/wma.c
+++ b/apps/codecs/libwmapro/wma.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include "wma.h" 22#include "wma.h"
23#include "codeclib.h" /* needed for av_log2() */
23 24
24/** 25/**
25 *@brief Get the samples per frame for this stream. 26 *@brief Get the samples per frame for this stream.
@@ -109,14 +110,20 @@ int ff_wma_run_level_decode(GetBitContext* gb,
109{ 110{
110 int32_t code, level, sign; 111 int32_t code, level, sign;
111 const unsigned int coef_mask = block_len - 1; 112 const unsigned int coef_mask = block_len - 1;
113 /* Rockbox: To be able to use rockbox' optimized mdct we need to pre-shift
114 * the values by >>(nbits-3). */
115 const int nbits = av_log2(block_len)+1;
116 const int shift = WMAPRO_FRACT-(nbits-3);
112 for (; offset < num_coefs; offset++) { 117 for (; offset < num_coefs; offset++) {
113 code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX); 118 code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX);
114 if (code > 1) { 119 if (code > 1) {
115 /** normal code */ 120 /** normal code */
116 offset += run_table[code]; 121 offset += run_table[code];
117 sign = !get_bits1(gb); 122 sign = !get_bits1(gb);
118 ptr[offset & coef_mask] = sign ? -level_table[code] : level_table[code]; 123 /* Rockbox: To be able to use rockbox' optimized mdct we need
119 ptr[offset & coef_mask] <<= WMAPRO_FRACT; 124 * invert the sign. */
125 ptr[offset & coef_mask] = sign ? level_table[code] : -level_table[code];
126 ptr[offset & coef_mask] <<= shift;
120 } else if (code == 1) { 127 } else if (code == 1) {
121 /** EOB */ 128 /** EOB */
122 break; 129 break;
@@ -143,8 +150,8 @@ int ff_wma_run_level_decode(GetBitContext* gb,
143 } 150 }
144 } 151 }
145 sign = !get_bits1(gb); 152 sign = !get_bits1(gb);
146 ptr[offset & coef_mask] = sign ? -level : level; 153 ptr[offset & coef_mask] = sign ? level : -level;
147 ptr[offset & coef_mask] <<= WMAPRO_FRACT; 154 ptr[offset & coef_mask] <<= shift;
148 } 155 }
149 } 156 }
150 /** NOTE: EOB can be omitted */ 157 /** NOTE: EOB can be omitted */
diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c
index a7a0f4d34d..e5a5fd94eb 100644
--- a/apps/codecs/libwmapro/wmaprodec.c
+++ b/apps/codecs/libwmapro/wmaprodec.c
@@ -91,7 +91,7 @@
91#include "wmaprodata.h" 91#include "wmaprodata.h"
92#include "wma.h" 92#include "wma.h"
93#include "wmaprodec.h" 93#include "wmaprodec.h"
94#include "wmapro_mdct.h" 94//#include "wmapro_mdct.h"
95#include "mdct_tables.h" 95#include "mdct_tables.h"
96#include "quant.h" 96#include "quant.h"
97#include "wmapro_math.h" 97#include "wmapro_math.h"
@@ -878,11 +878,18 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
878 vals[3] = (symbol_to_vec4[idx] ) & 0xF; 878 vals[3] = (symbol_to_vec4[idx] ) & 0xF;
879 } 879 }
880 880
881 /* Rockbox: To be able to use rockbox' optimized mdct we need to
882 * pre-shift the values by >>(nbits-3). */
883 const int nbits = av_log2(s->subframe_len)+1;
884 const int shift = WMAPRO_FRACT-(nbits-3);
885
881 /** decode sign */ 886 /** decode sign */
882 for (i = 0; i < 4; i++) { 887 for (i = 0; i < 4; i++) {
883 if (vals[i]) { 888 if (vals[i]) {
884 int sign = get_bits1(&s->gb) - 1; 889 int sign = get_bits1(&s->gb) - 1;
885 ci->coeffs[cur_coeff] = (sign == -1)? -vals[i]<<WMAPRO_FRACT : vals[i]<<WMAPRO_FRACT; 890 /* Rockbox: To be able to use rockbox' optimized mdct we need
891 * invert the sign. */
892 ci->coeffs[cur_coeff] = (sign == -1)? vals[i]<<shift : -vals[i]<<shift;
886 num_zeros = 0; 893 num_zeros = 0;
887 } else { 894 } else {
888 ci->coeffs[cur_coeff] = 0; 895 ci->coeffs[cur_coeff] = 0;
@@ -1266,6 +1273,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
1266 get_bits_count(&s->gb) - s->subframe_offset); 1273 get_bits_count(&s->gb) - s->subframe_offset);
1267 1274
1268 if (transmit_coeffs) { 1275 if (transmit_coeffs) {
1276 int nbits = av_log2(subframe_len)+1;
1269 /** reconstruct the per channel data */ 1277 /** reconstruct the per channel data */
1270 inverse_channel_transform(s); 1278 inverse_channel_transform(s);
1271 for (i = 0; i < s->channels_for_cur_subframe; i++) { 1279 for (i = 0; i < s->channels_for_cur_subframe; i++) {
@@ -1276,7 +1284,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
1276 if (c == s->lfe_channel) 1284 if (c == s->lfe_channel)
1277 memset(&s->tmp[cur_subwoofer_cutoff], 0, sizeof(*s->tmp) * 1285 memset(&s->tmp[cur_subwoofer_cutoff], 0, sizeof(*s->tmp) *
1278 (subframe_len - cur_subwoofer_cutoff)); 1286 (subframe_len - cur_subwoofer_cutoff));
1279 1287
1280 /** inverse quantization and rescaling */ 1288 /** inverse quantization and rescaling */
1281 for (b = 0; b < s->num_bands; b++) { 1289 for (b = 0; b < s->num_bands; b++) {
1282 const int end = FFMIN(s->cur_sfb_offsets[b+1], s->subframe_len); 1290 const int end = FFMIN(s->cur_sfb_offsets[b+1], s->subframe_len);
@@ -1299,8 +1307,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
1299 } 1307 }
1300 1308
1301 /** apply imdct (ff_imdct_half == DCTIV with reverse) */ 1309 /** apply imdct (ff_imdct_half == DCTIV with reverse) */
1302 imdct_half(av_log2(subframe_len)+1, 1310 ff_imdct_half(nbits,s->channel[c].coeffs, s->tmp);
1303 s->channel[c].coeffs, s->tmp);
1304 1311
1305 } 1312 }
1306 } 1313 }