dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: libwma generates lower output volume than libavcodec

libwma generates lower output volume than libavcodec

From: James Hag <>
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.


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

- fixed32 mult3 = (fixed32)(fixdiv64(pow_table[total_gain+20],
+ fixed32 mult3 = (fixed32)(fixdiv64(pow_table[total_gain+32],
                 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,
Received on 2011-04-06

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy