[mad-dev] Stream Decode

Alexey V Paramonov plaza at profsolutions.ru
Tue May 20 10:29:20 PDT 2008


Hi!

I have the following question - is it possible to decode a stream using MAD?
For example: I have shoutcast stream and I read it in small portions 
(say, 40960 bytes), decode it and encode back to mp3 using LAME
(chaning bitrate, samplerate, etc...).

The problem is that I have to call mad_stream_buffer with each piece of 
stream data, decode/encode it and then if I listen the resulting mp3 
file - I notice "noise" between theese small decoded pieces.
Seems like it happen not only with VBR files.

Pseudo-code:

while ( bytes = read(file_id, buff, SHOUT_BUFFER_LENGTH ) )  {

    mad_stream_buffer(&stream, buff, bytes );

    while(1){
    mad_frame_decode(&frame,&stream)
    ....
    int ret = lame_encode_buffer( lameGlobalFlags,
                              left,
                              right,
                              nsamples,
                              mp3Buf,
                              mp3Size );
    // Play resulting mp3 data

   }

}

Is it possible to decode a stream without theese "edge effects" ? May be 
I should not re-initialize MAD buffer after each read in some way?
Please help.




More information about the mad-dev mailing list