Revision d42dc217

View differences:

libavcodec/iirfilter.c
47 47
/// maximum supported filter order
48 48
#define MAXORDER 30
49 49

  
50
av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type,
50
av_cold struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
51
                                                enum IIRFilterType filt_type,
51 52
                                                    enum IIRFilterMode filt_mode,
52 53
                                                    int order, float cutoff_ratio,
53 54
                                                    float stopband, float ripple)
......
62 63
    if(order <= 1 || (order & 1) || order > MAXORDER || cutoff_ratio >= 1.0)
63 64
        return NULL;
64 65

  
65
    c = av_malloc(sizeof(FFIIRFilterCoeffs));
66
    c->cx = av_malloc(sizeof(c->cx[0]) * ((order >> 1) + 1));
67
    c->cy = av_malloc(sizeof(c->cy[0]) * order);
66
    FF_ALLOCZ_OR_GOTO(avc, c,     sizeof(FFIIRFilterCoeffs),
67
                      init_fail);
68
    FF_ALLOC_OR_GOTO (avc, c->cx, sizeof(c->cx[0]) * ((order >> 1) + 1),
69
                      init_fail);
70
    FF_ALLOC_OR_GOTO (avc, c->cy, sizeof(c->cy[0]) * order,
71
                      init_fail);
68 72
    c->order = order;
69 73

  
70 74
    wa = 2 * tan(M_PI * 0.5 * cutoff_ratio);
......
110 114
    c->gain /= 1 << order;
111 115

  
112 116
    return c;
117

  
118
init_fail:
119
    ff_iir_filter_free_coeffs(c);
120
    return NULL;
113 121
}
114 122

  
115 123
av_cold struct FFIIRFilterState* ff_iir_filter_init_state(int order)
libavcodec/iirfilter.h
49 49
/**
50 50
 * Initialize filter coefficients.
51 51
 *
52
 * @param avc          a pointer to an arbitrary struct of which the first
53
 *                     field is a pointer to an AVClass struct
52 54
 * @param filt_type    filter type (e.g. Butterworth)
53 55
 * @param filt_mode    filter mode (e.g. lowpass)
54 56
 * @param order        filter order
......
58 60
 *
59 61
 * @return pointer to filter coefficients structure or NULL if filter cannot be created
60 62
 */
61
struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(enum IIRFilterType filt_type,
63
struct FFIIRFilterCoeffs* ff_iir_filter_init_coeffs(void *avc,
64
                                                enum IIRFilterType filt_type,
62 65
                                                    enum IIRFilterMode filt_mode,
63 66
                                                    int order, float cutoff_ratio,
64 67
                                                    float stopband, float ripple);
libavcodec/psymodel.c
88 88
        cutoff_coeff = 2.0 * avctx->cutoff / avctx->sample_rate;
89 89

  
90 90
    if (cutoff_coeff)
91
    ctx->fcoeffs = ff_iir_filter_init_coeffs(FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS,
91
    ctx->fcoeffs = ff_iir_filter_init_coeffs(avctx, FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS,
92 92
                                             FILT_ORDER, cutoff_coeff, 0.0, 0.0);
93 93
    if (ctx->fcoeffs) {
94 94
        ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels);

Also available in: Unified diff