[MPlayer-dev-eng] [PATCH] af should request format instead of failing

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Dec 17 19:24:53 CET 2004


Hi,
> currently audio filters fail (AF_ERROR) when they get an input
> format they do not support instead of requesting a working one.
> The following patch changes this.
> Now I'd like to know: did I miss something or was whoever coded this
> really as clueless as it seems?
> If you don't speak up I will probably apply tomorrow.

Oh well, the usual problem struck ;-). Here is the patch...

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libaf/af_extrastereo.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_extrastereo.c,v
retrieving revision 1.2
diff -u -r1.2 af_extrastereo.c
--- libaf/af_extrastereo.c	10 Oct 2004 14:20:42 -0000	1.2
+++ libaf/af_extrastereo.c	17 Dec 2004 18:16:12 -0000
@@ -35,10 +35,6 @@
     // Sanity check
     if(!arg) return AF_ERROR;
     
-    if(((af_data_t*)arg)->format != (AF_FORMAT_SI | AF_FORMAT_NE) ||
-       (((af_data_t*)arg)->nch != 2))
-       return AF_ERROR;
-
     af->data->rate   = ((af_data_t*)arg)->rate;
     af->data->nch    = 2;
     af->data->format = AF_FORMAT_SI | AF_FORMAT_NE;
Index: libaf/af_hrtf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_hrtf.c,v
retrieving revision 1.1
diff -u -r1.1 af_hrtf.c
--- libaf/af_hrtf.c	20 Nov 2004 14:40:52 -0000	1.1
+++ libaf/af_hrtf.c	17 Dec 2004 18:16:13 -0000
@@ -108,21 +108,15 @@
     case AF_CONTROL_REINIT:
 	af->data->rate   = ((af_data_t*)arg)->rate;
 	if(af->data->rate != 48000) {
-	    af_msg(AF_MSG_ERROR,
-		   "[hrtf] ERROR: Sampling rate is not 48000 Hz (%d)!\n",
-		   af->data->rate);
-	    return AF_ERROR;
+	    af->data->rate = 48000;
 	}
 	af->data->nch    = ((af_data_t*)arg)->nch;
 	if(af->data->nch < 5) {
-	    af_msg(AF_MSG_ERROR,
-		   "[hrtf] ERROR: Insufficient channels (%d < 5).\n",
-		   af->data->nch);
-	    return AF_ERROR;
+	    af->data->nch = 5;
 	}
 	af->data->format = AF_FORMAT_SI | AF_FORMAT_NE;
 	af->data->bps    = 2;
-	return AF_OK;
+	return af_test_output(af, (af_data_t*)arg);
     case AF_CONTROL_COMMAND_LINE:
 	sscanf((char*)arg, "%c", &mode);
 	switch(mode) {
Index: libaf/af_lavcresample.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_lavcresample.c,v
retrieving revision 1.3
diff -u -r1.3 af_lavcresample.c
--- libaf/af_lavcresample.c	3 Nov 2004 01:53:56 -0000	1.3
+++ libaf/af_lavcresample.c	17 Dec 2004 18:16:13 -0000
@@ -49,10 +49,8 @@
     if((af->data->rate == data->rate) || (af->data->rate == 0))
         return AF_DETACH;
 
-    if(data->format != (AF_FORMAT_SI | AF_FORMAT_NE) || data->nch > CHANS)
-       return AF_ERROR;
-
     af->data->nch    = data->nch;
+    if (af->data->nch > CHANS) af->data->nch = CHANS;
     af->data->format = AF_FORMAT_SI | AF_FORMAT_NE;
     af->data->bps    = 2;
     g= ff_gcd(af->data->rate, data->rate);
@@ -63,7 +61,7 @@
     if(s->avrctx) av_resample_close(s->avrctx);
     s->avrctx= av_resample_init(af->mul.n, /*in_rate*/af->mul.d, s->filter_length, s->phase_shift, s->linear, s->cutoff);
 
-    return AF_OK;
+    return af_test_output(af, (af_data_t*)arg);
   case AF_CONTROL_COMMAND_LINE:{
     sscanf((char*)arg,"%d:%d:%d:%d:%lf", &af->data->rate, &s->filter_length, &s->linear, &s->phase_shift, &s->cutoff);
     if(s->cutoff <= 0.0) s->cutoff= max(1.0 - 1.0/s->filter_length, 0.80);
Index: libaf/af_sweep.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_sweep.c,v
retrieving revision 1.1
diff -u -r1.1 af_sweep.c
--- libaf/af_sweep.c	21 Oct 2004 12:10:55 -0000	1.1
+++ libaf/af_sweep.c	17 Dec 2004 18:16:13 -0000
@@ -24,15 +24,12 @@
 
   switch(cmd){
   case AF_CONTROL_REINIT:
-    if(data->format != (AF_FORMAT_SI | AF_FORMAT_NE))
-       return AF_ERROR;
-
     af->data->nch    = data->nch;
     af->data->format = AF_FORMAT_SI | AF_FORMAT_NE;
     af->data->bps    = 2;
     af->data->rate   = data->rate;
 
-    return AF_OK;
+    return af_test_output(af, (af_data_t*)arg);
   case AF_CONTROL_COMMAND_LINE:
     sscanf((char*)arg,"%lf", &s->delta);
     return AF_OK;
Index: libaf/af_volnorm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_volnorm.c,v
retrieving revision 1.2
diff -u -r1.2 af_volnorm.c
--- libaf/af_volnorm.c	10 Oct 2004 14:20:42 -0000	1.2
+++ libaf/af_volnorm.c	17 Dec 2004 18:16:14 -0000
@@ -79,10 +79,6 @@
     af->data->rate   = ((af_data_t*)arg)->rate;
     af->data->nch    = ((af_data_t*)arg)->nch;
     
-    if(((af_data_t*)arg)->format != (AF_FORMAT_F | AF_FORMAT_NE) &&
-       ((af_data_t*)arg)->format != (AF_FORMAT_SI | AF_FORMAT_NE))
-       return AF_ERROR;
-    
     if(((af_data_t*)arg)->format == (AF_FORMAT_SI | AF_FORMAT_NE)){
       af->data->format = AF_FORMAT_SI | AF_FORMAT_NE;
       af->data->bps    = 2;


More information about the MPlayer-dev-eng mailing list