changeset 6530:f8d544dd22e9

mono mp3 encoding support by Paul Ortyl <ortylp at 3miasto.net>
author alex
date Sun, 23 Jun 2002 17:34:29 +0000
parents 8552767dbb46
children 7bd342baa785
files mencoder.c
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mencoder.c	Sun Jun 23 17:28:44 2002 +0000
+++ b/mencoder.c	Sun Jun 23 17:34:29 2002 +0000
@@ -716,10 +716,10 @@
     if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_msg(MSGT_MENCODER,MSGL_WARN,"sizeof(MPEGLAYER3WAVEFORMAT)==%d!=30, maybe broken C compiler?\n",sizeof(MPEGLAYER3WAVEFORMAT));
     mux_a->wf=malloc(sizeof(MPEGLAYER3WAVEFORMAT)); // should be 30
     mux_a->wf->wFormatTag=0x55; // MP3
-    mux_a->wf->nChannels=sh_audio->channels;
+    mux_a->wf->nChannels=(lame_param_mode == 3) ? 1 : sh_audio->channels;
     mux_a->wf->nSamplesPerSec=force_srate?force_srate:sh_audio->samplerate;
     mux_a->wf->nAvgBytesPerSec=192000/8; // FIXME!
-    mux_a->wf->nBlockAlign=(mux_a->h.dwRate<32000)?576:1152; // requires for l3codeca.acm + WMP 6.4
+    mux_a->wf->nBlockAlign=(mux_a->h.dwRate<32000)?576:1152; // required for l3codeca.acm + WMP 6.4
     mux_a->wf->wBitsPerSample=0; //16;
     // from NaNdub:  (requires for l3codeca.acm)
     mux_a->wf->cbSize=12;
@@ -732,6 +732,8 @@
 }
 }
 
+if (verbose>1) print_wave_header(mux_a->wf);
+
 printf("Writing AVI header...\n");
 aviwrite_write_header(muxer,muxer_f);
 
@@ -849,9 +851,18 @@
 		  unsigned char tmp[2304];
 		  int len=dec_audio(sh_audio,tmp,2304);
 		  if(len<=0) break; // eof
-		  len=lame_encode_buffer_interleaved(lame,
+		  /* mono encoding, a bit tricky */
+		  if (mux_a->wf->nChannels == 1)
+		  {
+		    len = lame_encode_buffer(lame, tmp, tmp, len/4,
+			mux_a->buffer+mux_a->buffer_len, mux_a->buffer_size-mux_a->buffer_len);
+		  }
+		  else
+		  {
+		    len=lame_encode_buffer_interleaved(lame,
 		      tmp,len/4,
 		      mux_a->buffer+mux_a->buffer_len,mux_a->buffer_size-mux_a->buffer_len);
+		  }
 		  if(len<0) break; // error
 		  mux_a->buffer_len+=len;
 		}