Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: libwma generates lower output volume than libavcodec

libwma generates lower output volume than libavcodec

From: James Hag <james_recmp_at_yahoo.co.uk>
Date: Wed, 6 Apr 2011 16:06:20 +0100 (BST)

Hello Developers,

Decoding WMA streams (e.g. Codec: wmav2, Bitrate: 128kbps, Sample rate: 44.1KHz, Channels: 2) with libwma on mplayer causes the output volume to be lower than with libavcodec, but libavcodec has a high cpu usage on the ARM processor I'm using (it has no hardware support for floating-point arithmetic).

The issue with libwma appears to be down to the multiplier (mult) used when computing the MDCT coefficients in function 'wma_decode_block' in libwma/wmadeci.c. The multiplier always gets rounded off to 0. Whereas, in function 'wma_decode_block' in libavcodec/wmadec.c, the multiplier is a 'float' and has a non-zero value assigned to it.

One way to fix this is to increase the offset for the total_gain value to be used in the 'pow' lookup table by 12.

I.e.

diff --git a/libwma/wmadeci.c b/libwma/wmadeci.c
index 94fd768..de2e1c8 100644
--- a/libwma/wmadeci.c
+++ b/libwma/wmadeci.c
@@ -1429,7 +1429,7 @@ static int wma_decode_block(WMADecodeContextPrivate *s)
             {
                 /*Noise coding not used, simply convert from exp to fixed
representation*/

- fixed32 mult3 = (fixed32)(fixdiv64(pow_table[total_gain+20],
+ fixed32 mult3 = (fixed32)(fixdiv64(pow_table[total_gain+32],
                         Fixed32To64(s->max_exponent[ch])));
                 mult3 = fixmul32(mult3, mdct_norm);

This causes the decoded wma streams to end up with the same volume as that of libavcodec.

Are there any potential problems with making this change? For example, would if be possible for a lookup in the pow_table to be out of bounds if the offset is increased?

There are three instances of the +20 offset used when looking up values in the pow_table in function 'wma_decode_block'. Would the offset need changing for all these instances?

Many thanks,
James
Received on 2011-04-06


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa