Some little changes (not effecting sound quality).
Is it easy to install a CVS system (I've never worked with such a system)?
timestatus.c
~~~~~~~~~~~~
#if defined LIBSNDFILE || defined LAMESNDFILE
/* these functions are used in get_audio.c */
void decoder_progress ( const lame_global_flags* gfp )
{
static int last_total = -1;
static int last_kbps = -1;
static int last_frame = -1;
if ( (gfp -> frameNum & 255 ) == 1 ) {
fprintf ( stderr, "\rFrame#%6lu/%-6lu %3u kbps ", gfp -> frameNum, gfp
-> totalframes, gfp -> brate );
last_frame = -1;
}
else if ( last_kbps != gfp -> brate ) {
fprintf ( stderr, "\rFrame#%6lu/%-6lu %3u", gfp -> frameNum, gfp ->
totalframes, gfp -> brate );
last_frame = -1;
}
else if ( last_total != gfp -> totalframes ) {
fprintf ( stderr, "\rFrame#%6lu/%-6lu", gfp -> frameNum, gfp -> totalframes );
last_frame = -1;
}
else {
if ( last_frame > 0 && last_frame/10 == gfp -> frameNum/10 )
fprintf ( stderr, "\b%lu", gfp -> frameNum % 10 );
else if ( last_frame > 0 && last_frame/100 == gfp -> frameNum/100 )
fprintf ( stderr, "\b\b%02lu", gfp -> frameNum % 100 );
else
fprintf ( stderr, "\rFrame#%6lu", gfp -> frameNum ),
last_frame = gfp -> frameNum;
}
last_total = gfp -> totalframes;
last_kbps = gfp -> brate;
}
void decoder_progress_finish ( const lame_global_flags* gfp )
{
fprintf ( stderr, "\n" );
}
#endif
timestatus.h
~~~~~~~~~~~~
#ifndef TIMESTATUS_H_INCLUDED
#define TIMESTATUS_H_INCLUDED
void timestatus ( int SampleRate, long FrameNum, long TotalFrames, int
FrameSize );
void timestatus_finish ( void );
#if defined LIBSNDFILE || defined LAMESNDFILE
void decoder_progress ( const lame_global_flags* gfp );
void decoder_progress_finish ( const lame_global_flags* gfp );
#endif
#endif
get_audio.c
~~~~~~~~~~~
#include <limits.h>
/*
* The simple lame decoder
*
* After calling lame_init(), lame_init_params() and lame_init_infile(), call
* this routine to read the input MP3 file and output .wav data to the
* specified file pointer
*
* lame_decoder will ignore the first 528 samples, since these samples
* represent the mpglib delay (and are all 0). skip = number of additional
* samples to skip, to (for example) compensate for the encoder delay
*/
int lame_decoder ( lame_global_flags* gfp, FILE* outf, int skip )
{
short int Buffer [2] [1152];
int iread;
int i;
long wavsize = LONG_MAX;
MSGF ( "\rinput:\t%s%s(%g kHz, %i channel%s",
strcmp (gfp -> inPath, "-") ? gfp -> inPath : "<stdin>",
strlen (gfp -> inPath) < 32 ? " " : "\n\t",
gfp -> in_samplerate / 1.e3,
gfp -> num_channels,
gfp -> num_channels != 1 ? "s" : "" );
if ( gfp -> input_format == sf_mp3 ) { /* mp3 decoder has a 528 sample delay, plus
user supplied "skip" */
skip += 528;
MSGF (", MPEG%i Layer III)\n", 2 - gfp -> version );
} else { /* other formats have no delay */
skip = 0;
MSGF (")\n" );
}
MSGF ( "\routput:\t%s (WAV format)\n",
strcmp (gfp -> outPath, "-") ? gfp -> outPath : "<stdout>" );
if ( skip > 0 )
MSGF ( "\r\tskipping initial %i samples (encoder+decoder delay)\n", skip );
WriteWav ( outf, wavsize, gfp -> in_samplerate, gfp -> num_channels );
wavsize = -skip;
do { /* read in 'iread' samples */
iread = lame_readframe ( gfp, Buffer );
wavsize += iread;
if ( ! gfp -> silent )
decoder_progress ( gfp );
skip -= ( i = iread < skip ? iread : skip );
for ( ; i < iread; i++ ) {
Write16BitsLowHigh ( outf, Buffer [0] [i] );
if ( gfp -> num_channels == 2 )
Write16BitsLowHigh ( outf, Buffer [1] [i] );
}
} while ( iread );
if ( wavsize < 0 )
wavsize = 0;
wavsize *= 2 * gfp -> num_channels;
decoder_progress_finish ( gfp );
/* if outf is seekable, rewind and adjust length */
if ( ! fseek ( outf, 0, SEEK_SET ) )
WriteWav ( outf, wavsize, gfp -> in_samplerate, gfp -> num_channels );
fclose ( outf );
return 0;
}
#endif /* LAMESNDFILE or LIBSNDFILE */
--
Mit freundlichen Gr��en
Frank Klemm
eMail | [EMAIL PROTECTED] home: [EMAIL PROTECTED]
phone | +49 (3641) 64-2721 home: +49 (3641) 390545
sMail | R.-Breitscheid-Str. 43, 07747 Jena, Germany
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )