[MPlayer-cvslog] CVS: main/libaf af.c,1.35,1.36

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Jan 1 20:19:24 CET 2005


Hi,

On Fri, Dec 31, 2004 at 12:45:28AM -0500, D Richard Felker III wrote:
> On Mon, Dec 27, 2004 at 02:22:42PM +0100, Reimar Döffinger wrote:
> > > > > > > > CVS change done by Reimar Döffinger CVS
> > > > > > > >
> > > > > > > > Update of /cvsroot/mplayer/main/libaf
> > > > > > > > In directory mail:/var2/tmp/cvs-serv8321/libaf
> > > > > > > >
> > > > > > > > Modified Files:
> > > > > > > >  af.c
> > > > > > > > Log Message:
> > > > > > > > Use lavcresample when accuracy-optimized audio filter chain is
> > > > > > > > requested.
> > > > > > >
> > > > > > > shouldn't it be dependant on wether lavc is compiled in?
> > > > > >
> > > > > > Yes, you are right... Actually on thinking once again it was quite a
> > > > > > stupid patch. What do you think about the attached one?
> > > > >
> > > > > Hmm, I'm not sure, are there any advantages for the lavcresampler, IIRC
> > > > > the mplayer one was pretty good, but is lavc one faster?
> > > >
> > > > the mplayer one is just about the most broken resampler code i've ever
> > > > seen. it has errors that mangle the audio, sometimes dropping samples
> > > > and perhaps even desyncing which channel is which. it's also slow,
> > > > except in the ultra-low-quality "linint" mode (which is misnamed, it's
> > > > really nearest-neighbor sampling).
> > > >
> > > > the only (re)sampler i've ever seen that's as bad or worse was written
> > > > by yours truly about 5 years ago.. :)
> > > eh? you mean the SDL audio built in? =) If it's so bad, than why not remove it 
> > > and only allow resampling if mplayer is compiled with lavc (which it should 
> > > be in 99% of cases anyways)?
> > 
> > I though resample was a bit faster... Well, do you want me to change it
> > to always use lavcresample when libavcodec is compiled in? I actually
> 
> with force= set for speed, please don't use lavc!!
> i use the shitty 'linint' resampler because anything else is too
> slow..

I'd like to suggest the attached patch. Does it look okay to you? It is
a bit more complicated because I wanted it to be easy to change -
lavcresample with a filter size of 1 is hardly any slower on my system
anymore...
Also it can now use any filter to change the samplerate, regardless of
the name (it must only accept AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET)
thus opening the door for future optimizations.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libaf/af.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.c,v
retrieving revision 1.37
diff -u -r1.37 af.c
--- libaf/af.c	1 Jan 2005 18:46:56 -0000	1.37
+++ libaf/af.c	1 Jan 2005 18:57:13 -0000
@@ -380,21 +380,27 @@
     af_instance_t* af = NULL; // New filter
     // Check output frequency if not OK fix with resample
     if(s->last->data->rate!=s->output.rate){
-      if(NULL==(af=af_get(s,"lavcresample")) &&
-          NULL==(af=af_get(s,"resample"))){
+      // try to find a filter that can change samplrate
+      af = af_control_any_rev(s, AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET,
+               &(s->output.rate));
+      if (!af) {
+        char *resampler = "resample";
+#ifdef USE_LIBAVCODEC
+        if ((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_SLOW)
+          resampler = "lavcresample";
+#endif
 	if((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_SLOW){
 	  if(!strcmp(s->first->info->name,"format"))
-	    af = af_append(s,s->first,"lavcresample");
+	    af = af_append(s,s->first,resampler);
 	  else
-	    af = af_prepend(s,s->first,"lavcresample");
+	    af = af_prepend(s,s->first,resampler);
 	}		
 	else{
 	  if(!strcmp(s->last->info->name,"format"))
-	    af = af_prepend(s,s->last,"resample");
+	    af = af_prepend(s,s->last,resampler);
 	  else
-	    af = af_append(s,s->last,"resample");
+	    af = af_append(s,s->last,resampler);
 	}
-      }
       // Init the new filter
       if(!af || (AF_OK != af->control(af,AF_CONTROL_RESAMPLE_RATE,
 				      &(s->output.rate))))
@@ -402,9 +408,16 @@
       // Use lin int if the user wants fast
       if ((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_FAST) {
         char args[32];
-	sprintf(args, "%d:0:0", s->output.rate);
+	sprintf(args, "%d", s->output.rate);
+#ifdef USE_LIBAVCODEC
+	if (strcmp(resampler, "lavcresample") == 0)
+	  strcat(args, ":1");
+	else
+#endif
+	strcat(args, ":0:0");
 	af->control(af, AF_CONTROL_COMMAND_LINE, args);
       }
+      }
       if(AF_OK != af_reinit(s,af))
       	return -1;
     }	


More information about the MPlayer-cvslog mailing list