+++ /dev/null
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/brhist.c cinelerra-1.1.5/plugins/lame/frontend/brhist.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/brhist.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/brhist.c Sun Oct 27 15:02:05 2002
-@@ -53,12 +53,13 @@
- #endif
-
-
--#if defined(HAVE_TERMCAP)
--#if defined(HAVE_TERMCAP_H)
--# include <termcap.h>
--#elif defined(HAVE_NCURSES_TERMCAP_H)
-+#if defined(HAVE_NCURSES_TERMCAP_H)
- # include <ncurses/termcap.h>
--#endif
-+#elif defined(HAVE_TERMCAP_H)
-+# include <termcap.h>
-+#elif defined(HAVE_TERMCAP)
-+#include <curses.h>
-+#include <term.h>
- #endif
-
- #include "brhist.h"
-@@ -310,12 +311,15 @@
- int i;
- int br_hist [BRHIST_WIDTH];
- int st_mode [4];
-+ int bl_type [6];
- int st_frames = 0;
- int br_frames = 0;
- double sum = 0.;
-+ extern int silent;
-
- lame_stereo_mode_hist ( gf, st_mode );
- lame_bitrate_hist ( gf, br_hist );
-+ lame_block_type_hist ( gf, bl_type );
-
- for (i = 0; i < BRHIST_WIDTH; i++) {
- br_frames += br_hist[i];
-@@ -340,6 +344,24 @@
- fprintf ( Console_IO.Console_fp, " MS: %d (%#5.4g%%)", st_mode[MS], 100. * st_mode[MS] / st_frames );
- }
- fprintf ( Console_IO.Console_fp, "\n" );
-+
-+ if (bl_type[5] > 0 && silent <= -5 && silent > -10) {
-+ fprintf ( Console_IO.Console_fp, "block type");
-+ fprintf ( Console_IO.Console_fp, " long: %#4.3f", 100. * bl_type[0] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " start: %#4.3f", 100. * bl_type[1] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " short: %#4.3f", 100. * bl_type[2] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " stop: %#4.3f", 100. * bl_type[3] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " mixed: %#4.3f", 100. * bl_type[4] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " (%%)\n" );
-+ }
-+ else if (bl_type[5] > 0 && silent <= -10) {
-+ fprintf ( Console_IO.Console_fp, "block types granules percent\n" );
-+ fprintf ( Console_IO.Console_fp, " long: % 10d % 8.3f%%\n", bl_type[0], 100. * bl_type[0] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " start: % 10d % 8.3f%%\n", bl_type[1], 100. * bl_type[1] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " short: % 10d % 8.3f%%\n", bl_type[2], 100. * bl_type[2] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " stop: % 10d % 8.3f%%\n", bl_type[3], 100. * bl_type[3] / bl_type[5] );
-+ fprintf ( Console_IO.Console_fp, " mixed: % 10d % 8.3f%%\n", bl_type[4], 100. * bl_type[4] / bl_type[5] );
-+ }
- fflush ( Console_IO.Console_fp );
- }
-
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/console.c cinelerra-1.1.5/plugins/lame/frontend/console.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/console.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/console.c Tue Sep 3 13:31:39 2002
-@@ -19,8 +19,14 @@
-
- #include "console.h"
-
--#if defined(TERMCAP_AVAILABLE)
-+#if defined(HAVE_TERMCAP)
-+#include <curses.h>
-+#include <term.h>
-+#if defined(HAVE_TERMCAP_H)
- # include <termcap.h>
-+#elif defined(HAVE_NCURSES_TERMCAP_H)
-+# include <ncurses/termcap.h>
-+#endif
- #endif
-
- #ifdef WITH_DMALLOC
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/get_audio.c cinelerra-1.1.5/plugins/lame/frontend/get_audio.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/get_audio.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/get_audio.c Thu Oct 17 14:38:32 2002
-@@ -49,12 +49,18 @@
- # endif
- #endif
-
-+
- #define MAX_U_32_NUM 0xFFFFFFFF
-
-
- #include <math.h>
- #include <sys/stat.h>
-
-+#ifdef __sun__
-+/* woraround for SunOS 4.x, it has SEEK_* defined here */
-+#include <unistd.h>
-+#endif
-+
- #include "lame.h"
- #include "main.h"
- #include "get_audio.h"
-@@ -78,7 +84,7 @@
- int lame_decode_initfile(const char *fullname,
- mp3data_struct * const mp3data);
- #else
--int lame_decode_initfile(FILE * const fd, mp3data_struct * const mp3data);
-+int lame_decode_initfile(FILE * fd, mp3data_struct * mp3data);
- #endif
-
- /* read mp3 file until mpglib returns one frame of PCM data */
-@@ -98,10 +104,10 @@
-
- static int read_samples_pcm(FILE * musicin, int sample_buffer[2304],
- int frame_size, int samples_to_read);
--static int read_samples_mp3(lame_global_flags * gfp, FILE * musicin,
-- short int mpg123pcm[2][1152], int num_chan);
--static int read_samples_ogg(lame_global_flags * gfp, FILE * musicin,
-+static int read_samples_mp3(lame_global_flags * const gfp, FILE * const musicin,
- short int mpg123pcm[2][1152], int num_chan);
-+static int read_samples_ogg(lame_global_flags * const gfp, FILE * const musicin,
-+ short int mpg123pcm[2][1152], const int num_chan);
- void CloseSndFile(sound_file_format input, FILE * musicin);
- FILE *OpenSndFile(lame_global_flags * gfp, char *);
-
-@@ -182,7 +188,7 @@
- /* open the input file */
- count_samples_carefully = 0;
- num_samples_read=0;
-- pcmbitwidth = 16;
-+ pcmbitwidth=in_bitwidth;
- musicin = OpenSndFile(gfp, inPath);
- }
-
-@@ -379,10 +385,9 @@
- }
- }
-
-+ /* LAME mp3 and ogg output 16bit - convert to int, if necessary */
- if( input_format == sf_mp1 || input_format == sf_mp2 ||
- input_format == sf_mp3 || input_format == sf_ogg ) {
-- /* LAME mp3 and ogg input routines currently */
-- /* only accept up to 16 bit samples */
- if( buffer != NULL ) {
- for( i = samples_read; --i >= 0; )
- buffer[0][i] = buf_tmp16[0][i] << (8 * sizeof(int) - 16);
-@@ -857,8 +862,10 @@
- for (i = 0; i < samples_read; i++)
- sample_buffer[i] <<= (8 * sizeof(int) - 24);
- break;
-+ case 32:
-+ break;
- default:
-- fprintf(stderr, "Only 8, 16, and 24 bit input files supported \n");
-+ fprintf(stderr, "Only 8, 16, 24 and 32 bit input files supported \n");
- exit(1);
- }
-
-@@ -925,11 +932,15 @@
- *--op = ip[i]<<(b-16) | ip[i+1]<<(b-8);
- GA_URS_IFLOOP( 3 )
- *--op = ip[i]<<(b-24) | ip[i+1]<<(b-16) | ip[i+2]<<(b-8);
-+ GA_URS_IFLOOP( 4 )
-+ *--op = ip[i]<<(b-32) | ip[i+1]<<(b-24) | ip[i+2]<<(b-16) | ip[i+3] << (b-8);
- } else {
- GA_URS_IFLOOP( 2 )
- *--op = ip[i]<<(b-8) | ip[i+1]<<(b-16);
- GA_URS_IFLOOP( 3 )
- *--op = ip[i]<<(b-8) | ip[i+1]<<(b-16) | ip[i+2]<<(b-24);
-+ GA_URS_IFLOOP( 4 )
-+ *--op = ip[i]<<(b-8) | ip[i+1]<<(b-16) | ip[i+2]<<(b-24) | ip[i+3]<<(b-32);
- }
- #undef GA_URS_IFLOOP
- return( samples_read );
-@@ -957,21 +968,18 @@
- int iswav = (input_format == sf_wave);
- int hi_lo_order; /* byte order of input stream */
-
-- if( (24 == pcmbitwidth) || (16 == pcmbitwidth) ) {
-+ if( (32 == pcmbitwidth) || (24 == pcmbitwidth) || (16 == pcmbitwidth) ) {
- /* assume only recognized wav files are */
- /* in little endian byte order */
- hi_lo_order = (!iswav == !swapbytes);
-- if( 16 == pcmbitwidth )
-- samples_read = unpack_read_samples(samples_to_read, 2, hi_lo_order,
-- sample_buffer, musicin );
-- else /* ( 24 == pcmbitwidth ) */
-- samples_read = unpack_read_samples(samples_to_read, 3, hi_lo_order,
-- sample_buffer, musicin );
-+ samples_read = unpack_read_samples(samples_to_read, pcmbitwidth/8,
-+ hi_lo_order,sample_buffer, musicin );
-+
- } else if( 8 == pcmbitwidth ) {
- samples_read = unpack_read_samples( samples_to_read, 1, 0,
- sample_buffer, musicin );
- } else {
-- fprintf(stderr, "Only 8, 16, and 24 bit input files supported \n");
-+ fprintf(stderr, "Only 8, 16, 24 and 32 bit input files supported \n");
- exit(1);
- }
- if (ferror(musicin)) {
-@@ -1501,6 +1509,7 @@
- int ret;
- int len, aid_header;
- short int pcm_l[1152], pcm_r[1152];
-+
-
- memset(mp3data, 0, sizeof(mp3data_struct));
- lame_decode_init();
-@@ -1541,7 +1550,7 @@
- // so mp3data->bitrate will be 0 until we have decoded the first
- // frame. Cannot decode first frame here because we are not
- // yet prepared to handle the output.
-- ret = lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
-+ ret = lame_decode1_headersB(buf, len, pcm_l, pcm_r, mp3data,&enc_delay,&enc_padding);
- if (-1 == ret)
- return -1;
-
-@@ -1550,7 +1559,7 @@
- len = fread(buf, 1, sizeof(buf), fd);
- if (len != sizeof(buf))
- return -1;
-- ret = lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
-+ ret = lame_decode1_headersB(buf, len, pcm_l, pcm_r, mp3data,&enc_delay,&enc_padding);
- if (-1 == ret)
- return -1;
- }
-@@ -1612,12 +1621,18 @@
- if (len == 0) {
- /* we are done reading the file, but check for buffered data */
- ret = lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
-- if (ret<=0) return -1; // done with file
-+ if (ret<=0) {
-+ lame_decode_exit(); // release mp3decoder memory
-+ return -1; // done with file
-+ }
- break;
- }
-
- ret = lame_decode1_headers(buf, len, pcm_l, pcm_r, mp3data);
-- if (ret == -1) return -1;
-+ if (ret == -1) {
-+ lame_decode_exit(); // release mp3decoder memory
-+ return -1;
-+ }
- if (ret >0) break;
- }
- return ret;
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/get_audio.h cinelerra-1.1.5/plugins/lame/frontend/get_audio.h
---- cinelerra-1.1.5/plugins/lame/frontend.orig/get_audio.h Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/get_audio.h Thu Oct 17 14:38:32 2002
-@@ -42,8 +42,8 @@
- FILE *init_outfile ( char *outPath, int decode );
- void init_infile(lame_global_flags *, char *inPath);
- void close_infile(void);
--int get_audio(lame_global_flags *gfp, int buffer[2][1152]);
--int get_audio16(lame_global_flags *gfp, short buffer[2][1152]);
-+int get_audio(lame_global_flags * const gfp, int buffer[2][1152]);
-+int get_audio16(lame_global_flags * const gfp, short buffer[2][1152]);
- int WriteWaveHeader(FILE * const fp, const int pcmbytes,
- const int freq, const int channels, const int bits);
-
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/gtkanal.c cinelerra-1.1.5/plugins/lame/frontend/gtkanal.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/gtkanal.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/gtkanal.c Wed Feb 13 17:29:39 2002
-@@ -43,6 +43,18 @@
- #include <dmalloc.h>
- #endif
-
-+
-+//! Stringify \a x.
-+#define STR(x) #x
-+//! Stringify \a x, perform macro expansion.
-+#define XSTR(x) STR(x)
-+
-+#define MP3X_MAJOR_VERSION 0 /* Major version number */
-+#define MP3X_MINOR_VERSION 82 /* Minor version number */
-+#define MP3X_ALPHA_VERSION 0 /* Set number if this is an alpha version, otherwise zero */
-+#define MP3X_BETA_VERSION 0 /* Set number if this is a beta version, otherwise zero */
-+
-+
- plotting_data *pinfo;
- plotting_data *pplot;
- plotting_data Pinfo[NUMPINFO];
-@@ -85,6 +97,7 @@
- int totis; /* total frames with i_stereo */
- int totshort; /* total granules with short blocks */
- int totmix; /* total granules with mixed blocks */
-+ int totpreflag; /* total granules with preflag */
- int pupdate; /* plot while processing, or only when needed */
- int sfblines; /* plot scalefactor bands in MDCT plot */
- int difference; /* plot original - decoded instead of orig vs. decoded */
-@@ -138,7 +151,7 @@
- for ( ch = 0; ch < channels_out; ch++ ) {
- for ( j = 0; j < framesize-DECDELAY; j++ )
- pinfo->pcmdata2[ch][j] = pinfo->pcmdata2[ch][j+framesize];
-- for ( j = 0; j < framesize; j++ )
-+ for ( j = 0; j < framesize; j++ ) /*rescale from int to short int */
- pinfo->pcmdata2[ch][j+framesize-DECDELAY] = Buffer[ch][j];
- }
-
-@@ -851,6 +864,7 @@
- for (ch = 0 ; ch < 2 ; ch ++) {
- gtkinfo.totshort += (pinfo->mpg123blocktype[gr][ch]==2);
- gtkinfo.totmix += !(pinfo->mixed[gr][ch]==0);
-+ gtkinfo.totpreflag += (pinfo->preflag[gr][ch]==1);
- pinfo->totbits += pinfo->mainbits[gr][ch];
- }
- }
-@@ -1018,6 +1032,29 @@
- }
-
-
-+//! Get the mp3x version string.
-+/*!
-+ \param void
-+ \return a pointer to a string which describes the version of mp3x.
-+*/
-+const char* get_mp3x_version ( void )
-+{
-+#if MP3X_ALPHA_VERSION > 0
-+ static /*@observer@*/ const char *const str =
-+ XSTR(MP3X_MAJOR_VERSION) "." XSTR(MP3X_MINOR_VERSION)
-+ " (alpha " XSTR(MP3X_ALPHA_VERSION) ", " __DATE__ " " __TIME__ ")";
-+#elif MP3X_BETA_VERSION > 0
-+ static /*@observer@*/ const char *const str =
-+ XSTR(MP3X_MAJOR_VERSION) "." XSTR(MP3X_MINOR_VERSION)
-+ " (beta " XSTR(MP3X_BETA_VERSION) ", " __DATE__ ")";
-+#else
-+ static /*@observer@*/ const char *const str =
-+ XSTR(MP3X_MAJOR_VERSION) "." XSTR(MP3X_MINOR_VERSION);
-+#endif
-+
-+ return str;
-+}
-+
-
- static void text_window (GtkWidget *widget, gpointer data)
- {
-@@ -1162,6 +1199,8 @@
- gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL,text,-1);
- sprintf(text,"mixed block granules: %i \n",gtkinfo.totmix);
- gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL,text,-1);
-+ sprintf(text,"preflag granules: %i \n",gtkinfo.totpreflag);
-+ gtk_text_insert(GTK_TEXT(box),NULL,NULL,NULL,text,-1);
- break;
- }
-
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/lametime.c cinelerra-1.1.5/plugins/lame/frontend/lametime.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/lametime.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/lametime.c Mon May 27 13:13:37 2002
-@@ -58,6 +58,12 @@
- #else
- t = clock ();
- #endif
-+
-+ /*
-+fprintf(stderr,"clock_t t = %lli \n\n",(int64_t) t);
-+fprintf(stderr,"output: %f \n\n",t/(double)CLOCKS_PER_SEC);
-+ */
-+
- return t / (double) CLOCKS_PER_SEC;
- }
-
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/main.c cinelerra-1.1.5/plugins/lame/frontend/main.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/main.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/main.c Tue Oct 15 11:33:42 2002
-@@ -48,6 +48,10 @@
- # include <fcntl.h>
- #endif
-
-+#if defined(_WIN32)
-+# include <windows.h>
-+#endif
-+
-
- /*
- main.c is example code for how to use libmp3lame.a. To use this library,
-@@ -62,6 +66,7 @@
- #include "get_audio.h"
- #include "portableio.h"
- #include "timestatus.h"
-+#include "VbrTag.h"
-
- /* PLL 14/04/2000 */
- #if macintosh
-@@ -174,7 +179,7 @@
-
-
-
-- fprintf(stderr, "\rinput: %s%s(%g kHz, %i channel%s, ",
-+ if (silent < 10) fprintf(stderr, "\rinput: %s%s(%g kHz, %i channel%s, ",
- strcmp(inPath, "-") ? inPath : "<stdin>",
- strlen(inPath) > 26 ? "\n\t" : " ",
- lame_get_in_samplerate( gfp ) / 1.e3,
-@@ -182,44 +187,51 @@
-
- switch (input_format) {
- case sf_mp3:
-- skip += 528 + 1; /* mp3 decoder has a 528 sample delay, plus user supplied "skip" */
-- fprintf(stderr, "MPEG-%u%s Layer %s", 2 - lame_get_version(gfp),
-+ if (skip==0) {
-+ if (enc_delay>-1) skip = enc_delay + 528+1;
-+ else skip=lame_get_encoder_delay(gfp)+528+1;
-+ }else{
-+ // user specified a value of skip. just add for decoder
-+ skip += 528+1; /* mp3 decoder has a 528 sample delay, plus user supplied "skip" */
-+ }
-+
-+ if (silent < 10) fprintf(stderr, "MPEG-%u%s Layer %s", 2 - lame_get_version(gfp),
- lame_get_out_samplerate( gfp ) < 16000 ? ".5" : "", "III");
- break;
- case sf_mp2:
- skip += 240 + 1;
-- fprintf(stderr, "MPEG-%u%s Layer %s", 2 - lame_get_version(gfp),
-+ if (silent < 10) fprintf(stderr, "MPEG-%u%s Layer %s", 2 - lame_get_version(gfp),
- lame_get_out_samplerate( gfp ) < 16000 ? ".5" : "", "II");
- break;
- case sf_mp1:
- skip += 240 + 1;
-- fprintf(stderr, "MPEG-%u%s Layer %s", 2 - lame_get_version(gfp),
-+ if (silent < 10) fprintf(stderr, "MPEG-%u%s Layer %s", 2 - lame_get_version(gfp),
- lame_get_out_samplerate( gfp ) < 16000 ? ".5" : "", "I");
- break;
- case sf_ogg:
-- fprintf(stderr, "Ogg Vorbis");
-+ if (silent < 10) fprintf(stderr, "Ogg Vorbis");
- skip = 0; /* other formats have no delay *//* is += 0 not better ??? */
- break;
- case sf_raw:
-- fprintf(stderr, "raw PCM data");
-+ if (silent < 10) fprintf(stderr, "raw PCM data");
- mp3input_data.nsamp = lame_get_num_samples( gfp );
- mp3input_data.framesize = 1152;
- skip = 0; /* other formats have no delay *//* is += 0 not better ??? */
- break;
- case sf_wave:
-- fprintf(stderr, "Microsoft WAVE");
-+ if (silent < 10) fprintf(stderr, "Microsoft WAVE");
- mp3input_data.nsamp = lame_get_num_samples( gfp );
- mp3input_data.framesize = 1152;
- skip = 0; /* other formats have no delay *//* is += 0 not better ??? */
- break;
- case sf_aiff:
-- fprintf(stderr, "SGI/Apple AIFF");
-+ if (silent < 10) fprintf(stderr, "SGI/Apple AIFF");
- mp3input_data.nsamp = lame_get_num_samples( gfp );
- mp3input_data.framesize = 1152;
- skip = 0; /* other formats have no delay *//* is += 0 not better ??? */
- break;
- default:
-- fprintf(stderr, "unknown");
-+ if (silent < 10) fprintf(stderr, "unknown");
- mp3input_data.nsamp = lame_get_num_samples( gfp );
- mp3input_data.framesize = 1152;
- skip = 0; /* other formats have no delay *//* is += 0 not better ??? */
-@@ -227,12 +239,12 @@
- break;
- }
-
-- fprintf(stderr, ")\noutput: %s%s(16 bit, Microsoft WAVE)\n",
-+ if (silent < 10) fprintf(stderr, ")\noutput: %s%s(16 bit, Microsoft WAVE)\n",
- strcmp(outPath, "-") ? outPath : "<stdout>",
- strlen(outPath) > 45 ? "\n\t" : " ");
-
- if (skip > 0)
-- fprintf(stderr, "skipping initial %i samples (encoder+decoder delay)\n",
-+ if (silent < 10) fprintf(stderr, "skipping initial %i samples (encoder+decoder delay)\n",
- skip);
-
- if ( 0 == disable_wav_header )
-@@ -274,11 +286,11 @@
- i = (16 / 8) * tmp_num_channels;
- assert(i > 0);
- if (wavsize <= 0) {
-- fprintf(stderr, "WAVE file contains 0 PCM samples\n");
-+ if (silent < 10) fprintf(stderr, "WAVE file contains 0 PCM samples\n");
- wavsize = 0;
- }
- else if (wavsize > 0xFFFFFFD0 / i) {
-- fprintf(stderr,
-+ if (silent < 10) fprintf(stderr,
- "Very huge WAVE file, can't set filesize accordingly\n");
- wavsize = 0xFFFFFFD0;
- }
-@@ -423,9 +435,9 @@
-
- if (nogap) {
- imp3 = lame_encode_flush_nogap(gf, mp3buffer, sizeof(mp3buffer)); /* may return one more mp3 frame */
-- /* reinitialize bitstream for next encoding. this is normally done
-- * by lame_init_params(), but we cannot call that routine twice */
-- lame_init_bitstream(gf);
-+ /* reinitialize bitstream for next encoding. this is normally done
-+ * by lame_init_params(), but we cannot call that routine twice */
-+ lame_init_bitstream(gf);
- } else {
- imp3 = lame_encode_flush(gf, mp3buffer, sizeof(mp3buffer)); /* may return one more mp3 frame */
- }
-@@ -485,6 +497,86 @@
-
-
-
-+void parse_nogap_filenames(int nogapout, char *inPath, char *outPath, char *outdir) {
-+
-+ char *slasher;
-+ int n;
-+
-+ strcpy(outPath,outdir);
-+ if (!nogapout) {
-+ strncpy(outPath, inPath, PATH_MAX + 1 - 4);
-+ n=strlen(outPath);
-+ /* nuke old extension, if one */
-+ if (outPath[n-3] == 'w'
-+ && outPath[n-2] == 'a'
-+ && outPath[n-1] == 'v'
-+ && outPath[n-4] == '.') {
-+ outPath[n-3] = 'm';
-+ outPath[n-2] = 'p';
-+ outPath[n-1] = '3';
-+ } else {
-+ outPath[n+0] = '.';
-+ outPath[n+1] = 'm';
-+ outPath[n+2] = 'p';
-+ outPath[n+3] = '3';
-+ outPath[n+4] = 0;
-+ }
-+ } else {
-+ slasher = inPath;
-+ slasher += PATH_MAX + 1 - 4;
-+
-+ /* backseek to last dir delemiter */
-+ while (*slasher != '/' && *slasher != '\\' && slasher != inPath
-+ && *slasher != ':')
-+ {
-+ slasher--;
-+ }
-+
-+ /* skip one foward if needed */
-+ if (slasher != inPath
-+ && (outPath[strlen(outPath)-1] == '/'
-+ ||
-+ outPath[strlen(outPath)-1] == '\\'
-+ ||
-+ outPath[strlen(outPath)-1] == ':'))
-+ slasher++;
-+ else if (slasher == inPath
-+ && (outPath[strlen(outPath)-1] != '/'
-+ &&
-+ outPath[strlen(outPath)-1] != '\\'
-+ &&
-+ outPath[strlen(outPath)-1] != ':'))
-+#ifdef _WIN32
-+ strcat(outPath, "\\");
-+#elif __OS2__
-+ strcat(outPath, "\\");
-+#else
-+ strcat(outPath, "/");
-+#endif
-+
-+ strncat(outPath, slasher, PATH_MAX + 1 - 4);
-+ n=strlen(outPath);
-+ /* nuke old extension */
-+ if (outPath[n-3] == 'w'
-+ && outPath[n-2] == 'a'
-+ && outPath[n-1] == 'v'
-+ && outPath[n-4] == '.') {
-+ outPath[n-3] = 'm';
-+ outPath[n-2] = 'p';
-+ outPath[n-1] = '3';
-+ } else {
-+ outPath[n+0] = '.';
-+ outPath[n+1] = 'm';
-+ outPath[n+2] = 'p';
-+ outPath[n+3] = '3';
-+ outPath[n+4] = 0;
-+ }
-+ }
-+}
-+
-+
-+
-+
-
-
-
-@@ -493,21 +585,49 @@
- {
- int ret;
- lame_global_flags *gf;
-- char outPath[MAX_NAME_SIZE];
-- char inPath[MAX_NAME_SIZE];
--#define MAX_NOGAP 20
-+ char outPath[PATH_MAX + 1];
-+ char nogapdir[PATH_MAX + 1];
-+ char inPath[PATH_MAX + 1];
-+
-+ /* support for "nogap" encoding of up to 200 .wav files */
-+#define MAX_NOGAP 200
-+ int nogapout = 0;
- int max_nogap = MAX_NOGAP;
- char *nogap_inPath[MAX_NOGAP];
-+
- int i;
- FILE *outf;
-
- #if macintosh
- argc = ccommand(&argv);
- #endif
-+
-+#if defined(_WIN32)
-+ /* set affinity back to all CPUs. Fix for EAC/lame on SMP systems from
-+ "Todd Richmond" <todd.richmond@openwave.com> */
-+ typedef BOOL (WINAPI *SPAMFunc)(HANDLE, DWORD);
-+ SPAMFunc func;
-+ SYSTEM_INFO si;
-+
-+ if ((func = (SPAMFunc)GetProcAddress(GetModuleHandle("KERNEL32.DLL"),
-+ "SetProcessAffinityMask")) != NULL) {
-+ GetSystemInfo(&si);
-+ func(GetCurrentProcess(), si.dwActiveProcessorMask);
-+ }
-+#endif
-+
-+
-+#ifdef __EMX__
-+ /* This gives wildcard expansion on Non-POSIX shells with OS/2 */
-+ _wildcard(&argc, &argv);
-+#endif
-+
- for (i = 0; i < max_nogap; ++i) {
-- nogap_inPath[i] = malloc(MAX_NAME_SIZE);
-+ nogap_inPath[i] = malloc(PATH_MAX + 1);
- }
-
-+ memset(inPath, 0, sizeof(inPath));
-+
- /* initialize libmp3lame */
- input_format = sf_unknown;
- if (NULL == (gf = lame_init())) {
-@@ -533,12 +653,22 @@
- if (update_interval < 0.)
- update_interval = 2.;
-
-+ if (outPath[0] != '\0' && max_nogap>0) {
-+ strncpy(nogapdir, outPath, PATH_MAX + 1);
-+ nogapout = 1;
-+ }
-+
- /* initialize input file. This also sets samplerate and as much
- other data on the input file as available in the headers */
- if (max_nogap > 0) {
-- strncpy(outPath, nogap_inPath[0], MAX_NAME_SIZE - 4);
-- strncat(outPath, ".mp3", 4);
-+ /* for nogap encoding of multiple input files, it is not possible to
-+ * specify the output file name, only an optional output directory. */
-+ parse_nogap_filenames(nogapout,nogap_inPath[0],outPath,nogapdir);
- outf = init_files(gf, nogap_inPath[0], outPath);
-+ if (lame_get_bWriteVbrTag(gf)) {
-+ fprintf(stderr,"Note: Disabling VBR Xing/Info tag since it interferes with --nogap\n");
-+ lame_set_bWriteVbrTag( gf, 0 );
-+ }
- }
- else {
- outf = init_files(gf, inPath, outPath);
-@@ -564,7 +694,7 @@
- }
-
-
--#ifdef HAVE_VORBIS
-+#ifdef HAVE_VORBIS_ENCODER
- if (lame_get_ogg(gf)) {
- lame_encode_ogg_init(gf);
- lame_set_VBR(gf, vbr_off); /* ignore lame's various VBR modes */
-@@ -577,16 +707,18 @@
- if (mp3_delay_set)
- lame_decoder(gf, outf, mp3_delay, inPath, outPath);
- else
-- lame_decoder(gf, outf, lame_get_encoder_delay(gf), inPath, outPath);
-+ lame_decoder(gf, outf, 0, inPath, outPath);
-
- }
- else {
- if (max_nogap > 0) {
-+ /*
-+ * encode multiple input files using nogap option
-+ */
- for (i = 0; i < max_nogap; ++i) {
- int use_flush_nogap = (i != (max_nogap - 1));
- if (i > 0) {
-- strncpy(outPath, nogap_inPath[i], MAX_NAME_SIZE - 4);
-- strncat(outPath, ".mp3", 4);
-+ parse_nogap_filenames(nogapout,nogap_inPath[i],outPath,nogapdir);
- /* note: if init_files changes anything, like
- samplerate, num_channels, etc, we are screwed */
- outf = init_files(gf, nogap_inPath[i], outPath);
-@@ -594,8 +726,12 @@
- brhist_init_package(gf);
- ret =
- lame_encoder(gf, outf, use_flush_nogap, nogap_inPath[i],
-- outPath);
-+ outPath);
-+
-+ if (silent<=0) ReportLameTagProgress(gf,1);
- lame_mp3_tags_fid(gf, outf); /* add VBR tags to mp3 file */
-+ if (silent<=0) ReportLameTagProgress(gf,0);
-+
- fclose(outf); /* close the output file */
- close_infile(); /* close the input file */
- }
-@@ -603,9 +739,16 @@
-
- }
- else {
-+ /*
-+ * encode a single input file
-+ */
- brhist_init_package(gf);
- ret = lame_encoder(gf, outf, 0, inPath, outPath);
-+
-+ if (silent<=0) ReportLameTagProgress(gf,1);
- lame_mp3_tags_fid(gf, outf); /* add VBR tags to mp3 file */
-+ if (silent<=0) ReportLameTagProgress(gf,0);
-+
- fclose(outf); /* close the output file */
- close_infile(); /* close the input file */
- lame_close(gf);
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/main.h cinelerra-1.1.5/plugins/lame/frontend/main.h
---- cinelerra-1.1.5/plugins/lame/frontend.orig/main.h Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/main.h Tue Oct 15 11:25:25 2002
-@@ -22,8 +22,11 @@
-
-
- #include "get_audio.h"
-+#include <limits.h>
-
--#define MAX_NAME_SIZE 1000
-+#ifndef PATH_MAX
-+#define PATH_MAX 1024
-+#endif
-
-
- /* GLOBAL VARIABLES used by parse.c and main.c.
-@@ -32,8 +35,11 @@
- extern int swapbytes; /* force byte swapping default=0*/
- extern int silent;
- extern int brhist;
-+
- extern int mp3_delay; /* for decoder only */
- extern int mp3_delay_set; /* for decoder only */
-+extern int enc_delay; /* if decoder finds a Xing header */
-+extern int enc_padding; /* if decoder finds a Xing header */
- extern float update_interval; /* to use Frank's time status display */
- extern int disable_wav_header; /* for decoder only */
- extern mp3data_struct mp3input_data; /* used by Ogg and MP3 */
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/mp3rtp.c cinelerra-1.1.5/plugins/lame/frontend/mp3rtp.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/mp3rtp.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/mp3rtp.c Tue Oct 15 11:33:43 2002
-@@ -47,8 +47,6 @@
- #include <dmalloc.h>
- #endif
-
--#define MAX_NAME_SIZE 2048 /* current value of Linux */
--
- /*
- * Encode (via LAME) to mp3 with RTP streaming of the output.
- *
-@@ -88,9 +86,9 @@
-
-
-
--unsigned maxvalue ( short int Buffer [2] [1152] )
-+unsigned int maxvalue ( int Buffer [2] [1152] )
- {
-- int max = 0;
-+ unsigned int max = 0;
- int i;
-
- for ( i = 0; i < 1152; i++ ) {
-@@ -101,7 +99,7 @@
- return max;
- }
-
--void levelmessage ( unsigned maxvalue )
-+void levelmessage ( unsigned int maxvalue )
- {
- char buff [] = "| . | . | . | . | . | . | . | . | . | . | \r";
- static int max = 0;
-@@ -128,8 +126,8 @@
- int main ( int argc, char **argv )
- {
- unsigned char mp3buffer [LAME_MAXMP3BUFFER];
-- char inPath [MAX_NAME_SIZE];
-- char outPath [MAX_NAME_SIZE];
-+ char inPath [PATH_MAX + 1];
-+ char outPath [PATH_MAX + 1];
- int Buffer [2] [1152];
-
- lame_global_flags *gf;
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/mp3x.c cinelerra-1.1.5/plugins/lame/frontend/mp3x.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/mp3x.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/mp3x.c Tue Oct 15 11:33:43 2002
-@@ -36,8 +36,8 @@
- {
- char mp3buffer[LAME_MAXMP3BUFFER];
- lame_global_flags *gf;
-- char outPath[MAX_NAME_SIZE];
-- char inPath[MAX_NAME_SIZE];
-+ char outPath[PATH_MAX + 1];
-+ char inPath[PATH_MAX + 1];
- int ret;
-
- gf=lame_init();
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/parse.c cinelerra-1.1.5/plugins/lame/frontend/parse.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/parse.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/parse.c Sun Nov 17 10:45:51 2002
-@@ -43,6 +43,14 @@
- # endif
- #endif
-
-+#ifdef __OS2__
-+#include <os2.h>
-+#define PRTYC_IDLE 1
-+#define PRTYC_REGULAR 2
-+#define PRTYD_MINIMUM -31
-+#define PRTYD_MAXIMUM 31
-+#endif
-+
- #include "lame.h"
-
- #include "brhist.h"
-@@ -66,6 +74,9 @@
- during decode */
- int mp3_delay_set; /* user specified the value of the mp3 encoder
- delay to assume for decoding */
-+
-+int enc_delay;
-+int enc_padding;
- int disable_wav_header;
- mp3data_struct mp3input_data; /* used by Ogg and MP3 */
-
-@@ -84,18 +95,20 @@
- static void
- dosToLongFileName( char *fn )
- {
-- const int MSIZE = MAX_NAME_SIZE-4; // we wanna add ".mp3" later
-+ const int MSIZE = PATH_MAX + 1 - 4; // we wanna add ".mp3" later
- WIN32_FIND_DATAA lpFindFileData;
- HANDLE h = FindFirstFileA( fn, &lpFindFileData );
- if ( h != INVALID_HANDLE_VALUE ) {
- int a;
-- char *q;
-+ char *q, *p;
- FindClose( h );
- for ( a = 0; a < MSIZE; a++ ) {
- if ( '\0' == lpFindFileData.cFileName[a] ) break;
- }
- if ( a >= MSIZE || a == 0 ) return;
- q = strrchr( fn, '\\' );
-+ p = strrchr( fn, '/' );
-+ if ( p-q > 0 ) q = p;
- if ( q == NULL ) q = strrchr(fn,':');
- if ( q == NULL ) strncpy( fn, lpFindFileData.cFileName, a );
- else {
-@@ -107,6 +120,69 @@
- }
- #endif
-
-+#if defined(__OS2__)
-+/* OS/2 priority functions */
-+static int setOS2Priority( lame_global_flags* gfp, int Priority )
-+{
-+ int rc;
-+
-+ switch(Priority) {
-+
-+ case 0:
-+ rc = DosSetPriority(
-+ 0, /* Scope: only one process */
-+ PRTYC_IDLE, /* select priority class (idle, regular, etc) */
-+ 0, /* set delta */
-+ 0); /* Assume current process */
-+ printf("==> Priority set to 0 (Low priority).\n");
-+ break;
-+
-+ case 1:
-+ rc = DosSetPriority(
-+ 0, /* Scope: only one process */
-+ PRTYC_IDLE, /* select priority class (idle, regular, etc) */
-+ PRTYD_MAXIMUM, /* set delta */
-+ 0); /* Assume current process */
-+ printf("==> Priority set to 1 (Medium priority).\n");
-+ break;
-+
-+ case 2:
-+ rc = DosSetPriority(
-+ 0, /* Scope: only one process */
-+ PRTYC_REGULAR, /* select priority class (idle, regular, etc) */
-+ PRTYD_MINIMUM, /* set delta */
-+ 0); /* Assume current process */
-+ printf("==> Priority set to 2 (Regular priority).\n");
-+ break;
-+
-+ case 3:
-+ rc = DosSetPriority(
-+ 0, /* Scope: only one process */
-+ PRTYC_REGULAR, /* select priority class (idle, regular, etc) */
-+ 0, /* set delta */
-+ 0); /* Assume current process */
-+ printf("==> Priority set to 3 (High priority).\n");
-+ break;
-+
-+ case 4:
-+ rc = DosSetPriority(
-+ 0, /* Scope: only one process */
-+ PRTYC_REGULAR, /* select priority class (idle, regular, etc) */
-+ PRTYD_MAXIMUM, /* set delta */
-+ 0); /* Assume current process */
-+ printf("==> Priority set to 4 (Maximum priority). I hope you enjoy it :)\n");
-+ break;
-+
-+ default:
-+ printf("==> Invalid priority specified! Assuming idle priority.\n");
-+ }
-+
-+
-+ return 0;
-+}
-+#endif
-+
-+
- /************************************************************************
- *
- * license
-@@ -192,10 +268,14 @@
- "\n"
- " <infile> and/or <outfile> can be \"-\", which means stdin/stdout.\n"
- "\n"
-- "Try \"%s --help\" for more information\n"
-- " or \"%s --longhelp\"\n"
-- " or \"%s -?\" for a complete options list\n\n",
-- ProgramName, ProgramName, ProgramName, ProgramName );
-+ "Try:\n"
-+ " \"%s --help\" for general usage information\n"
-+ " or:\n"
-+ " \"%s --preset help\" for information on suggested predefined settings\n"
-+ " or:\n"
-+ " \"%s --longhelp\"\n"
-+ " or \"%s -?\" for a complete options list\n\n",
-+ ProgramName, ProgramName, ProgramName, ProgramName, ProgramName );
- return 0;
- }
-
-@@ -230,9 +310,20 @@
- " default is (j) or (s) depending on bitrate\n"
- " -V n quality setting for VBR. default n=%i\n"
- "\n"
-- " --preset type type must be phone, voice, fm, tape, hifi, cd or studio\n"
-+ " --preset type type must be \"standard\", \"extreme\", \"insane\",\n"
-+ " or a value for an average desired bitrate and depending on\n"
-+ " the value specified, appropriate quality settings will be used.\n"
- " \"--preset help\" gives some more infos on these\n"
- "\n"
-+#if defined(__OS2__)
-+ " --priority type sets the process priority (OS/2 only):\n"
-+ " 0 = Low priority\n"
-+ " 1 = Medium priority\n"
-+ " 2 = Regular priority\n"
-+ " 3 = High priority\n"
-+ " 4 = Maximum priority\n"
-+ "\n"
-+#endif
- " --longhelp full list of options\n"
- "\n",
- ProgramName, lame_get_VBR_q(gfp) );
-@@ -275,8 +366,8 @@
- " -r input is raw pcm\n"
- " -x force byte-swapping of input\n"
- " -s sfreq sampling frequency of input file (kHz) - default 44.1 kHz\n"
--#ifdef LIBSNDFILE
- " --bitwidth w input bit width is w (default 16)\n"
-+#ifdef LIBSNDFILE
- " --signed input is signed (default)\n"
- " --unsigned input is unsigned\n"
- " --little-endian input is little-endian (default from host)\n"
-@@ -285,8 +376,14 @@
- " --mp1input input file is a MPEG Layer I file\n"
- " --mp2input input file is a MPEG Layer II file\n"
- " --mp3input input file is a MPEG Layer III file\n"
-- " --ogginput input file is a Ogg Vorbis file",
-- ProgramName );
-+#if defined(HAVE_VORBIS)
-+ " --ogginput input file is a Ogg Vorbis file\n"
-+#endif
-+ " --nogap <file1> <file2> <...>\n"
-+ " gapless encoding for a set of contiguous files\n"
-+ " --nogapout <dir>\n"
-+ " output dir for gapless encoding (must precede --nogap)"
-+ , ProgramName );
-
- wait_for ( fp, lessmode );
- fprintf ( fp,
-@@ -296,30 +393,32 @@
- " force = force ms_stereo on all frames.\n"
- " auto = jstereo, with varialbe mid/side threshold\n"
- " -a downmix from stereo to mono file for mono encoding\n"
-- " -d allow channels to have different blocktypes\n"
-- " --disptime <arg>print progress report every arg seconds\n"
-+#if defined(HAVE_VORBIS_ENCODER)
- " --ogg encode to Ogg Vorbis instead of MP3\n"
-+#endif
- " --freeformat produce a free format bitstream\n"
- " --decode input=mp3 file, output=wav\n"
- " -t disable writing wav header when using --decode\n"
- " --comp <arg> choose bitrate to achive a compression ratio of <arg>\n"
- " --scale <arg> scale input (multiply PCM data) by <arg>\n"
-- " --athonly only use the ATH for masking\n"
-- " --noath disable the ATH for masking\n"
-- " --athlower x lower the ATH x dB\n"
-- " --notemp disable temporal masking effect\n"
-- " --short use short blocks\n"
-- " --noshort do not use short blocks\n"
-- " --voice experimental voice mode\n"
-- " --preset type type must be phone, voice, fm, tape, hifi, cd or studio\n"
-- " \"--preset help\" gives some more infos on these" );
-+ " --scale-l <arg> scale channel 0 (left) input (multiply PCM data) by <arg>\n"
-+ " --scale-r <arg> scale channel 1 (right) input (multiply PCM data) by <arg>\n"
-+ " --preset type type must be \"standard\", \"extreme\", \"insane\",\n"
-+ " or a value for an average desired bitrate and depending on\n"
-+ " the value specified, appropriate quality settings will be used.\n"
-+ " \"--preset help\" gives some more infos on these\n"
-+ " --r3mix use r3mix.net VBR preset"
-+ );
-
- wait_for ( fp, lessmode );
- fprintf ( fp,
- " Verbosity:\n"
-+ " --disptime <arg>print progress report every arg seconds\n"
- " -S don't print progress report, VBR histograms\n"
-+ " --nohist disable VBR histogram display\n"
- " --silent don't print anything on screen\n"
- " --quiet don't print anything on screen\n"
-+ " --brief print more useful information\n"
- " --verbose print a lot of useful information\n"
- "\n"
- " Noise shaping & psycho acoustic algorithms:\n"
-@@ -327,12 +426,14 @@
- " -q 0: Highest quality, very slow \n"
- " -q 9: Poor quality, but fast \n"
- " -h Same as -q 2. Recommended.\n"
-- " -f Same as -q 7. Fast, ok quality\n" );
-+ " -f Same as -q 7. Fast, ok quality\n"
-+ );
-
- wait_for ( fp, lessmode );
- fprintf ( fp,
- " CBR (constant bitrate, the default) options:\n"
- " -b <bitrate> set the bitrate in kbps, default 128 kbps\n"
-+ " --cbr enforce use of constant bitrate\n"
- "\n"
- " ABR options:\n"
- " --abr <bitrate> specify average bitrate desired (instead of quality)\n"
-@@ -341,19 +442,60 @@
- " -v use variable bitrate (VBR) (--vbr-old)\n"
- " --vbr-old use old variable bitrate (VBR) routine\n"
- " --vbr-new use new variable bitrate (VBR) routine\n"
-- " --vbr-mtrh a merger of old and new (VBR) routine\n"
- " -V n quality setting for VBR. default n=%i\n"
- " 0=high quality,bigger files. 9=smaller files\n"
- " -b <bitrate> specify minimum allowed bitrate, default 32 kbps\n"
- " -B <bitrate> specify maximum allowed bitrate, default 320 kbps\n"
- " -F strictly enforce the -b option, for use with players that\n"
-- " do not support low bitrate mp3 (Apex AD600-A DVD/mp3 player)\n"
-- " -t disable writing Xing VBR informational tag\n"
-- " --nohist disable VBR histogram display",
-- lame_get_VBR_q(gfp) );
-+ " do not support low bitrate mp3\n"
-+ " -t disable writing LAME Tag\n"
-+ , lame_get_VBR_q(gfp) );
-
- wait_for ( fp, lessmode );
- fprintf ( fp,
-+ " ATH related:\n"
-+ " --noath turns ATH down to a flat noise floor\n"
-+ " --athshort ignore GPSYCHO for short blocks, use ATH only\n"
-+ " --athonly ignore GPSYCHO completely, use ATH only\n"
-+ " --athtype n selects between different ATH types [0-5]\n"
-+ " --athlower x lowers ATH by x dB\n"
-+ " --athaa-type n ATH auto adjust types 1-3, else no adjustment\n"
-+ " --athaa-loudapprox n n=1 total energy or n=2 equal loudness curve\n"
-+ " --athaa-sensitivity x activation offset in -/+ dB for ATH auto-adjustment\n"
-+ "\n"
-+ " PSY related:\n"
-+ " --short use short blocks when appropriate\n"
-+ " --noshort do not use short blocks\n"
-+ " --allshort use only short blocks\n"
-+ " --cwlimit <freq> compute tonality up to freq (in kHz) default 8.8717\n"
-+#if 0
-+/* this is redundant, we already have --notemp */
-+ " --temporal-masking n use temporal masking effect n=0:no n=1:yes\n"
-+#endif
-+ " --notemp disable temporal masking effect\n"
-+ " --nspsytune experimental PSY tunings by Naoki Shibata\n"
-+ " --nssafejoint M/S switching criterion\n"
-+ " --nsmsfix <arg> M/S switching tuning [effective 0-3.5]\n"
-+ " --interch x adjust inter-channel masking ratio\n"
-+ " --substep n use pseudo substep noise shaping method types 0-2\n"
-+ " --ns-bass x adjust masking for sfbs 0 - 6 (long) 0 - 5 (short)\n"
-+ " --ns-alto x adjust masking for sfbs 7 - 13 (long) 6 - 10 (short)\n"
-+ " --ns-treble x adjust masking for sfbs 14 - 21 (long) 11 - 12 (short)\n"
-+ " --ns-sfb21 x change ns-treble by x dB for sfb21\n"
-+ );
-+
-+ wait_for ( fp, lessmode );
-+
-+ fprintf ( fp,
-+ " experimental switches:\n"
-+ " -X n selects between different noise measurements\n"
-+ " -Y lets LAME ignore noise in sfb21, like in CBR\n"
-+ " -Z toggles the scalefac feature on\n"
-+ );
-+
-+ wait_for ( fp, lessmode );
-+
-+ fprintf ( fp,
- " MP3 header/stream options:\n"
- " -e <emp> de-emphasis n/5/c (obsolete)\n"
- " -c mark as copyright\n"
-@@ -371,7 +513,7 @@
- " --highpass <freq> frequency(kHz), highpass filter cutoff below freq\n"
- " --highpass-width <freq> frequency(kHz) - default 15%% of highpass freq\n"
- " --resample <sfreq> sampling frequency of output file(kHz)- default=automatic\n"
-- " --cwlimit <freq> compute tonality up to freq (in kHz) default 8.8717" );
-+ );
-
- wait_for ( fp, lessmode );
- fprintf ( fp,
-@@ -393,57 +535,35 @@
- " Note: A version 2 tag will NOT be added unless one of the input fields\n"
- " won't fit in a version 1 tag (e.g. the title string is longer than 30\n"
- " characters), or the '--add-id3v2' or '--id3v2-only' options are used,\n"
-- " or output is redirected to stdout."
--#if defined(HAVE_VORBIS)
-+ " or output is redirected to stdout.\n"
-+#if defined(HAVE_VORBIS_ENCODER)
- "\n\n"
- " Note: All '--t*' options (except those for track and genre) work for Ogg\n"
- " Vorbis output, but other ID3-specific options are ignored."
- #endif
--#if defined(HAVE_GTK)
-- "\n\n"
-- " -g run graphical analysis on <infile>"
-+#if defined(__OS2__)
-+ "\n\nOS/2-specific options:\n"
-+ " --priority <type> sets the process priority:\n"
-+ " 0 = Low priority (IDLE, delta = 0)\n"
-+ " 1 = Medium priority (IDLE, delta = +31)\n"
-+ " 2 = Regular priority (REGULAR, delta = -31)\n"
-+ " 3 = High priority (REGULAR, delta = 0)\n"
-+ " 4 = Maximum priority (REGULAR, delta = +31)\n"
-+ " Note: Calling '--priority' without a parameter will select priority 0.\n"
- #endif
-+
- );
-
-+#if defined(HAVE_NASM)
- wait_for ( fp, lessmode );
-- display_bitrates ( fp );
--
-- return 0;
--}
--
--int extra_help ( const lame_global_flags* gfp, FILE* const fp, const char* ProgramName, int lessmode ) /* print long syntax help */
--{
-- lame_version_print ( fp );
- fprintf ( fp,
-- "Expert options (if you really know what you are doing)\n"
-- "\nATH related:\n"
-- "--noath turns ATH down to a flat noise floor\n"
-- "--athshort ignore GPSYCHO for short blocks, use ATH only\n"
-- "--athonly ignore GPSYCHO completely, use ATH only\n"
-- "--athtype n selects between different ATH types [0-5]\n"
-- "--athlower x lowers ATH by x dB\n"
-- "--ath-adjust n ATH auto adjust types 1-3, else no adjustment\n"
-- "--adapt-thres-type n n=1 total energy or n=2 approximated loudness\n"
-- "--adapt-thres-level x ??\n"
-- "-Y different ATH adjust method\n"
-- "\nPSY related:\n"
-- "--temporal-masking n use temporal masking effect n=0:no n=1:yes\n"
-- "--notemp disable temporal masking effect\n"
-- "--nspsytune experimental PSY tunings by Naoki Shibata\n"
-- "--nssafejoint M/S switching criterion\n"
-- "--ns-bass x used by above\n"
-- "--ns-alto x used by above\n"
-- "--ns-treble x used by above\n"
-- );
--
-+ " Platform specific:\n"
-+ " --noasm <instructions> disable assembly optimizations for mmx/3dnow/sse\n"
-+ );
- wait_for ( fp, lessmode );
-+#endif
-
-- fprintf ( fp,
-- "\nmisc:\n"
-- "--nores disables the use of the bitreservoir\n"
-- );
--
-- wait_for ( fp, lessmode );
-+ display_bitrates ( fp );
-
- return 0;
- }
-@@ -472,6 +592,22 @@
- }
-
-
-+/* note: for presets it would be better to externalize them in a file.
-+ suggestion: lame --preset <file-name> ...
-+ or: lame --preset my-setting ... and my-setting is defined in lame.ini
-+ */
-+
-+
-+/*
-+Note from GB on 08/25/2002:
-+I am merging --presets and --alt-presets. Old presets are now aliases for
-+corresponding abr values from old alt-presets. This way we now have a
-+unified preset system, and I hope than more people will use the new tuned
-+presets instead of the old unmaintained ones.
-+*/
-+
-+
-+
- /************************************************************************
- *
- * usage
-@@ -481,163 +617,264 @@
- ************************************************************************/
-
-
--typedef struct {
-- const char* name; // name of preset
-- long resample; // resample frequency in Hz, or -1 for no resampling
-- short highpass_freq; // highpass frequency in Hz, or -1 for no highpass filtering
-- short lowpass_freq; // lowpass frequency in Hz, or -1 for no lowpass filtering
-- short lowpass_width; // lowpass width in Hz
-- signed char no_short_blocks; // use of short blocks, 1: no, 0: yes
-- signed char quality; // quality, the same as -f or -h
-- MPEG_mode mode; // channel mode (mono, stereo, joint)
-- short cbr; // CBR data rate in kbps (8...320)
-- signed char vbr_mode; // VBR mode (0...9)
-- short vbr_min; // minimum VBR rate in kbps ( 8...256)
-- short vbr_max; // maximum VBR rate in kbps (16...320)
--} preset_t;
--
--const preset_t Presets [] = {
-- // name fs fu fo dfo shrt qual mode cbr vbr_mode/min/max
-- { "phone" , 8000, 125, 3400, 0, 1, 5, MONO , 16, 6, 8, 24 }, // phone standard 300-3400
-- { "phon+" , 11025, 100, 4000, 0, 1, 5, MONO , 24, 4, 16, 32 }, // phone theoretical limits
-- { "lw" , 11025, -1, 4000, 0, 0, 5, MONO , 24, 3, 16, 56 }, // LW
-- { "mw-eu" , 11025, -1, 4000, 0, 0, 5, MONO , 24, 3, 16, 56 }, // MW in europe
-- { "mw-us" , 16000, -1, 7500, 0, 0, 5, MONO , 40, 3, 24, 112 }, // MW in U.S.A.
-- { "sw" , 11025, -1, 4000, 0, 0, 5, MONO , 24, 3, 16, 56 }, // SW
-- { "fm" , 32000, -1, 15000, 0, 0, 3, JOINT_STEREO, 112, 3, 80, 256 },
-- { "voice" , 24000, -1, 12000, 0, 1, 5, MONO , 56, 4, 40, 112 },
-- { "radio" , -1, -1, 15000, 0, 0, 3, JOINT_STEREO, 128, 3, 96, 256 },
-- { "tape" , -1, -1, 18000, 900, 0, 3, JOINT_STEREO, 128, 3, 96, 256 },
-- { "hifi" , -1, -1, 18000, 900, 0, -1, JOINT_STEREO, 160, 2, 112, 320 },
-- { "cd" , -1, -1, -1, -1, 0, -1, STEREO , 192, 1, 128, 320 },
-- { "studio", -1, -1, -1, -1, 0, -1, STEREO , 256, 0, 160, 320 },
--};
-+
-+static void presets_longinfo_dm ( FILE* msgfp )
-+{
-+ fprintf ( msgfp,
-+ "\n"
-+ "The --preset switches are designed to provide the highest possible quality.\n"
-+ "\n"
-+ "They have for the most part been subject to and tuned via rigorous double blind\n"
-+ "listening tests to verify and achieve this objective.\n"
-+ "\n"
-+ "These are continually updated to coincide with the latest developments that\n"
-+ "occur and as a result should provide you with nearly the best quality\n"
-+ "currently possible from LAME.\n"
-+ "\n"
-+ "To activate these presets:\n"
-+ "\n"
-+ " For VBR modes (generally highest quality):\n"
-+ "\n"
-+ " \"--preset standard\" This preset should generally be transparent\n"
-+ " to most people on most music and is already\n"
-+ " quite high in quality.\n"
-+ "\n"
-+ " \"--preset extreme\" If you have extremely good hearing and similar\n"
-+ " equipment, this preset will generally provide\n"
-+ " slightly higher quality than the \"standard\"\n"
-+ " mode.\n"
-+ "\n"
-+ " For CBR 320kbps (highest quality possible from the --preset switches):\n"
-+ "\n"
-+ " \"--preset insane\" This preset will usually be overkill for most\n"
-+ " people and most situations, but if you must\n"
-+ " have the absolute highest quality with no\n"
-+ " regard to filesize, this is the way to go.\n"
-+ "\n"
-+ " For ABR modes (high quality per given bitrate but not as high as VBR):\n"
-+ "\n"
-+ " \"--preset <kbps>\" Using this preset will usually give you good\n"
-+ " quality at a specified bitrate. Depending on the\n"
-+ " bitrate entered, this preset will determine the\n"
-+ " optimal settings for that particular situation.\n"
-+ " While this approach works, it is not nearly as\n"
-+ " flexible as VBR, and usually will not attain the\n"
-+ " same level of quality as VBR at higher bitrates.\n"
-+ "\n"
-+ "The following options are also available for the corresponding profiles:\n"
-+ "\n"
-+ " <fast> standard\n"
-+ " <fast> extreme\n"
-+ " insane\n"
-+ " <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"
-+ " simply specify a bitrate. For example:\n"
-+ " \"--preset 185\" activates this\n"
-+ " preset and uses 185 as an average kbps.\n"
-+ "\n"
-+ " \"fast\" - Enables the new fast VBR for a particular profile. The\n"
-+ " disadvantage to the speed switch is that often times the\n"
-+ " bitrate will be slightly higher than with the normal mode\n"
-+ " and quality may be slightly lower also.\n"
-+ " Warning: with the current version fast presets might result in too\n"
-+ " high bitrate compared to regular presets.\n"
-+ "\n"
-+ " \"cbr\" - If you use the ABR mode (read above) with a significant\n"
-+ " bitrate such as 80, 96, 112, 128, 160, 192, 224, 256, 320,\n"
-+ " you can use the \"cbr\" option to force CBR mode encoding\n"
-+ " instead of the standard abr mode. ABR does provide higher\n"
-+ " quality but CBR may be useful in situations such as when\n"
-+ " streaming an mp3 over the internet may be important.\n"
-+ "\n"
-+ " For example:\n"
-+ "\n"
-+ " \"--preset fast standard <input file> <output file>\"\n"
-+ " or \"--preset cbr 192 <input file> <output file>\"\n"
-+ " or \"--preset 172 <input file> <output file>\"\n"
-+ " or \"--preset extreme <input file> <output file>\"\n"
-+ "\n"
-+ "\n"
-+ "A few aliases are available for ABR mode:\n"
-+ "phone => 16kbps/mono phon+/lw/mw-eu/sw => 24kbps/mono\n"
-+ "mw-us => 40kbps/mono voice => 56kbps/mono\n"
-+ "fm/radio/tape => 112kbps hifi => 160kbps\n"
-+ "cd => 192kbps studio => 256kbps");
-+}
-
-
--static int presets_info ( const lame_global_flags* gfp, FILE* const fp, const char* ProgramName ) /* print possible combination */
-+static void presets_info_dm ( FILE* msgfp )
- {
-- int i;
-+ fprintf( msgfp, "\n"
-+ "presets highly tuned for utmost quality via blind listening tests:\n"
-+ " VBR presets for steady quality\n"
-+ " --preset standard\n"
-+ " --preset extreme\n"
-+ " --preset insane\n"
-+ " ABR presets for best quality at a given average bitrate:\n"
-+ " --preset <bitrate value>\n"
-+ );
-+}
-
-- fprintf ( fp, "\n");
-- lame_version_print ( fp );
--
-- fprintf ( fp, "Presets are some shortcuts for common settings.\n");
-- fprintf ( fp, "They can be combined with -v if you want VBR MP3s.\n");
--
-- fprintf ( fp, "\n ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, strlen(Presets[i].name) <= 4 ? "%5s " : " %-5s", Presets[i].name );
-- fprintf ( fp, "\n=================");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, "======" );
-- fprintf ( fp, "\n--resample ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- if ( Presets[i].resample < 0 )
-- fprintf ( fp, " " );
-- else
-- fprintf ( fp, "%6.3g", Presets[i].resample*1.e-3 );
-- fprintf ( fp, "\n--highpass ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- if ( Presets[i].highpass_freq < 0 )
-- fprintf ( fp, " " );
-+
-+static void presets_info_r3mix ( FILE* msgfp )
-+{
-+ fprintf( msgfp, "\n"
-+ "r3mix- VBR preset for steady quality with little excess:\n"
-+ " --preset r3mix\n" );
-+}
-+
-+
-+
-+/* some presets thanks to Dibrom
-+ */
-+static int presets_set( lame_t gfp, int fast, int cbr, const char* preset_name, const char* ProgramName )
-+{
-+ int mono = 0;
-+
-+ if ((strcmp(preset_name, "help") == 0) && (fast < 1)
-+ && (cbr < 1)) {
-+ lame_version_print ( stdout );
-+ presets_longinfo_dm( stdout );
-+ return -1;
-+ }
-+
-+
-+
-+ //aliases for compatibility with old presets
-+
-+ if (strcmp(preset_name, "phone") == 0) {
-+ preset_name = "16";
-+ mono = 1;
-+ }
-+ if ( (strcmp(preset_name, "phon+") == 0) ||
-+ (strcmp(preset_name, "lw") == 0) ||
-+ (strcmp(preset_name, "mw-eu") == 0) ||
-+ (strcmp(preset_name, "sw") == 0)) {
-+ preset_name = "24";
-+ mono = 1;
-+ }
-+ if (strcmp(preset_name, "mw-us") == 0) {
-+ preset_name = "40";
-+ mono = 1;
-+ }
-+ if (strcmp(preset_name, "voice") == 0) {
-+ preset_name = "56";
-+ mono = 1;
-+ }
-+ if (strcmp(preset_name, "fm") == 0) {
-+ preset_name = "112";
-+ }
-+ if ( (strcmp(preset_name, "radio") == 0) ||
-+ (strcmp(preset_name, "tape") == 0)) {
-+ preset_name = "112";
-+ }
-+ if (strcmp(preset_name, "hifi") == 0) {
-+ preset_name = "160";
-+ }
-+ if (strcmp(preset_name, "cd") == 0) {
-+ preset_name = "192";
-+ }
-+ if (strcmp(preset_name, "studio") == 0) {
-+ preset_name = "256";
-+ }
-+
-+
-+
-+ if (strcmp(preset_name, "medium") == 0) {
-+
-+ if (fast > 0)
-+ lame_set_preset(gfp, MEDIUM_FAST);
- else
-- fprintf ( fp, "%6.3g", Presets[i].highpass_freq*1.e-3 );
-- fprintf ( fp, "\n--lowpass ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- if ( Presets[i].lowpass_freq < 0 )
-- fprintf ( fp, " " );
-+ lame_set_preset(gfp, MEDIUM);
-+
-+ return 0;
-+ }
-+
-+ if (strcmp(preset_name, "standard") == 0) {
-+
-+ if (fast > 0)
-+ lame_set_preset(gfp, STANDARD_FAST);
- else
-- fprintf ( fp, "%6.3g", Presets[i].lowpass_freq*1.e-3 );
-- fprintf ( fp, "\n--lowpass-width ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- if ( Presets[i].lowpass_width < 0 )
-- fprintf ( fp, " " );
-+ lame_set_preset(gfp, STANDARD);
-+
-+ return 0;
-+ }
-+
-+ else if (strcmp(preset_name, "extreme") == 0){
-+
-+ if (fast > 0)
-+ lame_set_preset(gfp, EXTREME_FAST);
- else
-- fprintf ( fp, "%6.3g", Presets[i].lowpass_width*1.e-3 );
-- fprintf ( fp, "\n--noshort ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- switch ( Presets[i].no_short_blocks ) {
-- case 1: fprintf ( fp, " yes" ); break;
-- case 0: fprintf ( fp, " no" ); break;
-- case -1: fprintf ( fp, " " ); break;
-- default: assert (0); break;
-- }
-- fprintf ( fp, "\n ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- switch ( Presets[i].mode ) {
-- case MONO: fprintf ( fp, " -mm"); break;
-- case JOINT_STEREO: fprintf ( fp, " -mj"); break;
-- case STEREO: fprintf ( fp, " -ms"); break;
-- case -1: fprintf ( fp, " "); break;
-- default: assert (0); break;
-- }
-- fprintf ( fp, "\n ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- switch ( Presets[i].quality ) {
-- case -1: fprintf ( fp, " "); break;
-- case 2: fprintf ( fp, " -h"); break;
-- case 3: fprintf ( fp, " -q3"); break;
-- case 5: fprintf ( fp, " "); break;
-- case 7: fprintf ( fp, " -f"); break;
-- default: assert (0); break;
-- }
-- fprintf ( fp, "\n-b ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, "%6u", Presets[i].cbr );
-- fprintf ( fp, "\n-- PLUS WITH -v ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, "------" );
-- fprintf ( fp, "-\n-V ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, "%6u", Presets[i].vbr_mode );
-- fprintf ( fp, "\n-b ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, "%6u", Presets[i].vbr_min );
-- fprintf ( fp, "\n-B ");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, "%6u", Presets[i].vbr_max );
-- fprintf ( fp, "\n----------------");
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++)
-- fprintf ( fp, "------" );
--
-- fprintf ( fp, "-\nEXAMPLES:\n");
-- fprintf ( fp, " a) --preset fm\n");
-- fprintf ( fp, " equal to: -mj -b112 --resample 32 --lowpass 15 --lowpass-width 0\n");
-- fprintf ( fp, " b) -v --preset studio\n");
-- fprintf ( fp, " equals to: -h -ms -V0 -b160 -B320\n");
-+ lame_set_preset(gfp, EXTREME);
-+
-+ return 0;
-+ }
-+
-+ else if (((strcmp(preset_name, "insane") == 0) ||
-+ (strcmp(preset_name, "320" ) == 0)) && (fast < 1)) {
-+
-+ lame_set_preset(gfp, INSANE);
-
-- return 0;
--}
-+ return 0;
-+ }
-
-+ // Generic ABR Preset
-+ if (((atoi(preset_name)) > 0) && (fast < 1)) {
-+ if ((atoi(preset_name)) >= 8 && (atoi(preset_name)) <= 320){
-+ lame_set_preset(gfp, atoi(preset_name));
-
--static int presets_setup ( lame_global_flags* gfp, const char* preset_name, const char* ProgramName )
--{
-- int i;
-+ if (cbr == 1 )
-+ lame_set_VBR(gfp, vbr_off);
-+
-+ if (mono == 1 ) {
-+ lame_set_mode(gfp, MONO);
-+ }
-
-- for ( i = 0; i < sizeof(Presets)/sizeof(*Presets); i++ )
-- if ( 0 == strncmp (preset_name, Presets[i].name, strlen (preset_name) ) ) {
-- if ( Presets[i].resample >= 0 )
-- (void) lame_set_out_samplerate( gfp, Presets[i].resample );
-- if ( Presets[i].highpass_freq >= 0 )
-- lame_set_highpassfreq(gfp,Presets[i].highpass_freq),
-- lame_set_highpasswidth(gfp,0);
-- lame_set_lowpassfreq(gfp,Presets[i].lowpass_freq);
-- lame_set_lowpasswidth(gfp,Presets[i].lowpass_width);
-- lame_set_no_short_blocks( gfp, Presets[i].no_short_blocks );
-- lame_set_quality ( gfp, Presets[i].quality );
-- lame_set_mode ( gfp, Presets[i].mode );
-- lame_set_brate(gfp,Presets[i].cbr);
-- lame_set_VBR_q(gfp,Presets[i].vbr_mode);
-- lame_set_VBR_min_bitrate_kbps(gfp,Presets[i].vbr_min);
-- lame_set_VBR_max_bitrate_kbps(gfp,Presets[i].vbr_max);
- return 0;
-+
- }
-+ else {
-+ lame_version_print ( stderr );
-+ fprintf(stderr,"Error: The bitrate specified is out of the valid range for this preset\n"
-+ "\n"
-+ "When using this mode you must enter a value between \"32\" and \"320\"\n"
-+ "\n"
-+ "For further information try: \"%s --preset help\"\n"
-
-- presets_info ( gfp, stderr, ProgramName );
-+ , ProgramName
-+ );
-+ return -1;
-+ }
-+ }
-+
-+
-+
-+ lame_version_print ( stderr );
-+ fprintf(stderr,"Error: You did not enter a valid profile and/or options with --preset\n"
-+ "\n"
-+ "Available profiles are:\n"
-+ "\n"
-+ " <fast> standard\n"
-+ " <fast> extreme\n"
-+ " insane\n"
-+ " <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"
-+ " simply specify a bitrate. For example:\n"
-+ " \"--preset 185\" activates this\n"
-+ " preset and uses 185 as an average kbps.\n"
-+ "\n"
-+ " Some examples:\n"
-+ "\n"
-+ " or \"%s --preset fast standard <input file> <output file>\"\n"
-+ " or \"%s --preset cbr 192 <input file> <output file>\"\n"
-+ " or \"%s --preset 172 <input file> <output file>\"\n"
-+ " or \"%s --preset extreme <input file> <output file>\"\n"
-+ "\n"
-+ "For further information try: \"%s --preset help\"\n"
-+
-+ , ProgramName, ProgramName, ProgramName, ProgramName, ProgramName
-+ );
- return -1;
- }
-
--
- static void genre_list_handler (int num,const char *name,void *cookie)
- {
- printf ("%3d %s\n", num, name);
-@@ -692,7 +929,9 @@
- if ( 0 == local_strcasecmp ( FileName, ".mp1" ) ) return sf_mp1;
- if ( 0 == local_strcasecmp ( FileName, ".mp2" ) ) return sf_mp2;
- if ( 0 == local_strcasecmp ( FileName, ".mp3" ) ) return sf_mp3;
-+#if defined(HAVE_VORBIS)
- if ( 0 == local_strcasecmp ( FileName, ".ogg" ) ) return sf_ogg;
-+#endif
- if ( 0 == local_strcasecmp ( FileName, ".wav" ) ) return sf_wave;
- if ( 0 == local_strcasecmp ( FileName, ".aif" ) ) return sf_aiff;
- if ( 0 == local_strcasecmp ( FileName, ".raw" ) ) return sf_raw;
-@@ -743,6 +982,8 @@
- /* turn on display options. user settings may turn them off below */
- silent = 0;
- brhist = 1;
-+ enc_padding=-1;
-+ enc_delay=-1;
- mp3_delay = 0;
- mp3_delay_set=0;
- disable_wav_header=0;
-@@ -764,10 +1005,10 @@
- if (! *token) { /* The user wants to use stdin and/or stdout. */
- input_file = 1;
- if (inPath [0] == '\0')
-- strncpy (inPath, argv[i],MAX_NAME_SIZE);
-+ strncpy (inPath, argv[i], PATH_MAX + 1);
- else
- if (outPath[0] == '\0')
-- strncpy (outPath, argv[i],MAX_NAME_SIZE);
-+ strncpy (outPath, argv[i], PATH_MAX + 1);
- }
- if (*token == '-') { /* GNU style */
- token++;
-@@ -781,34 +1022,25 @@
- lame_set_VBR(gfp,vbr_rh);
-
- T_ELIF ("vbr-new")
-- lame_set_VBR(gfp,vbr_mt);
-+ lame_set_VBR(gfp,vbr_mtrh);
-
- T_ELIF ("vbr-mtrh")
- lame_set_VBR(gfp,vbr_mtrh);
-
-+ T_ELIF ("cbr")
-+ lame_set_VBR(gfp,vbr_off);
-+
- T_ELIF ("r3mix")
-- lame_set_VBR(gfp,vbr_rh);
-- lame_set_VBR_q(gfp,1);
-- lame_set_quality( gfp, 2 );
-- lame_set_lowpassfreq(gfp,19500);
-- lame_set_mode( gfp, JOINT_STEREO );
-- lame_set_ATHtype( gfp, 3 );
-- lame_set_VBR_min_bitrate_kbps(gfp,112);
--
--
-+ lame_set_preset(gfp, R3MIX);
-+
- /**
- * please, do *not* DOCUMENT this one
- * it is a developers only switch (rh)
- */
-- T_ELIF ("remix")
-- lame_set_VBR(gfp,vbr_mtrh);
-- lame_set_VBR_q(gfp,3);
-- lame_set_quality( gfp, 0 );
-- lame_set_lowpassfreq(gfp,19500);
-- lame_set_mode( gfp, JOINT_STEREO );
-- lame_set_ATHtype( gfp, 3 );
-- lame_set_VBR_min_bitrate_kbps(gfp,32);
--
-+ T_ELIF ("tune")
-+ argUsed=1;
-+ {extern void lame_set_tune(lame_t gfp, float val);
-+ lame_set_tune(gfp,atof(nextArg));}
-
- T_ELIF ("abr")
- argUsed=1;
-@@ -854,35 +1086,41 @@
- return -1;
- #endif
- T_ELIF ("ogg")
--#if defined(HAVE_VORBIS)
-+#if defined(HAVE_VORBIS_ENCODER)
- (void) lame_set_ogg( gfp, 1 );
- #else
-- fprintf(stderr,"Error: LAME not compiled with Vorbis support\n");
-+ fprintf(stderr,"Error: LAME not compiled with Vorbis Encoder support\n");
- return -1;
- #endif
- T_ELIF ("phone")
-- if (presets_setup ( gfp, token, ProgramName ) < 0)
-+ if (presets_set( gfp, 0, 0, token, ProgramName ) < 0)
- return -1;
-+ fprintf(stderr, "Warning: --phone is deprecated, use --preset phone instead!");
-
- T_ELIF ("voice")
-- if (presets_setup ( gfp, token, ProgramName ) < 0)
-+ if (presets_set( gfp, 0, 0, token, ProgramName ) < 0)
- return -1;
-+ fprintf(stderr, "Warning: --voice is deprecated, use --preset voice instead!");
-
- T_ELIF ("radio")
-- if (presets_setup ( gfp, token, ProgramName ) < 0)
-+ if (presets_set( gfp, 0, 0, token, ProgramName ) < 0)
- return -1;
--
-+ fprintf(stderr, "Warning: --radio is deprecated, use --preset radio instead!");
-+
- T_ELIF ("tape")
-- if (presets_setup ( gfp, token, ProgramName ) < 0)
-+ if (presets_set( gfp, 0, 0, token, ProgramName ) < 0)
- return -1;
-+ fprintf(stderr, "Warning: --tape is deprecated, use --preset tape instead!");
-
- T_ELIF ("cd")
-- if (presets_setup ( gfp, token, ProgramName ) < 0)
-+ if (presets_set( gfp, 0, 0, token, ProgramName ) < 0)
- return -1;
-+ fprintf(stderr, "Warning: --cd is deprecated, use --preset cd instead!");
-
- T_ELIF ("studio")
-- if (presets_setup ( gfp, token, ProgramName ) < 0)
-+ if (presets_set( gfp, 0, 0, token, ProgramName ) < 0)
- return -1;
-+ fprintf(stderr, "Warning: --studio is deprecated, use --preset studio instead!");
-
- T_ELIF ("noshort")
- (void) lame_set_no_short_blocks( gfp, 1 );
-@@ -890,6 +1128,9 @@
- T_ELIF ("short")
- (void) lame_set_no_short_blocks( gfp, 0 );
-
-+ T_ELIF ("allshort")
-+ (void) lame_set_force_short_blocks( gfp, 1 );
-+
- T_ELIF ("decode")
- (void) lame_set_decode_only( gfp, 1 );
-
-@@ -903,7 +1144,7 @@
-
- T_ELIF ("nores")
- lame_set_disable_reservoir(gfp,1);
-- lame_set_padding_type(gfp,0);
-+ lame_set_padding_type(gfp, PAD_NO);
-
- T_ELIF ("strictly-enforce-ISO")
- lame_set_strict_ISO(gfp,1);
-@@ -919,21 +1160,38 @@
- argUsed=1;
- (void) lame_set_ATHtype( gfp, atoi( nextArg ) );
-
-- T_ELIF ("ath-adjust") // switch for developing, no DOCU
-+ T_ELIF ("athaa-type") // switch for developing, no DOCU
- argUsed=1; // 1:Gaby, 2:Robert, 3:Jon, else:off
-- lame_set_adjust_type( gfp, atoi(nextArg) );
-+ lame_set_athaa_type( gfp, atoi(nextArg) );
-
-- T_ELIF ("adapt-thres-type")
-+ T_ELIF ("athaa-loudapprox")
- argUsed=1;
-- lame_set_adapt_thres_type( gfp, atoi(nextArg) );
-+ lame_set_athaa_loudapprox( gfp, atoi(nextArg) );
-
-- T_ELIF ("adapt-thres-level")
-+ T_ELIF ("athaa-sensitivity")
- argUsed=1;
-- lame_set_adapt_thres_level( gfp, atof(nextArg) );
-+ lame_set_athaa_sensitivity( gfp, atof(nextArg) );
-
- T_ELIF ("scale")
- argUsed=1;
- (void) lame_set_scale( gfp, atof(nextArg) );
-+
-+ T_ELIF ("noasm")
-+ argUsed=1;
-+ if (!strcmp(nextArg, "mmx"))
-+ (void) lame_set_asm_optimizations( gfp, MMX, 0 );
-+ if (!strcmp(nextArg, "3dnow"))
-+ (void) lame_set_asm_optimizations( gfp, AMD_3DNOW, 0 );
-+ if (!strcmp(nextArg, "sse"))
-+ (void) lame_set_asm_optimizations( gfp, SSE, 0 );
-+
-+ T_ELIF ("scale-l")
-+ argUsed=1;
-+ (void) lame_set_scale_left( gfp, atof(nextArg) );
-+
-+ T_ELIF ("scale-r")
-+ argUsed=1;
-+ (void) lame_set_scale_right( gfp, atof(nextArg) );
-
- T_ELIF ("freeformat")
- lame_set_free_format(gfp,1);
-@@ -944,6 +1202,12 @@
- T_ELIF ("nohist")
- brhist = 0;
-
-+#if defined(__OS2__)
-+ T_ELIF ("priority")
-+ argUsed=1;
-+ setOS2Priority(gfp, atoi(nextArg));
-+#endif
-+
- /* options for ID3 tag */
- T_ELIF ("tt")
- argUsed=1;
-@@ -1056,9 +1320,20 @@
- }
- lame_set_compression_ratio(gfp,val);
-
-+ T_ELIF ("no-preset-tune")
-+ (void) lame_set_preset_notune( gfp, 0 );
-+
- T_ELIF ("notemp")
- (void) lame_set_useTemporal( gfp, 0 );
-
-+ T_ELIF ("interch")
-+ argUsed=1;
-+ (void) lame_set_interChRatio( gfp, atof(nextArg ) );
-+
-+ T_ELIF ("substep")
-+ argUsed=1;
-+ (void) lame_set_substep( gfp, atof(nextArg) );
-+
- T_ELIF ("temporal-masking")
- argUsed = 1;
- (void) lame_set_useTemporal( gfp, atoi(nextArg)?1:0 );
-@@ -1070,6 +1345,10 @@
-
- T_ELIF ("nssafejoint")
- lame_set_exp_nspsytune(gfp,lame_get_exp_nspsytune(gfp) | 2);
-+
-+ T_ELIF ("nsmsfix")
-+ argUsed=1;
-+ (void) lame_set_msfix( gfp, atof(nextArg) );
-
- T_ELIF ("ns-bass")
- argUsed=1;
-@@ -1110,6 +1389,36 @@
- lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | (k << 14));
- }
-
-+ T_ELIF ("ns-sfb21")
-+ /* to be compatible with Naoki's original code,
-+ * ns-sfb21 specifies how to change ns-treble for sfb21 */
-+ argUsed=1;
-+ {
-+ double d;
-+ int k;
-+ d = atof( nextArg );
-+ k = (int)(d * 4);
-+ if (k < -32) k = -32;
-+ if (k > 31) k = 31;
-+ if (k < 0) k += 64;
-+ lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | (k << 20));
-+ }
-+
-+ T_ELIF ("nspsytune2")
-+ {
-+ FILE *fp = fopen( nextArg, "r" );
-+ if (fp == NULL) {
-+ fprintf(stderr,"nspsytune2 : error opening %s\n",nextArg);
-+ abort();
-+ }
-+ lame_set_exp_nspsytune2_pointer(gfp,0,fp);
-+ }
-+ /* nspsytune2 implies nspsytune */
-+ argUsed=1;
-+ lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | 1);
-+ lame_set_experimentalZ(gfp,1);
-+ lame_set_experimentalX(gfp,1);
-+
- /* some more GNU-ish options could be added
- * brief => few messages on screen (name, status report)
- * o/output file => specifies output filename
-@@ -1120,8 +1429,11 @@
- T_ELIF2 ("quiet", "silent")
- silent = 10; /* on a scale from 1 to 10 be very silent */
-
-+ T_ELIF ("brief")
-+ silent = -5; /* print few info on screen */
-+
- T_ELIF ("verbose")
-- silent = -10; /* print a lot on screen, the default */
-+ silent = -10; /* print a lot on screen */
-
- T_ELIF2 ("version", "license")
- print_license ( gfp, stdout, ProgramName );
-@@ -1135,10 +1447,6 @@
- long_help ( gfp, stdout, ProgramName, 0 /* lessmode=NO */ );
- return -2;
-
-- T_ELIF ("extrahelp")
-- extra_help ( gfp, stdout, ProgramName, 0 /* lessmode=NO */ );
-- return -2;
--
- T_ELIF ("?")
- #ifdef __unix__
- FILE* fp = popen ("less -Mqc", "w");
-@@ -1149,15 +1457,35 @@
- #endif
- return -2;
-
-- T_ELIF ("preset")
-+ T_ELIF2 ("preset", "alt-preset")
- argUsed = 1;
-- if (presets_setup ( gfp, nextArg, ProgramName ) < 0)
-- return -1;
--
-+ {
-+ int fast = 0, cbr = 0;
-+
-+ while ((strcmp(nextArg, "fast") == 0) ||
-+ (strcmp(nextArg, "cbr") == 0)) {
-+
-+ if ((strcmp(nextArg, "fast") == 0) && (fast < 1))
-+ fast = 1;
-+ if ((strcmp(nextArg, "cbr") == 0) && (cbr < 1))
-+ cbr = 1;
-+
-+ argUsed++;
-+ nextArg = i+argUsed < argc ? argv[i+argUsed] : "";
-+ }
-+
-+ if (presets_set ( gfp, fast, cbr, nextArg, ProgramName ) < 0)
-+ return -1;
-+ }
-+
- T_ELIF ("disptime")
- argUsed = 1;
- update_interval = atof (nextArg);
-
-+ T_ELIF ("nogapout")
-+ strcpy(outPath, nextArg);
-+ argUsed = 1;
-+
- T_ELIF ("nogap")
- nogap=1;
-
-@@ -1275,7 +1603,8 @@
- lame_set_highpassfreq(gfp,-1);
- break;
- case 'd':
-- (void) lame_set_allow_diff_short( gfp, 1 );
-+ fprintf(stderr,"WARNING: -d is obsolete.\n");
-+ /*(void) lame_set_allow_diff_short( gfp, 1 );*/
- break;
- case 'S':
- silent = 1;
-@@ -1290,11 +1619,6 @@
- case 'Z':
- lame_set_experimentalZ(gfp,1);
- break;
--#if defined(HAVE_GTK)
-- case 'g': /* turn on gtk analysis */
-- (void) lame_set_analysis( gfp, 1 );
-- break;
--#endif
- case 'e':
- argUsed = 1;
-
-@@ -1333,7 +1657,7 @@
- } else {
- if (nogap) {
- if ((num_nogap != NULL) && (count_nogap < *num_nogap)) {
-- strncpy(nogap_inPath[count_nogap++],argv[i],MAX_NAME_SIZE);
-+ strncpy(nogap_inPath[count_nogap++], argv[i], PATH_MAX + 1);
- input_file=1;
- } else {
- /* sorry, calling program did not allocate enough space */
-@@ -1345,11 +1669,11 @@
- /* normal options: inputfile [outputfile], and
- either one can be a '-' for stdin/stdout */
- if (inPath [0] == '\0') {
-- strncpy(inPath , argv[i], MAX_NAME_SIZE);
-+ strncpy(inPath , argv[i], PATH_MAX + 1);
- input_file=1;
- } else {
- if (outPath[0] == '\0')
-- strncpy(outPath, argv[i], MAX_NAME_SIZE);
-+ strncpy(outPath, argv[i], PATH_MAX + 1);
- else {
- fprintf(stderr,"%s: excess arg %s\n", ProgramName, argv[i]);
- err = 1;
-@@ -1365,18 +1689,20 @@
- }
-
- if ( inPath[0] == '-' )
-- silent = 1; /* turn off status - it's broken for stdin */
-+ /* turn off status - it's broken for stdin */
-+ silent = (silent <= 1 ? 1 : silent);
-+
- #ifdef WIN32
- else
- dosToLongFileName( inPath );
- #endif
-
-- if ( outPath[0] == '\0' ) {
-+ if ( outPath[0] == '\0' && count_nogap == 0) {
- if ( inPath[0] == '-' ) {
- /* if input is stdin, default output is stdout */
- strcpy(outPath,"-");
- } else {
-- strncpy(outPath, inPath, MAX_NAME_SIZE - 4);
-+ strncpy(outPath, inPath, PATH_MAX + 1 - 4);
- if ( lame_get_decode_only( gfp ) ) {
- strncat (outPath, ".wav", 4 );
- } else if( lame_get_ogg( gfp ) ) {
-@@ -1386,6 +1712,7 @@
- }
- }
- }
-+
- /* some file options not allowed with stdout */
- if (outPath[0]=='-') {
- (void) lame_set_bWriteVbrTag( gfp, 0 ); /* turn off VBR tag */
-@@ -1421,6 +1748,7 @@
- if ( lame_get_free_format(gfp) ) {
- if ( lame_get_brate(gfp) < 8 || lame_get_brate(gfp) > 640 ) {
- fprintf(stderr,"For free format, specify a bitrate between 8 and 640 kbps\n");
-+ fprintf(stderr,"with the -b <bitrate> option\n");
- return -1;
- }
- }
-@@ -1429,3 +1757,4 @@
- }
-
- /* end of parse.c */
-+
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/parse.h cinelerra-1.1.5/plugins/lame/frontend/parse.h
---- cinelerra-1.1.5/plugins/lame/frontend.orig/parse.h Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/parse.h Thu Oct 17 14:38:32 2002
-@@ -5,7 +5,7 @@
- int long_help ( const lame_global_flags* gfp, FILE* const fp, const char* ProgramName, int lessmode );
- int display_bitrates ( FILE* const fp );
-
--int parse_args(lame_global_flags* gfp, int argc, char** argv, char *inPath, char *outPath, char * nogap_inPath[], int *max_nogap);
-+int parse_args(lame_global_flags* gfp, int argc, char** argv, char * const inPath, char * const outPath, char * nogap_inPath[], int *max_nogap);
- void print_config(lame_global_flags* gfp);
-
- /* end of parse.h */
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/rtp.h cinelerra-1.1.5/plugins/lame/frontend/rtp.h
---- cinelerra-1.1.5/plugins/lame/frontend.orig/rtp.h Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/rtp.h Wed Feb 13 17:30:05 2002
-@@ -26,7 +26,7 @@
- int makesocket(char *szAddr,unsigned short port,unsigned char TTL,struct sockaddr_in *sSockAddr);
- void rtp_output(const char *mp3buffer,int mp3size);
-
--#ifdef 0
-+#if 0
- int rtp_send (
- SOCKET s,
- struct rtpheader *foo,
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/timestatus.c cinelerra-1.1.5/plugins/lame/frontend/timestatus.c
---- cinelerra-1.1.5/plugins/lame/frontend.orig/timestatus.c Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/timestatus.c Mon May 27 13:13:37 2002
-@@ -55,8 +55,8 @@
- #endif
-
- typedef struct {
-- double start_time; // start time of converting [s]
-- double elapsed_time; // current time - start time [s]
-+ double last_time; // result of last call to clock
-+ double elapsed_time; // total time
- double estimated_time; // estimated total duration time [s]
- double speed_index; // speed relative to realtime coding [100%]
- } timestatus_t;
-@@ -112,15 +112,29 @@
- static timestatus_t proc_time;
- int percent;
- static int init = 0; /* What happens here? A work around instead of a bug fix ??? */
-+ double tmx,delta;
-
-
- if ( frameNum == 0 ) {
-- real_time.start_time = GetRealTime ();
-- proc_time.start_time = GetCPUTime ();
-+ real_time.last_time = GetRealTime ();
-+ proc_time.last_time = GetCPUTime ();
-+ real_time.elapsed_time = 0;
-+ proc_time.elapsed_time = 0;
- }
--
-- real_time.elapsed_time = GetRealTime () - real_time.start_time;
-- proc_time.elapsed_time = GetCPUTime () - proc_time.start_time;
-+
-+ // we need rollover protection for GetCPUTime, and maybe GetRealTime():
-+ tmx=GetRealTime();
-+ delta=tmx-real_time.last_time;
-+ if (delta<0) delta=0; // ignore, clock has rolled over
-+ real_time.elapsed_time += delta;
-+ real_time.last_time = tmx;
-+
-+
-+ tmx=GetCPUTime();
-+ delta=tmx-proc_time.last_time;
-+ if (delta<0) delta=0; // ignore, clock has rolled over
-+ proc_time.elapsed_time += delta;
-+ proc_time.last_time = tmx;
-
- if ( frameNum == 0 && init == 0 ) {
- fprintf ( stderr,
-diff -Nur cinelerra-1.1.5/plugins/lame/frontend.orig/timestatus.h cinelerra-1.1.5/plugins/lame/frontend/timestatus.h
---- cinelerra-1.1.5/plugins/lame/frontend.orig/timestatus.h Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/frontend/timestatus.h Thu Oct 17 14:38:32 2002
-@@ -21,15 +21,15 @@
-
- #ifndef LAME_TIMESTATUS_H
- #define LAME_TIMESTATUS_H
--void timestatus_klemm(const lame_global_flags *gfp);
-+void timestatus_klemm(const lame_global_flags * const gfp);
-
--void timestatus ( int samp_rate,
-- int frameNum,
-- int totalframes,
-- int framesize);
-+void timestatus ( const int samp_rate,
-+ const int frameNum,
-+ const int totalframes,
-+ const int framesize);
- void timestatus_finish(void);
-
--void decoder_progress(const lame_global_flags *gfp,const mp3data_struct *);
--void decoder_progress_finish(const lame_global_flags *gfp);
-+void decoder_progress(const lame_global_flags * const gfp,const mp3data_struct * const);
-+void decoder_progress_finish(const lame_global_flags * const gfp);
-
- #endif /* LAME_TIMESTATUS_H */
---- cinelerra-1.1.5/plugins/lame/Makefile.orig Fri Jun 21 14:35:25 2002
-+++ cinelerra-1.1.5/plugins/lame/Makefile Mon Mar 24 10:10:46 2003
-@@ -14,7 +14,7 @@
-
-
- CFLAGS += -DHAVE_CONFIG_H \
-- -Iinclude \
-+ -I/usr/include/lame \
- -Ilibmp3lame \
- -I.
-
-@@ -26,34 +26,14 @@
- $(OBJDIR)/frontend/main.o \
- $(OBJDIR)/frontend/parse.o \
- $(OBJDIR)/frontend/portableio.o \
-- $(OBJDIR)/frontend/timestatus.o \
-- $(OBJDIR)/libmp3lame/VbrTag.o \
-- $(OBJDIR)/libmp3lame/bitstream.o \
-- $(OBJDIR)/libmp3lame/encoder.o \
-- $(OBJDIR)/libmp3lame/fft.o \
-- $(OBJDIR)/libmp3lame/id3tag.o \
-- $(OBJDIR)/libmp3lame/lame.o \
-- $(OBJDIR)/libmp3lame/mpglib_interface.o \
-- $(OBJDIR)/libmp3lame/newmdct.o \
-- $(OBJDIR)/libmp3lame/pcm.o \
-- $(OBJDIR)/libmp3lame/psymodel.o \
-- $(OBJDIR)/libmp3lame/quantize.o \
-- $(OBJDIR)/libmp3lame/quantize_pvt.o \
-- $(OBJDIR)/libmp3lame/reservoir.o \
-- $(OBJDIR)/libmp3lame/set_get.o \
-- $(OBJDIR)/libmp3lame/tables.o \
-- $(OBJDIR)/libmp3lame/takehiro.o \
-- $(OBJDIR)/libmp3lame/util.o \
-- $(OBJDIR)/libmp3lame/vbrquantize.o \
-- $(OBJDIR)/libmp3lame/version.o \
-- $(OBJDIR)/libmp3lame/vorbis_interface.o
-+ $(OBJDIR)/frontend/timestatus.o
-
- OUTPUT = ../$(OBJDIR)/lame.plugin
-
-
--LIBS = -lm -lcurses
-+LIBS = -lm -lcurses -lmp3lame
-
--DIRS = $(OBJDIR)/frontend $(OBJDIR)/libmp3lame/
-+DIRS = $(OBJDIR)/frontend
-
- $(shell echo $(CFLAGS) > $(OBJDIR)/c_flags)
- $(shell echo $(OBJS) $(LIBS) > $(OBJDIR)/libs)