From 5e6cd8241b3cb3e45972a2a932155676522a22d8 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 22 Dec 2004 00:12:00 +0000 Subject: [PATCH] Make filters request a supported input format instead of failing. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14214 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af_extrastereo.c | 4 ---- libaf/af_hrtf.c | 9 ++++----- libaf/af_lavcresample.c | 12 ++++++++---- libaf/af_sweep.c | 3 --- libaf/af_volnorm.c | 4 ---- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/libaf/af_extrastereo.c b/libaf/af_extrastereo.c index e9b88a5705..36674e9ffa 100644 --- a/libaf/af_extrastereo.c +++ b/libaf/af_extrastereo.c @@ -35,10 +35,6 @@ static int control(struct af_instance_s* af, int cmd, void* arg) // 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; diff --git a/libaf/af_hrtf.c b/libaf/af_hrtf.c index afb3bf0991..8f302e8448 100644 --- a/libaf/af_hrtf.c +++ b/libaf/af_hrtf.c @@ -108,6 +108,8 @@ static int control(struct af_instance_s *af, int cmd, void* arg) 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 @@ static int control(struct af_instance_s *af, int cmd, void* arg) } 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) { diff --git a/libaf/af_lavcresample.c b/libaf/af_lavcresample.c index ee25fbd635..c37807865b 100644 --- a/libaf/af_lavcresample.c +++ b/libaf/af_lavcresample.c @@ -43,16 +43,15 @@ static int control(struct af_instance_s* af, int cmd, void* arg) 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 @@ static int control(struct af_instance_s* af, int cmd, void* arg) 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); diff --git a/libaf/af_sweep.c b/libaf/af_sweep.c index ee2c97ddb3..8ed84266e1 100644 --- a/libaf/af_sweep.c +++ b/libaf/af_sweep.c @@ -24,9 +24,6 @@ static int control(struct af_instance_s* af, int cmd, void* arg) 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; diff --git a/libaf/af_volnorm.c b/libaf/af_volnorm.c index cc50dfa035..c1fed6a9d3 100644 --- a/libaf/af_volnorm.c +++ b/libaf/af_volnorm.c @@ -79,10 +79,6 @@ static int control(struct af_instance_s* af, int cmd, void* arg) 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;