Posted with wrong from address.. here it is again.
Hi im new to the list. Im trying to decode some data using the low level api, I want to decode it a frame at a time , but currently im just trying to do something simple, give it 8k of data and have it call decode without hanging. in is a pointer to the data, I just put 8192 in for the hell of it. The 8k of data is valid mpeg data and I can decode it fine with my own fpu based mp3 code. I tried this
mad_stream_init(&stream); mad_frame_init(&frame); mad_synth_init(&synth);
mad_stream_buffer(&stream, in, 8192);
if (mad_frame_decode(&frame, &stream) == -1) { return FALSE; }
It decodes the header correctly, then when decoding the data in the (stereo mp3) file, it goes into an infinite loop inside mad_frame_decode. The code it hangs in is in III_huffdecode (not immediately).. The while loop is the following one.
while (!pair->final) { cachesz -= clumpsz; clumpsz = pair->ptr.bits; pair = &table[pair->ptr.offset + MASK(bitcache, cachesz, clumpsz)]; } Its called from the III_decode function, and it is gr = 1, ngr = 2 and ch = 1 nch = 2. So it performs in this manner. gr = 0 ch = 0 : succeeds gr = 0 ch = 1 : succeeds gr = 1 ch = 0 : succeeds gr = 1 ch = 1 : hang
Maybe I didnt set the project up properly, all I did was create a new project in devstudio, add all the mad files, then defined FPM_DEFAULT,OPT_SPEED in my project. Is there anything else I should be doing?
thanks Brett
Brett Paterson wrote:
It decodes the header correctly, then when decoding the data in the (stereo mp3) file, it goes into an infinite loop inside mad_frame_decode.
Maybe I didnt set the project up properly, all I did was create a new project in devstudio, add all the mad files, then defined FPM_DEFAULT,OPT_SPEED in my project. Is there anything else I should be doing?
The problem is in huffman.c. Currently, this uses a GNU extension to initialize a union member other than the first. I'm surprised you were able to compile this file without making changes to it.
I'll be releasing a new version of MAD soon which makes the code more portable to non-GCC compilers. It will also include MSVC++ project files.
Until then, you'll need to find a workaround for the union initializations in huffman.c.
Cheers, -rob
<Slaps head>.. oh yeah I forgot about that! I did chop that out to make it compile but I guess I busted it in the process.
I did this.. //# define PTR(offs, bits) { ptr: { 0, bits, offs } } # define PTR(offs, bits) { { 0, bits, offs } }
which I guess is obviously wrong .. I havent seen that extension before, would you have an alternative macro that could do whatever it is supposed to do?
Brett
-----Original Message----- From: mad-dev-admin@lists.mars.org
[mailto:mad-dev-admin@lists.mars.org]
On Behalf Of Rob Leslie Sent: Monday, 15 October 2001 7:31 PM To: mad-dev@lists.mars.org Subject: Re: [mad-dev] hang in huff code
Brett Paterson wrote:
It decodes the header correctly, then when decoding the data in the (stereo mp3) file, it goes into an infinite loop inside mad_frame_decode.
Maybe I didnt set the project up properly, all I did was create a
new
project in devstudio, add all the mad files, then defined FPM_DEFAULT,OPT_SPEED in my project. Is there anything else I should be doing?
The problem is in huffman.c. Currently, this uses a GNU extension to initialize a union member other than the first. I'm surprised you were able to compile this file without making changes to it.
I'll be releasing a new version of MAD soon which makes the code more portable to non-GCC compilers. It will also include MSVC++ project files.
Until then, you'll need to find a workaround for the union
initializations
in huffman.c.
Cheers, -rob
Ok I realized it was specifying the struct in the union, which isnt ansi .. I fixed it via these changes.. At the top of huffquad and huffpair union put
unsigned short data;
then the macros become
# define V(v, w, x, y, hlen) { (unsigned short)((y << 7) | (x << 6) | (w << 5) | (v << 4) | (hlen << 1) | 1 ) } # define PTR(offs, bits) { (unsigned short)((offs << 4) | (bits << 1)) }
and
#define V(x, y, hlen) { (unsigned short)((y << 8) | (x << 4) | (hlen << 1) | 1 ) } #define PTR(offs, bits) { (unsigned short)((offs << 4) | (bits << 1)) }
simple enuff cheers Brett
-----Original Message----- From: mad-dev-admin@lists.mars.org
[mailto:mad-dev-admin@lists.mars.org]
On Behalf Of Brett Paterson Sent: Monday, 15 October 2001 7:43 PM To: mad-dev@lists.mars.org Subject: RE: [mad-dev] hang in huff code
<Slaps head>.. oh yeah I forgot about that! I did chop that out to
make
it compile but I guess I busted it in the process.
I did this.. //# define PTR(offs, bits) { ptr: { 0, bits, offs } } # define PTR(offs, bits) { { 0, bits, offs } }
which I guess is obviously wrong .. I havent seen that extension
before,
would you have an alternative macro that could do whatever it is supposed to do?
Brett
-----Original Message----- From: mad-dev-admin@lists.mars.org
[mailto:mad-dev-admin@lists.mars.org]
On Behalf Of Rob Leslie Sent: Monday, 15 October 2001 7:31 PM To: mad-dev@lists.mars.org Subject: Re: [mad-dev] hang in huff code
Brett Paterson wrote:
It decodes the header correctly, then when decoding the data in
the
(stereo mp3) file, it goes into an infinite loop inside mad_frame_decode.
Maybe I didnt set the project up properly, all I did was create a
new
project in devstudio, add all the mad files, then defined FPM_DEFAULT,OPT_SPEED in my project. Is there anything else I should be doing?
The problem is in huffman.c. Currently, this uses a GNU extension to initialize a union member other than the first. I'm surprised you
were
able to compile this file without making changes to it.
I'll be releasing a new version of MAD soon which makes the code
more
portable to non-GCC compilers. It will also include MSVC++ project files.
Until then, you'll need to find a workaround for the union
initializations
in huffman.c.
Cheers, -rob
Hi,
I'll be releasing a new version of MAD soon which makes the code more portable to non-GCC compilers. It will also include MSVC++ project files.
Until then, you'll need to find a workaround for the union
initializations
in huffman.c.
I've successfully compiled libmad on win32 using mingw. Available at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/winlame/winlame/source/librar... The libmad.lib is in ./lib, the mad.h is in ./include
bye Michael
Hi Michael,
I've successfully compiled libmad on win32 using mingw. Available at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/winlame/winlame/source/librar... The libmad.lib is in ./lib, the mad.h is in ./include
Where is the source?