From: Tamas M. <tm...@gm...> - 2013-02-08 11:22:31
|
> > The thing is, I read in the whole file (no ID3 tag), hip_decode_headers > > returns 0, but there is no more data in the file, so I essentially get > > nothing out of it. > > Can you provide an example file? I uploaded one here: http://tmarki.com/ZSS_Fi_MasterLink.mp3 It was encoded by Lame CLI from this source: http://noproblo.dayjo.org/ZeldaSounds/ZSS/ZSS_Fi_MasterLink.wav If I transcode it with the Lame CLI everything is fine, so I must be doing something wrong in my code... I'm using a 8kB buffer for the MP3 data (because lame_encode_flush recommends buffers size > 7200 bytes). My encoding loop goes like this: int readloc = fread(glob_mp3_buffer, sizeof(unsigned char), MP3_SIZE, glob_mp3_in); if (readloc) { int read2 = 0; read2 = hip_decode_headers(glob_hipt, glob_mp3_buffer, MP3_SIZE, glob_pcm_buffer1, glob_pcm_buffer2, &glob_mp3data); // snipped code handling mp3 header if (read2) { // this is 0 on the first pass for very small files int coded = lame_encode_buffer(glob_lame, glob_pcm_buffer1, glob_pcm_buffer2, read2, glob_mp3_outbuffer, PCM_SIZE); if (coded > 0) { glob_write += fwrite (glob_mp3_outbuffer, 1, coded, glob_mp3_out); } } } The finishing/flushing part: int coded = lame_encode_flush(glob_lame,glob_mp3_outbuffer, MP3_SIZE); if (coded > 0) { glob_write += fwrite (glob_mp3_outbuffer, 1, coded, glob_mp3_out); } hip_decode_exit(glob_hipt); lame_close(glob_lame); It works fine if the file is larger than MP3_SIZE (=8k). Thanks -- Tamas Marki |