1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Mohamed Tarek 2010-08-04 22:29:50 +00:00
parent 83be40f7d3
commit 3bbbb96395
5 changed files with 27 additions and 12 deletions

View file

@ -2,4 +2,3 @@ wmaprodec.c
wma.c wma.c
mdct_tables.c mdct_tables.c
../lib/ffmpeg_bitstream.c ../lib/ffmpeg_bitstream.c
wmapro_mdct.c

View file

@ -1378,6 +1378,7 @@ const int32_t *sine_windows[6] = {
the table should be in s.31 format, but in wma pro, all the tables are scaled the table should be in s.31 format, but in wma pro, all the tables are scaled
down to preserve energy in the signal, so this downscaling is equivalent to down to preserve energy in the signal, so this downscaling is equivalent to
having the tables in ~s15.16 instead. */ having the tables in ~s15.16 instead. */
/* rockbox: not used
const int32_t sincos_lookup_wmap[8064] = { const int32_t sincos_lookup_wmap[8064] = {
0x0000011C, 0x00016A09, 0x000009FE, 0x000169E6, 0x0000011C, 0x00016A09, 0x000009FE, 0x000169E6,
0x000012DF, 0x0001698B, 0x00001BBD, 0x000168F9, 0x000012DF, 0x0001698B, 0x00001BBD, 0x000168F9,
@ -3387,4 +3388,4 @@ const int32_t sincos_lookup_wmap[8064] = {
0x00003FFD, 0x00000112, 0x00003FFD, 0x00000106, 0x00003FFD, 0x00000112, 0x00003FFD, 0x00000106,
0x00003FFE 0x00003FFE
}; };
*/

View file

@ -3,7 +3,8 @@
#include <inttypes.h> #include <inttypes.h>
extern const int32_t *sine_windows[6]; extern const int32_t *sine_windows[6];
/* rockbox: not used
extern const int32_t sincos_lookup_wmap[8064]; extern const int32_t sincos_lookup_wmap[8064];
*/
#endif /* _MDCT_TABLES_H_ */ #endif /* _MDCT_TABLES_H_ */

View file

@ -20,6 +20,7 @@
*/ */
#include "wma.h" #include "wma.h"
#include "codeclib.h" /* needed for av_log2() */
/** /**
*@brief Get the samples per frame for this stream. *@brief Get the samples per frame for this stream.
@ -109,14 +110,20 @@ int ff_wma_run_level_decode(GetBitContext* gb,
{ {
int32_t code, level, sign; int32_t code, level, sign;
const unsigned int coef_mask = block_len - 1; const unsigned int coef_mask = block_len - 1;
/* Rockbox: To be able to use rockbox' optimized mdct we need to pre-shift
* the values by >>(nbits-3). */
const int nbits = av_log2(block_len)+1;
const int shift = WMAPRO_FRACT-(nbits-3);
for (; offset < num_coefs; offset++) { for (; offset < num_coefs; offset++) {
code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX); code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX);
if (code > 1) { if (code > 1) {
/** normal code */ /** normal code */
offset += run_table[code]; offset += run_table[code];
sign = !get_bits1(gb); sign = !get_bits1(gb);
ptr[offset & coef_mask] = sign ? -level_table[code] : level_table[code]; /* Rockbox: To be able to use rockbox' optimized mdct we need
ptr[offset & coef_mask] <<= WMAPRO_FRACT; * invert the sign. */
ptr[offset & coef_mask] = sign ? level_table[code] : -level_table[code];
ptr[offset & coef_mask] <<= shift;
} else if (code == 1) { } else if (code == 1) {
/** EOB */ /** EOB */
break; break;
@ -143,8 +150,8 @@ int ff_wma_run_level_decode(GetBitContext* gb,
} }
} }
sign = !get_bits1(gb); sign = !get_bits1(gb);
ptr[offset & coef_mask] = sign ? -level : level; ptr[offset & coef_mask] = sign ? level : -level;
ptr[offset & coef_mask] <<= WMAPRO_FRACT; ptr[offset & coef_mask] <<= shift;
} }
} }
/** NOTE: EOB can be omitted */ /** NOTE: EOB can be omitted */

View file

@ -91,7 +91,7 @@
#include "wmaprodata.h" #include "wmaprodata.h"
#include "wma.h" #include "wma.h"
#include "wmaprodec.h" #include "wmaprodec.h"
#include "wmapro_mdct.h" //#include "wmapro_mdct.h"
#include "mdct_tables.h" #include "mdct_tables.h"
#include "quant.h" #include "quant.h"
#include "wmapro_math.h" #include "wmapro_math.h"
@ -878,11 +878,18 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c)
vals[3] = (symbol_to_vec4[idx] ) & 0xF; vals[3] = (symbol_to_vec4[idx] ) & 0xF;
} }
/* Rockbox: To be able to use rockbox' optimized mdct we need to
* pre-shift the values by >>(nbits-3). */
const int nbits = av_log2(s->subframe_len)+1;
const int shift = WMAPRO_FRACT-(nbits-3);
/** decode sign */ /** decode sign */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (vals[i]) { if (vals[i]) {
int sign = get_bits1(&s->gb) - 1; int sign = get_bits1(&s->gb) - 1;
ci->coeffs[cur_coeff] = (sign == -1)? -vals[i]<<WMAPRO_FRACT : vals[i]<<WMAPRO_FRACT; /* Rockbox: To be able to use rockbox' optimized mdct we need
* invert the sign. */
ci->coeffs[cur_coeff] = (sign == -1)? vals[i]<<shift : -vals[i]<<shift;
num_zeros = 0; num_zeros = 0;
} else { } else {
ci->coeffs[cur_coeff] = 0; ci->coeffs[cur_coeff] = 0;
@ -1266,6 +1273,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
get_bits_count(&s->gb) - s->subframe_offset); get_bits_count(&s->gb) - s->subframe_offset);
if (transmit_coeffs) { if (transmit_coeffs) {
int nbits = av_log2(subframe_len)+1;
/** reconstruct the per channel data */ /** reconstruct the per channel data */
inverse_channel_transform(s); inverse_channel_transform(s);
for (i = 0; i < s->channels_for_cur_subframe; i++) { for (i = 0; i < s->channels_for_cur_subframe; i++) {
@ -1299,8 +1307,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
} }
/** apply imdct (ff_imdct_half == DCTIV with reverse) */ /** apply imdct (ff_imdct_half == DCTIV with reverse) */
imdct_half(av_log2(subframe_len)+1, ff_imdct_half(nbits,s->channel[c].coeffs, s->tmp);
s->channel[c].coeffs, s->tmp);
} }
} }