yading@10: /* yading@10: * various filters for CELP-based codecs yading@10: * yading@10: * Copyright (c) 2008 Vladimir Voroshilov yading@10: * yading@10: * This file is part of FFmpeg. yading@10: * yading@10: * FFmpeg is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * FFmpeg is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with FFmpeg; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: #ifndef AVCODEC_CELP_FILTERS_H yading@10: #define AVCODEC_CELP_FILTERS_H yading@10: yading@10: #include yading@10: yading@10: typedef struct CELPFContext { yading@10: /** yading@10: * LP synthesis filter. yading@10: * @param[out] out pointer to output buffer yading@10: * - the array out[-filter_length, -1] must yading@10: * contain the previous result of this filter yading@10: * @param filter_coeffs filter coefficients. yading@10: * @param in input signal yading@10: * @param buffer_length amount of data to process yading@10: * @param filter_length filter length (10 for 10th order LP filter). Must be yading@10: * greater than 4 and even. yading@10: * yading@10: * @note Output buffer must contain filter_length samples of past yading@10: * speech data before pointer. yading@10: * yading@10: * Routine applies 1/A(z) filter to given speech data. yading@10: */ yading@10: void (*celp_lp_synthesis_filterf)(float *out, const float *filter_coeffs, yading@10: const float *in, int buffer_length, yading@10: int filter_length); yading@10: yading@10: /** yading@10: * LP zero synthesis filter. yading@10: * @param[out] out pointer to output buffer yading@10: * @param filter_coeffs filter coefficients. yading@10: * @param in input signal yading@10: * - the array in[-filter_length, -1] must yading@10: * contain the previous input of this filter yading@10: * @param buffer_length amount of data to process (should be a multiple of eight) yading@10: * @param filter_length filter length (10 for 10th order LP filter; yading@10: * should be a multiple of two) yading@10: * yading@10: * @note Output buffer must contain filter_length samples of past yading@10: * speech data before pointer. yading@10: * yading@10: * Routine applies A(z) filter to given speech data. yading@10: */ yading@10: void (*celp_lp_zero_synthesis_filterf)(float *out, const float *filter_coeffs, yading@10: const float *in, int buffer_length, yading@10: int filter_length); yading@10: yading@10: }CELPFContext; yading@10: yading@10: /** yading@10: * Initialize CELPFContext. yading@10: */ yading@10: void ff_celp_filter_init(CELPFContext *c); yading@10: void ff_celp_filter_init_mips(CELPFContext *c); yading@10: yading@10: /** yading@10: * Circularly convolve fixed vector with a phase dispersion impulse yading@10: * response filter (D.6.2 of G.729 and 6.1.5 of AMR). yading@10: * @param fc_out vector with filter applied yading@10: * @param fc_in source vector yading@10: * @param filter phase filter coefficients yading@10: * yading@10: * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] } yading@10: * yading@10: * @note fc_in and fc_out should not overlap! yading@10: */ yading@10: void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in, yading@10: const int16_t *filter, int len); yading@10: yading@10: /** yading@10: * Add an array to a rotated array. yading@10: * yading@10: * out[k] = in[k] + fac * lagged[k-lag] with wrap-around yading@10: * yading@10: * @param out result vector yading@10: * @param in samples to be added unfiltered yading@10: * @param lagged samples to be rotated, multiplied and added yading@10: * @param lag lagged vector delay in the range [0, n] yading@10: * @param fac scalefactor for lagged samples yading@10: * @param n number of samples yading@10: */ yading@10: void ff_celp_circ_addf(float *out, const float *in, yading@10: const float *lagged, int lag, float fac, int n); yading@10: yading@10: /** yading@10: * LP synthesis filter. yading@10: * @param[out] out pointer to output buffer yading@10: * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000) yading@10: * @param in input signal yading@10: * @param buffer_length amount of data to process yading@10: * @param filter_length filter length (10 for 10th order LP filter) yading@10: * @param stop_on_overflow 1 - return immediately if overflow occurs yading@10: * 0 - ignore overflows yading@10: * @param shift the result is shifted right by this value yading@10: * @param rounder the amount to add for rounding (usually 0x800 or 0xfff) yading@10: * yading@10: * @return 1 if overflow occurred, 0 - otherwise yading@10: * yading@10: * @note Output buffer must contain filter_length samples of past yading@10: * speech data before pointer. yading@10: * yading@10: * Routine applies 1/A(z) filter to given speech data. yading@10: */ yading@10: int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, yading@10: const int16_t *in, int buffer_length, yading@10: int filter_length, int stop_on_overflow, yading@10: int shift, int rounder); yading@10: yading@10: /** yading@10: * LP synthesis filter. yading@10: * @param[out] out pointer to output buffer yading@10: * - the array out[-filter_length, -1] must yading@10: * contain the previous result of this filter yading@10: * @param filter_coeffs filter coefficients. yading@10: * @param in input signal yading@10: * @param buffer_length amount of data to process yading@10: * @param filter_length filter length (10 for 10th order LP filter). Must be yading@10: * greater than 4 and even. yading@10: * yading@10: * @note Output buffer must contain filter_length samples of past yading@10: * speech data before pointer. yading@10: * yading@10: * Routine applies 1/A(z) filter to given speech data. yading@10: */ yading@10: void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, yading@10: const float *in, int buffer_length, yading@10: int filter_length); yading@10: yading@10: /** yading@10: * LP zero synthesis filter. yading@10: * @param[out] out pointer to output buffer yading@10: * @param filter_coeffs filter coefficients. yading@10: * @param in input signal yading@10: * - the array in[-filter_length, -1] must yading@10: * contain the previous input of this filter yading@10: * @param buffer_length amount of data to process yading@10: * @param filter_length filter length (10 for 10th order LP filter) yading@10: * yading@10: * @note Output buffer must contain filter_length samples of past yading@10: * speech data before pointer. yading@10: * yading@10: * Routine applies A(z) filter to given speech data. yading@10: */ yading@10: void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, yading@10: const float *in, int buffer_length, yading@10: int filter_length); yading@10: yading@10: #endif /* AVCODEC_CELP_FILTERS_H */