| 179 | } |
| 180 | |
| 181 | AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ |
| 182 | AVResampleContext *c= av_mallocz(sizeof(AVResampleContext)); |
| 183 | double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); |
| 184 | int phase_count= 1<<phase_shift; |
| 185 | |
| 186 | c->phase_shift= phase_shift; |
| 187 | c->phase_mask= phase_count-1; |
| 188 | c->linear= linear; |
| 189 | |
| 190 | c->filter_length= FFMAX((int)ceil(filter_size/factor), 1); |
| 191 | c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); |
| 192 | build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, WINDOW_TYPE); |
| 193 | memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); |
| 194 | c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; |
| 195 | |
| 196 | c->src_incr= out_rate; |
| 197 | c->ideal_dst_incr= c->dst_incr= in_rate * phase_count; |
| 198 | c->index= -phase_count*((c->filter_length-1)/2); |
| 199 | |
| 200 | return c; |
| 201 | } |
| 202 | |
| 203 | void av_resample_close(AVResampleContext *c){ |
| 204 | av_freep(&c->filter_bank); |
no test coverage detected