changeset 14213:3c56b18bbb0c

Make filters request a supported input format instead of failing.
author reimar
date Wed, 22 Dec 2004 00:12:00 +0000
parents 540903a59fc0
children b13b17e0640a
files libaf/af_extrastereo.c libaf/af_hrtf.c libaf/af_lavcresample.c libaf/af_sweep.c libaf/af_volnorm.c
diffstat 5 files changed, 12 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_extrastereo.c	Tue Dec 21 23:26:45 2004 +0000
+++ b/libaf/af_extrastereo.c	Wed Dec 22 00:12:00 2004 +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;
--- a/libaf/af_hrtf.c	Tue Dec 21 23:26:45 2004 +0000
+++ b/libaf/af_hrtf.c	Wed Dec 22 00:12:00 2004 +0000
@@ -108,6 +108,8 @@
     case AF_CONTROL_REINIT:
 	af->data->rate   = ((af_data_t*)arg)->rate;
 	if(af->data->rate != 48000) {
+	    // automatic samplerate adjustment in the filter chain
+	    // is not yet supported.
 	    af_msg(AF_MSG_ERROR,
 		   "[hrtf] ERROR: Sampling rate is not 48000 Hz (%d)!\n",
 		   af->data->rate);
@@ -115,14 +117,11 @@
 	}
 	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) {
--- a/libaf/af_lavcresample.c	Tue Dec 21 23:26:45 2004 +0000
+++ b/libaf/af_lavcresample.c	Wed Dec 22 00:12:00 2004 +0000
@@ -43,16 +43,15 @@
   int g;
   af_resample_t* s   = (af_resample_t*)af->setup; 
   af_data_t *data= (af_data_t*)arg;
+  int out_rate, test_output_res; // helpers for checking input format
 
   switch(cmd){
   case AF_CONTROL_REINIT:
     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 +62,12 @@
     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;
+    // hack to make af_test_output ignore the samplerate change
+    out_rate = af->data->rate;
+    af->data->rate = data->rate;
+    test_output_res = af_test_output(af, (af_data_t*)arg);
+    af->data->rate = out_rate;
+    return test_output_res;
   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);
--- a/libaf/af_sweep.c	Tue Dec 21 23:26:45 2004 +0000
+++ b/libaf/af_sweep.c	Wed Dec 22 00:12:00 2004 +0000
@@ -24,9 +24,6 @@
 
   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;
--- a/libaf/af_volnorm.c	Tue Dec 21 23:26:45 2004 +0000
+++ b/libaf/af_volnorm.c	Wed Dec 22 00:12:00 2004 +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;