Revision d42dc217 libavcodec/iirfilter.c

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)

Also available in: Unified diff