Commit a994f861 authored by Justin Ruggles's avatar Justin Ruggles Committed by Michael Niedermayer

iir: change filter type if/else to a switch.

Simplifies error handling and makes it easier to add additional filter types.
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
(cherry picked from commit 0361d13c)
parent aa226b24
...@@ -164,6 +164,7 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc, ...@@ -164,6 +164,7 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
float stopband, float ripple) float stopband, float ripple)
{ {
FFIIRFilterCoeffs *c; FFIIRFilterCoeffs *c;
int ret = 0;
if (order <= 0 || order > MAXORDER || cutoff_ratio >= 1.0) if (order <= 0 || order > MAXORDER || cutoff_ratio >= 1.0)
return NULL; return NULL;
...@@ -176,22 +177,22 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc, ...@@ -176,22 +177,22 @@ av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
init_fail); init_fail);
c->order = order; c->order = order;
if (filt_type == FF_FILTER_TYPE_BUTTERWORTH) { switch (filt_type) {
if (butterworth_init_coeffs(avc, c, filt_mode, order, cutoff_ratio, case FF_FILTER_TYPE_BUTTERWORTH:
stopband)) { ret = butterworth_init_coeffs(avc, c, filt_mode, order, cutoff_ratio,
goto init_fail; stopband);
} break;
} else if (filt_type == FF_FILTER_TYPE_BIQUAD) { case FF_FILTER_TYPE_BIQUAD:
if (biquad_init_coeffs(avc, c, filt_mode, order, cutoff_ratio, ret = biquad_init_coeffs(avc, c, filt_mode, order, cutoff_ratio,
stopband)) { stopband);
goto init_fail; break;
} default:
} else {
av_log(avc, AV_LOG_ERROR, "filter type is not currently implemented\n"); av_log(avc, AV_LOG_ERROR, "filter type is not currently implemented\n");
goto init_fail; goto init_fail;
} }
return c; if (!ret)
return c;
init_fail: init_fail:
ff_iir_filter_free_coeffs(c); ff_iir_filter_free_coeffs(c);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment