changeset 732:e14114170e01

applied 'fakemono' patch by Bryan Chan scorpio@acm.org
author arpi_esp
date Tue, 08 May 2001 21:49:00 +0000
parents 7e4e014fb5a5
children 97a4bb050fae
files cfg-mplayer.h configure dec_audio.c help_mp.h mp3lib/decod386.c mp3lib/mp3.h mp3lib/sr1.c
diffstat 7 files changed, 75 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Tue May 08 21:47:51 2001 +0000
+++ b/cfg-mplayer.h	Tue May 08 21:49:00 2001 +0000
@@ -18,6 +18,9 @@
 extern int sdl_noxv;
 extern int sdl_forcexv;
 #endif
+#ifdef USE_FAKE_MONO
+extern int fakemono; // defined in dec_audio.c
+#endif
 
 extern int vo_dbpp;
 extern int osd_level;
@@ -76,6 +79,9 @@
 	{"aid", &audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
 	{"vid", &video_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
 	{"sid", &dvdsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 32},
+#ifdef USE_FAKE_MONO
+	{"stereo", &fakemono, CONF_TYPE_INT, CONF_RANGE, 0, 2},
+#endif
 
 	{"dumpfile", &stream_dump_name, CONF_TYPE_STRING, 0, 0, 0},
 	{"dumpaudio", &stream_dump_type, CONF_TYPE_FLAG, 0, 0, 1},
--- a/configure	Tue May 08 21:47:51 2001 +0000
+++ b/configure	Tue May 08 21:49:00 2001 +0000
@@ -1011,6 +1011,13 @@
    buffer problems, but it seems to be useful for every soundcard drivers) */
 #define ALSA_TIMER
 
+/* Undefine this if you don't want to select mono audio (left or right)
+   with a stereo MPEG layer 2/3 audio stream. The command-line option
+   -stereo has three possible values (0 for stereo, 1 for left-only, 2 for
+   right-only), with 0 being the default.
+   */
+#define USE_FAKE_MONO
+
 /* Undefine this if your soundcard driver has no working select().
    If you have kernel Oops, player hangups, or just no audio, you should
    try to recompile MPlayer with this option disabled! */
--- a/dec_audio.c	Tue May 08 21:47:51 2001 +0000
+++ b/dec_audio.c	Tue May 08 21:49:00 2001 +0000
@@ -6,6 +6,10 @@
 
 extern int verbose; // defined in mplayer.c
 
+#ifdef USE_FAKE_MONO
+int fakemono=0;
+#endif
+
 #include "stream.h"
 #include "demuxer.h"
 
@@ -157,7 +161,11 @@
 }
 case 1: {
   // MPEG Audio:
+#ifdef USE_FAKE_MONO
+  MP3_Init(fakemono);
+#else
   MP3_Init();
+#endif
   MP3_samplerate=MP3_channels=0;
 //  printf("[\n");
   sh_audio->a_buffer_len=MP3_DecodeFrame(sh_audio->a_buffer,-1);
--- a/help_mp.h	Tue May 08 21:47:51 2001 +0000
+++ b/help_mp.h	Tue May 08 21:49:00 2001 +0000
@@ -25,6 +25,9 @@
 #else
 "    -alsa           enable timing code (works better with ALSA)\n"
 #endif
+#ifdef USE_FAKE_MONO
+"    -stereo         select MPEG1 stereo output (0:stereo 1:left 2:right)\n"
+#endif
 "    -aid <id>       select audio channel [MPG: 0-31  AVI: 1-99]\n"
 "    -vid <id>       select video channel [MPG: 0-15  AVI:  -- ]\n"
 "    -fps <value>    force frame rate (if value is wrong in the header)\n"
--- a/mp3lib/decod386.c	Tue May 08 21:47:51 2001 +0000
+++ b/mp3lib/decod386.c	Tue May 08 21:49:00 2001 +0000
@@ -72,6 +72,40 @@
 }
 
 
+#ifdef USE_FAKE_MONO
+static int synth_1to1_l(real *bandPtr,int channel,unsigned char *out,int *pnt)
+{
+  int i,ret;
+
+  ret = synth_1to1(bandPtr,channel,out,pnt);
+  out = out + *pnt - 128;
+
+  for(i=0;i<32;i++) {
+    ((short *)out)[1] = ((short *)out)[0];
+    out+=4;
+  }
+
+  return ret;
+}
+
+
+static int synth_1to1_r(real *bandPtr,int channel,unsigned char *out,int *pnt)
+{
+  int i,ret;
+
+  ret = synth_1to1(bandPtr,channel,out,pnt);
+  out = out + *pnt - 128;
+
+  for(i=0;i<32;i++) {
+    ((short *)out)[0] = ((short *)out)[1];
+    out+=4;
+  }
+
+  return ret;
+}
+#endif
+
+
 static int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
 {
   static real buffs[2][2][0x110];
--- a/mp3lib/mp3.h	Tue May 08 21:47:51 2001 +0000
+++ b/mp3lib/mp3.h	Tue May 08 21:49:00 2001 +0000
@@ -1,7 +1,11 @@
 /* MP3 Player Library 2.0      (C) 1999 A'rpi/Astral&ESP-team  */
 
 /* decoder level: */
+#ifdef USE_FAKE_MONO
+extern void MP3_Init(int fakemono);
+#else
 extern void MP3_Init();
+#endif
 extern int MP3_Open(char *filename,int buffsize);
 extern void MP3_SeekFrame(int num,int dir);
 extern void MP3_SeekForward(int num);
--- a/mp3lib/sr1.c	Tue May 08 21:47:51 2001 +0000
+++ b/mp3lib/sr1.c	Tue May 08 21:49:00 2001 +0000
@@ -348,7 +348,11 @@
 static int tables_done_flag=0;
 
 // Init decoder tables.  Call first, once!
+#ifdef USE_FAKE_MONO
+void MP3_Init(int fakemono){
+#else
 void MP3_Init(){
+#endif
     _CpuID=CpuDetect();
     _i586=ipentium();
 #ifdef HAVE_3DNOW
@@ -362,7 +366,16 @@
 #endif
 
     make_decode_tables(outscale);
+#ifdef USE_FAKE_MONO
+    if (fakemono == 1)
+        fr.synth=synth_1to1_l;
+    else if (fakemono == 2)
+        fr.synth=synth_1to1_r;
+    else
+        fr.synth=synth_1to1;
+#else
     fr.synth=synth_1to1;
+#endif
     fr.synth_mono=synth_1to1_mono2stereo;
     fr.down_sample=0;
     fr.down_sample_sblimit = SBLIMIT>>(fr.down_sample);