Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] AnalogTV patch adding a sample rate setting



Andreas, would you mind merging this on your source?
I need to set a sampling rate of 32 KHz to get sound from the digital
capture of my Hauppauge WinTV card, which I access through the btaudio
OSS module.

I've just tested mp1e from within analogtv, but I know the settings work
with both ffmpeg and mencoder. I didn't have have and for the other
encoders either I didn't know what the setting might be /and/or I din't
even have a copy of the program (fame).

BTW, recently a btaudio module was added to ALSA. I tried it with
analogtv, both acessing the ALSA device directly (as explained in your
INSTALL guide) and through OSS emaulation with /dev/dsp. Both ways
resulted in a huge capturing performace drop. Usually mp1e only takes
3-5% of CPU usage of my AthlonXP 2000+, cpturing at 4.5 Mbit/s @ 352x576,
64 kbit/s with GOP sequence IBBPBBPBBPBB, filter 8 YUV 4:2:0 and no
deinterlacing or motion compensation (the signal is not that clean on
some channels, and it gave more problems than benefits).

Could it be an analogtv problem with the ALSA device or would it be more
due to a less tunes btaudio module for ALSA, than the old OSS one?

The patch is against 0.9.25, it applies cleanly to 0.9.26 and 0.9.27
also, but I can't use them. All I get when I try to tune an analog
channel is "can't transfer data" on the log. I didn't manage to solve
it.
This is on 1.3.4 (in fact, in all the 1.3.x series). I know the CiCaps
has changed on 1.3.x and don't know how to overcome it.


--
Javier Marcet <javier@marcet.info>
--- analogtv/analogtv.c.old	2004-01-04 19:39:20.000000000 +0100
+++ analogtv/analogtv.c	2004-02-15 12:12:13.000000000 +0100
@@ -355,6 +355,7 @@
   s.mixer_volume = 91;			// PVR default: 59343 
 
   s.audio_mode = 3;
+  s.sample_rate = 2;
   v4l = -1;
   ReaderLoopRunning = 0;
   EncoderNeeded = 0;
@@ -487,6 +488,7 @@
   *sc.mixer_device = 0;
   sc.mixer_line = -1;
   sc.audio_mode = -1;
+  sc.sample_rate = -1;
 }
 
 cPluginAnalogtv::~cPluginAnalogtv()
@@ -640,6 +642,7 @@
   else if (!strcasecmp(Name, "MPEG"))               s.mpeg = atoi(Value);
   else if (!strcasecmp(Name, "Test"))               s.test = atoi(Value);
   else if (!strcasecmp(Name, "AudioMode"))          s.audio_mode = atoi(Value);
+  else if (!strcasecmp(Name, "SampleRate"))         s.sample_rate = atoi(Value);
   else if (!strcasecmp(Name, "PsychoAnalysis"))     s.analysis = atoi(Value);
   else if (!strcasecmp(Name, "Brightness"))         s.brightness = atoi(Value);
   else if (!strcasecmp(Name, "Hue"))                s.hue = atoi(Value);
--- analogtv/i18n.c.old	2003-12-16 22:35:02.000000000 +0100
+++ analogtv/i18n.c	2004-02-15 12:45:24.000000000 +0100
@@ -194,6 +194,14 @@
     "Mono"
 };
 
+const char *samplerates[] = {
+    "22.05 KHz",
+    "32 KHz",
+    "44.1 KHz",
+    "48 KHz",
+    "96 KHz"
+};
+
 const char *analysismodes[] = {
     "Static",
     "Fast",
--- analogtv/menusetup.c.old	2003-12-16 22:35:02.000000000 +0100
+++ analogtv/menusetup.c	2004-02-15 12:26:02.000000000 +0100
@@ -427,6 +427,7 @@
     Add(new cMenuEditStrItem( tr("Setup.analogTV$OSS Mixer device"),             sx.mixer_device, MAX_DEV_NAME, allowed));
     Add(new cMenuEditStraItem(tr("Setup.analogTV$OSS Mixer input"),              &sx.mixer_line, SOUND_MIXER_NRDEVICES, SoundDevices));
     Add(new cMenuEditStraItem(tr("Setup.analogTV$Audio mode"),                   &sx.audio_mode, 4, audiomodes));
+    Add(new cMenuEditStraItem(tr("Setup.analogTV$Audio sample rate"),            &sx.sample_rate, 5, samplerates));
     Add(new cMenuEditStraItem(tr("Setup.analogTV$Psychoacoustic analysis"),      &sx.analysis, 3, analysismodes));
   }
 
@@ -800,6 +801,7 @@
   SetupStore("MPEG",             s.mpeg);
   SetupStore("Test",             s.test);
   SetupStore("AudioMode",        s.audio_mode);
+  SetupStore("SampleRate",       s.sample_rate);
   SetupStore("PsychoAnalysis",   s.analysis);
   SetupStore("Brightness",       s.brightness);
   SetupStore("Hue",              s.hue);
--- analogtv/msg.h.old	2003-11-05 22:19:41.000000000 +0100
+++ analogtv/msg.h	2004-02-15 12:26:48.000000000 +0100
@@ -24,6 +24,7 @@
 
 extern const char *SoundDevices[];
 extern const char *audiomodes[];
+extern const char *samplerates[];
 extern const char *analysismodes[];
 extern const char *loggers[];
 extern const char *encoders[];
--- analogtv/player-analogtv.c.old	2003-11-30 17:24:58.000000000 +0100
+++ analogtv/player-analogtv.c	2004-02-15 13:00:24.382200576 +0100
@@ -670,6 +670,7 @@
           fprintf(fo, "\tMotion compensation disabled\n");
 
         fprintf(fo, "\tAudio mode:%s\n", audiomodes[s.audio_mode]);
+        fprintf(fo, "\tAudio sample rate:%s\n", samplerates[s.sample_rate]);
       
       	fprintf(fo, "\tAdditional options:%s\n", MP1EOPTS);
       	fprintf(fo, "\tGOP sequence:%s\n", gops[s.gop]);
@@ -779,8 +780,17 @@
 static int action(int halt, int Apid, int Vpid)
 {
   register int    a, b, f, cc;
+  auto     float  ar;
   auto     char   cmd[512], s0[64], s1[64], s3[64];
 
+  switch (s.sample_rate) {
+    case 0 : ar = 22.05; break;
+    case 1 : ar = 32; break;
+    case 2 : ar = 44.1; break;
+    case 3 : ar = 48; break;
+    case 4 : ar = 96; break;
+  }
+
   switch (s.mpeg_encoder) {
     case MP1E      : *s0 = 0;
                      if (s.debug)
@@ -820,7 +830,7 @@
                        case 2 : a += 20; break;
                      }
 
-                     sprintf(cmd, "mp1e %s%s%s%s -t %d -g %s -p %s -c %s -x %s -d %d -a %d -b %d -B %d%s -r %d,%d -s %s -F %d%s%s%s%s -o %s &",
+                     sprintf(cmd, "mp1e %s%s%s%s -t %d -g %s -p %s -c %s -x %s -d %d -a %d -b %d -B %d%s -r %d,%d -s %s -S %2.1f -F %d%s%s%s%s -o %s &",
                       /* -j */ halt ? "-j " : "",
                       /* -l */ wide ? "-l " : "",
                                MP1EOPTS,
@@ -837,6 +847,7 @@
                       /* -v */ s0,
                       /* -r */ s.mixer_line, s.mixer_volume,
                       /* -s */ imagesizes[s.image_size],
+                      /* -S */ ar,
                       /* -F */ f,
                       /* -G */ s1,
                       /* -R */ s3,
@@ -846,10 +857,11 @@
                      break;
 
     case FFMPEGPES :
-    case FFMPEGTS  : sprintf(cmd, "ffmpeg -f %s -s %s -ad %s:%d -vd %s -ac %d -b %d -ab %d -y -hq -re -title %s -author %s -copyright %s -comment %s -aspect %s -tvstd %s %s%s &",
+    case FFMPEGTS  : sprintf(cmd, "ffmpeg -f %s -s %s -ad %s:%d -ar %2.1f -vd %s -ac %d -b %d -ab %d -y -hq -re -title %s -author %s -copyright %s -comment %s -aspect %s -tvstd %s %s%s &",
                       /* -f           */ (s.mpeg_encoder == FFMPEGTS) ? "mpegts" : "mpeg1video",
                       /* -s           */ imagesizes[s.image_size],
                       /* -ad          */ s.audio_device, s.mixer_line,
+                      /* -ar          */ ar,
                       /* -vd          */ video_device,
                       /* -ac          */ !s.audio_mode ? 2 : 1,
                       /* -b           */ s.video_bit_rate * 100,
@@ -883,7 +895,7 @@
                      break;
 
     case NVRECPES  :
-    case NVRECTS   : sprintf(cmd, "ffmpegrec%s -d %s%s -mixvol %s:%s:%d -v %s -w %d -h %d -norm %s -input %s -ff %s -vc mpeg1video -ac mp2 -vb %d -ab %d -vg %d -o %s &",
+    case NVRECTS   : sprintf(cmd, "ffmpegrec%s -d %s%s -mixvol %s:%s:%d -v %s -w %d -h %d -norm %s -input %s -ff %s -vc mpeg1video -ac mp2 -vb %d -ab %d -ar %2.1f -vg %d -o %s &",
                       /* -deint     */ s.deinterlace ? " -deint bob" : "",
                       /* -d         */ s.audio_device,
                       /* -s         */ s.audio_mode ? "" : " -s",
@@ -896,6 +908,7 @@
                       /* -ff        */ "vcd", // FIXME (s.mpeg_encoder == NVRECTS) ? "mpegts" : "mpeg1video",
                       /* -vb        */ s.video_bit_rate * 100,
                       /* -ab        */ s.audio_mode ? s.audio_bit_rate : s.audio_bit_rate * 2,
+                      /* -ar        */ ar,
                       /* -vg        */ (s.gop == 1) ? 0 : 25,
                       /* -o         */ FIFO);
 
@@ -1514,6 +1527,7 @@
              strcmp(sc.mixer_device, s.mixer_device);
              sc.mixer_volume   = s.mixer_volume;
              sc.audio_mode     = s.audio_mode;
+             sc.sample_rate    = s.sample_rate;
              break;
   
     case 2 : sc.mpeg_encoder   = s.mpeg_encoder;
@@ -1571,5 +1585,6 @@
          (strcmp(s.mixer_device, sc.mixer_device)) ||
          (s.mixer_line     != sc.mixer_line)       ||
          (s.mixer_volume   != sc.mixer_volume)     ||
-         (s.audio_mode     != sc.audio_mode));
+         (s.audio_mode     != sc.audio_mode)       ||
+         (s.sample_rate    != sc.sample_rate));
 }
--- analogtv/player-analogtv.h.old	2003-11-30 17:24:58.000000000 +0100
+++ analogtv/player-analogtv.h	2004-02-15 12:22:48.000000000 +0100
@@ -337,6 +337,7 @@
   int  mixer_line;      // OSS Audio-Eingang (Line, CD, Video ...)
   int  mixer_volume;
   int  audio_mode;      // Mono/Stereo
+  int  sample_rate;     // Mono/Stereo
   int  analysis;
 
   ///> Misc:

Home | Main Index | Thread Index