[PATCH] Fixed-point WMA decoder adapted from ROckbox
Hello: Attached is a patch for MPlayer which adds a fixed-point WMA decoder that I adapted from Rockbox. Rockbox's fixed-point WMA decoder was in turn adapted from the one in libavcodec, so it would seem that the best approach is to port the modifications from the Rockbox WMA decoder back to libavcodec. But I didn't want to break libavcodec. So instead, I turned the libwma library from ROckbox into a stand-alone library which can run outside of Rockbox, then added it to the MPlayer build system and wrote an audio decoder plug-in for libwma (based on ad_ffmpeg.c). The attached patch also includes some changes to etc/codecs.conf. Once you apply the patch, you'll need to pass "--enable-libwma" to configure to enable this codec. However, there's a problem: the codec's output isn't always correct. I've found that the codec works fine for relatively high bit-rate WMA files stored locally or streamed over HTTP. But I had problems with a couple of streams using the MMS protocol. For instance, if you play this stream: mms://crista.streamguys.com/kcms you'll hear frequent high-pitch noises. This doesn't happen with Windows Media Player. I don't know nearly enough about codecs, or fixed-point math for that matter, to debug this; I only knew enough to get the WMA decoder from ROckbox to work in MPlayer. So I would really appreciate it if someone would spend some time debugging this, or at least give me some hints on how to go about it myself. Thanks, Matt
On Tue, 29 Apr 2008 10:48:25 -0500 Matt Campbell <mattcampbell@pobox.com> wrote:
Hello:
Attached is a patch for MPlayer which adds a fixed-point WMA decoder that I adapted from Rockbox. Rockbox's fixed-point WMA decoder was in turn adapted from the one in libavcodec, so it would seem that the best approach is to port the modifications from the Rockbox WMA decoder back to libavcodec. But I didn't want to break libavcodec. So instead, I turned the libwma library from ROckbox into a stand-alone library which can run outside of Rockbox, then added it to the MPlayer build system and wrote an audio decoder plug-in for libwma (based on ad_ffmpeg.c). The attached patch also includes some changes to etc/codecs.conf.
this would be better off in libavcodec. if you can, submit a diff of svn libavcodec to ffmpeg-devel. at least it will be a starting point. i'll add it to the ffmpeg small projects wiki. as for your patch, it seems to remove the check for libdca for some reason. -echocheck "libdca support" -if test "$_libdca" = auto ; then - _libdca=no - cat > $TMPC << EOF -#include <inttypes.h> -#include <dts.h> -int main(void) { dts_init (0); return 0; } -EOF - cc_check -ldts $_ld_lm && _libdca=yes -fi -if test "$_libdca" = yes ; then - _def_libdca='#define USE_LIBDCA 1' - _ld_extra="$_ld_extra -ldts" - _codecmodules="libdca $_codecmodules" -compn
I'm sorry, I didn't mean to remove the libdca check in configure; I was merely using the libdca check as a template for what I needed to add for libwma. Here's a corrected patch. As for patching libavcodec, the problem is that libwma includes modified versions of the FFT and MDCT functions from libavcodec, since the WMA decoder requires the MDCT function. So if I patch libavcodec, then I'll also have to fix all of the other codecs in libavcodec that use MDCT and/or FFT, to use fixed-point numbers for these functions instead of floats. And I'm not sure what else was changed in libwma relative to libavcodec; as I said before, I took libwma from Rockbox. Matt compn wrote:
On Tue, 29 Apr 2008 10:48:25 -0500 Matt Campbell <mattcampbell@pobox.com> wrote:
Hello:
Attached is a patch for MPlayer which adds a fixed-point WMA decoder that I adapted from Rockbox. Rockbox's fixed-point WMA decoder was in turn adapted from the one in libavcodec, so it would seem that the best approach is to port the modifications from the Rockbox WMA decoder back to libavcodec. But I didn't want to break libavcodec. So instead, I turned the libwma library from ROckbox into a stand-alone library which can run outside of Rockbox, then added it to the MPlayer build system and wrote an audio decoder plug-in for libwma (based on ad_ffmpeg.c). The attached patch also includes some changes to etc/codecs.conf.
this would be better off in libavcodec. if you can, submit a diff of svn libavcodec to ffmpeg-devel. at least it will be a starting point. i'll add it to the ffmpeg small projects wiki.
as for your patch, it seems to remove the check for libdca for some reason.
-echocheck "libdca support" -if test "$_libdca" = auto ; then - _libdca=no - cat > $TMPC << EOF -#include <inttypes.h> -#include <dts.h> -int main(void) { dts_init (0); return 0; } -EOF - cc_check -ldts $_ld_lm && _libdca=yes -fi -if test "$_libdca" = yes ; then - _def_libdca='#define USE_LIBDCA 1' - _ld_extra="$_ld_extra -ldts" - _codecmodules="libdca $_codecmodules"
-compn _______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
On Tue, 29 Apr 2008 11:49:09 -0500 Matt Campbell <mattcampbell@pobox.com> wrote:
I'm sorry, I didn't mean to remove the libdca check in configure; I was merely using the libdca check as a template for what I needed to add for libwma. Here's a corrected patch.
As for patching libavcodec, the problem is that libwma includes modified versions of the FFT and MDCT functions from libavcodec, since the WMA decoder requires the MDCT function. So if I patch libavcodec, then I'll also have to fix all of the other codecs in libavcodec that use MDCT and/or FFT, to use fixed-point numbers for these functions instead of floats. And I'm not sure what else was changed in libwma relative to libavcodec; as I said before, I took libwma from Rockbox.
well you wont have to fix all of the other codecs, the ffmpeg team will. but i see now what you mean, you swiped it from rockbox, and have nothing to do with rockbox or ffmpeg. sorry for the confusion -compn
Matt
compn wrote:
On Tue, 29 Apr 2008 10:48:25 -0500 Matt Campbell <mattcampbell@pobox.com> wrote:
Hello:
Attached is a patch for MPlayer which adds a fixed-point WMA decoder that I adapted from Rockbox. Rockbox's fixed-point WMA decoder was in turn adapted from the one in libavcodec, so it would seem that the best approach is to port the modifications from the Rockbox WMA decoder back to libavcodec. But I didn't want to break libavcodec. So instead, I turned the libwma library from ROckbox into a stand-alone library which can run outside of Rockbox, then added it to the MPlayer build system and wrote an audio decoder plug-in for libwma (based on ad_ffmpeg.c). The attached patch also includes some changes to etc/codecs.conf.
this would be better off in libavcodec. if you can, submit a diff of svn libavcodec to ffmpeg-devel. at least it will be a starting point. i'll add it to the ffmpeg small projects wiki.
as for your patch, it seems to remove the check for libdca for some reason.
-echocheck "libdca support" -if test "$_libdca" = auto ; then - _libdca=no - cat > $TMPC << EOF -#include <inttypes.h> -#include <dts.h> -int main(void) { dts_init (0); return 0; } -EOF - cc_check -ldts $_ld_lm && _libdca=yes -fi -if test "$_libdca" = yes ; then - _def_libdca='#define USE_LIBDCA 1' - _ld_extra="$_ld_extra -ldts" - _codecmodules="libdca $_codecmodules"
-compn _______________________________________________ MPlayer-dev-eng mailing list MPlayer-dev-eng@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
On Tue, Apr 29, 2008 at 9:14 PM, compn <tempn@twmi.rr.com> wrote:
On Tue, 29 Apr 2008 11:49:09 -0500
Matt Campbell <mattcampbell@pobox.com> wrote:
I'm sorry, I didn't mean to remove the libdca check in configure; I was merely using the libdca check as a template for what I needed to add for libwma. Here's a corrected patch.
As for patching libavcodec, the problem is that libwma includes modified versions of the FFT and MDCT functions from libavcodec, since the WMA decoder requires the MDCT function. So if I patch libavcodec, then I'll also have to fix all of the other codecs in libavcodec that use MDCT and/or FFT, to use fixed-point numbers for these functions instead of floats. And I'm not sure what else was changed in libwma relative to libavcodec; as I said before, I took libwma from Rockbox.
well you wont have to fix all of the other codecs, the ffmpeg team will. but i see now what you mean, you swiped it from rockbox, and have nothing to do with rockbox or ffmpeg.
sorry for the confusion
-compn
Matt
compn wrote:
On Tue, 29 Apr 2008 10:48:25 -0500 Matt Campbell <mattcampbell@pobox.com> wrote:
Hello:
Attached is a patch for MPlayer which adds a fixed-point WMA decoder that I adapted from Rockbox. Rockbox's fixed-point WMA decoder was in turn adapted from the one in libavcodec, so it would seem that the best approach is to port the modifications from the Rockbox WMA decoder back to libavcodec. But I didn't want to break libavcodec. So instead, I turned the libwma library from ROckbox into a stand-alone library which can run outside of Rockbox, then added it to the MPlayer build system and wrote an audio decoder plug-in for libwma (based on ad_ffmpeg.c). The attached patch also includes some changes to etc/codecs.conf.
this would be better off in libavcodec. if you can, submit a diff of svn libavcodec to ffmpeg-devel. at least it will be a starting point. i'll add it to the ffmpeg small projects wiki.
as for your patch, it seems to remove the check for libdca for some reason.
-echocheck "libdca support" -if test "$_libdca" = auto ; then - _libdca=no - cat > $TMPC << EOF -#include <inttypes.h> -#include <dts.h> -int main(void) { dts_init (0); return 0; } -EOF - cc_check -ldts $_ld_lm && _libdca=yes -fi -if test "$_libdca" = yes ; then - _def_libdca='#define USE_LIBDCA 1' - _ld_extra="$_ld_extra -ldts" - _codecmodules="libdca $_codecmodules"
It also moves some stuff from codecs.conf around. We actually accept only patches against current svn, with all the cosmetic and build changes, patch against rc2 may need quite some addition work to be applied. I have few more questions: 1. Why this library is better than the one in lavc. Can it decode wma3/pro (lavc can't). Is it faster (on x86 or only on cpu without fpu) ? Ignoring that it doesn't work correctly in cases where lavc does. 2. I don't like it been included as subdirectory. First, it have a lot of stuff I've seen in lavc , there are a lot of possibilities for conflict and/or miscompilation when both are available. I guess that probably a lot of the tables are also not changed. 3. I'm sure diego won't like the copyright headers. I'm ok with supporting this as external library, but I think it is overkill to add it into mplayer main tree. I may be wrong but I think there was integer only version of wma proposed by the original author in lavc list, or at least there was another attempt to not use floats. I'm not sure why it haven't made it.
On Tue, Apr 29, 2008 at 10:48:25AM -0500, Matt Campbell wrote:
Attached is a patch for MPlayer which adds a fixed-point WMA decoder that I adapted from Rockbox. Rockbox's fixed-point WMA decoder was in turn adapted from the one in libavcodec, so it would seem that the best approach is to port the modifications from the Rockbox WMA decoder back to libavcodec.
Exactly.
But I didn't want to break libavcodec. So instead, I turned the libwma library from ROckbox into a stand-alone library which can run outside of Rockbox, then added it to the MPlayer build system and wrote an audio decoder plug-in for libwma (based on ad_ffmpeg.c).
Sorry, but this is unacceptable. The fixed-point WMA decoder should be ported back into libavcodec instead. Diego
participants (4)
-
compn -
Diego Biurrun -
Ivan Kalvachev -
Matt Campbell