[MPlayer-cvslog] CVS: main/libaf af.c,1.37,1.38

Reimar Döffinger CVS syncmail at mplayerhq.hu
Mon Jan 3 15:05:40 CET 2005


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libaf
In directory mail:/var2/tmp/cvs-serv5974/libaf

Modified Files:
	af.c 
Log Message:
Use lavcresample only when libavcodec is compiled in.


Index: af.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- af.c	1 Jan 2005 18:46:56 -0000	1.37
+++ af.c	3 Jan 2005 14:05:38 -0000	1.38
@@ -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