[xiph-commits] r10092 - trunk/vorbis-tools/oggenc

msmith at svn.xiph.org msmith at svn.xiph.org
Thu Sep 29 02:51:53 PDT 2005


Author: msmith
Date: 2005-09-29 02:51:50 -0700 (Thu, 29 Sep 2005)
New Revision: 10092

Modified:
   trunk/vorbis-tools/oggenc/audio.c
   trunk/vorbis-tools/oggenc/audio.h
   trunk/vorbis-tools/oggenc/oggenc.c
Log:
Fix memleak in raw mode


Modified: trunk/vorbis-tools/oggenc/audio.c
===================================================================
--- trunk/vorbis-tools/oggenc/audio.c	2005-09-28 18:38:03 UTC (rev 10091)
+++ trunk/vorbis-tools/oggenc/audio.c	2005-09-29 09:51:50 UTC (rev 10092)
@@ -596,7 +596,7 @@
 	free(f);
 }
 
-int raw_open(FILE *in, oe_enc_opt *opt)
+int raw_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
 {
 	wav_fmt format; /* fake wave header ;) */
 	wavfile *wav = malloc(sizeof(wavfile));
@@ -763,6 +763,7 @@
 
     for(i=0; i < in_samples; i++) {
         buffer[0][i] = (d->bufs[0][i] + d->bufs[1][i])*0.5f;
+        fprintf(stderr, "%f %f -> %f\n", d->bufs[0][i] , d->bufs[1][i], buffer[0][i]);
     }
 
     return in_samples;

Modified: trunk/vorbis-tools/oggenc/audio.h
===================================================================
--- trunk/vorbis-tools/oggenc/audio.h	2005-09-28 18:38:03 UTC (rev 10091)
+++ trunk/vorbis-tools/oggenc/audio.h	2005-09-29 09:51:50 UTC (rev 10092)
@@ -54,7 +54,7 @@
 
 input_format *open_audio_file(FILE *in, oe_enc_opt *opt);
 
-int raw_open(FILE *in, oe_enc_opt *opt);
+int raw_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen);
 int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen);
 int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen);
 int wav_id(unsigned char *buf, int len);

Modified: trunk/vorbis-tools/oggenc/oggenc.c
===================================================================
--- trunk/vorbis-tools/oggenc/oggenc.c	2005-09-28 18:38:03 UTC (rev 10091)
+++ trunk/vorbis-tools/oggenc/oggenc.c	2005-09-29 09:51:50 UTC (rev 10092)
@@ -192,11 +192,16 @@
 
 		if(opt.rawmode)
 		{
+            input_format raw_format = {NULL, 0, raw_open, wav_close, "raw", 
+                N_("RAW file reader")};
+
 			enc_opts.rate=opt.raw_samplerate;
 			enc_opts.channels=opt.raw_channels;
 			enc_opts.samplesize=opt.raw_samplesize;
             enc_opts.endianness=opt.raw_endianness;
-			raw_open(in, &enc_opts);
+            
+            format = &raw_format;
+            format->open_func(in, &enc_opts, NULL, 0);
 			foundformat=1;
 		}
 		else
@@ -366,8 +371,7 @@
 		if(out_fn) free(out_fn);
         if(opt.outfile) free(opt.outfile);
 		vorbis_comment_clear(&vc);
-		if(!opt.rawmode) 
-			format->close_func(enc_opts.readdata);
+		format->close_func(enc_opts.readdata);
 
 		if(closein)
 			fclose(in);



More information about the commits mailing list