annotate ffmpeg/libavcodec/celp_filters.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * various filters for CELP-based codecs
yading@10 3 *
yading@10 4 * Copyright (c) 2008 Vladimir Voroshilov
yading@10 5 *
yading@10 6 * This file is part of FFmpeg.
yading@10 7 *
yading@10 8 * FFmpeg is free software; you can redistribute it and/or
yading@10 9 * modify it under the terms of the GNU Lesser General Public
yading@10 10 * License as published by the Free Software Foundation; either
yading@10 11 * version 2.1 of the License, or (at your option) any later version.
yading@10 12 *
yading@10 13 * FFmpeg is distributed in the hope that it will be useful,
yading@10 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 16 * Lesser General Public License for more details.
yading@10 17 *
yading@10 18 * You should have received a copy of the GNU Lesser General Public
yading@10 19 * License along with FFmpeg; if not, write to the Free Software
yading@10 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 21 */
yading@10 22
yading@10 23 #ifndef AVCODEC_CELP_FILTERS_H
yading@10 24 #define AVCODEC_CELP_FILTERS_H
yading@10 25
yading@10 26 #include <stdint.h>
yading@10 27
yading@10 28 typedef struct CELPFContext {
yading@10 29 /**
yading@10 30 * LP synthesis filter.
yading@10 31 * @param[out] out pointer to output buffer
yading@10 32 * - the array out[-filter_length, -1] must
yading@10 33 * contain the previous result of this filter
yading@10 34 * @param filter_coeffs filter coefficients.
yading@10 35 * @param in input signal
yading@10 36 * @param buffer_length amount of data to process
yading@10 37 * @param filter_length filter length (10 for 10th order LP filter). Must be
yading@10 38 * greater than 4 and even.
yading@10 39 *
yading@10 40 * @note Output buffer must contain filter_length samples of past
yading@10 41 * speech data before pointer.
yading@10 42 *
yading@10 43 * Routine applies 1/A(z) filter to given speech data.
yading@10 44 */
yading@10 45 void (*celp_lp_synthesis_filterf)(float *out, const float *filter_coeffs,
yading@10 46 const float *in, int buffer_length,
yading@10 47 int filter_length);
yading@10 48
yading@10 49 /**
yading@10 50 * LP zero synthesis filter.
yading@10 51 * @param[out] out pointer to output buffer
yading@10 52 * @param filter_coeffs filter coefficients.
yading@10 53 * @param in input signal
yading@10 54 * - the array in[-filter_length, -1] must
yading@10 55 * contain the previous input of this filter
yading@10 56 * @param buffer_length amount of data to process (should be a multiple of eight)
yading@10 57 * @param filter_length filter length (10 for 10th order LP filter;
yading@10 58 * should be a multiple of two)
yading@10 59 *
yading@10 60 * @note Output buffer must contain filter_length samples of past
yading@10 61 * speech data before pointer.
yading@10 62 *
yading@10 63 * Routine applies A(z) filter to given speech data.
yading@10 64 */
yading@10 65 void (*celp_lp_zero_synthesis_filterf)(float *out, const float *filter_coeffs,
yading@10 66 const float *in, int buffer_length,
yading@10 67 int filter_length);
yading@10 68
yading@10 69 }CELPFContext;
yading@10 70
yading@10 71 /**
yading@10 72 * Initialize CELPFContext.
yading@10 73 */
yading@10 74 void ff_celp_filter_init(CELPFContext *c);
yading@10 75 void ff_celp_filter_init_mips(CELPFContext *c);
yading@10 76
yading@10 77 /**
yading@10 78 * Circularly convolve fixed vector with a phase dispersion impulse
yading@10 79 * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
yading@10 80 * @param fc_out vector with filter applied
yading@10 81 * @param fc_in source vector
yading@10 82 * @param filter phase filter coefficients
yading@10 83 *
yading@10 84 * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
yading@10 85 *
yading@10 86 * @note fc_in and fc_out should not overlap!
yading@10 87 */
yading@10 88 void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in,
yading@10 89 const int16_t *filter, int len);
yading@10 90
yading@10 91 /**
yading@10 92 * Add an array to a rotated array.
yading@10 93 *
yading@10 94 * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
yading@10 95 *
yading@10 96 * @param out result vector
yading@10 97 * @param in samples to be added unfiltered
yading@10 98 * @param lagged samples to be rotated, multiplied and added
yading@10 99 * @param lag lagged vector delay in the range [0, n]
yading@10 100 * @param fac scalefactor for lagged samples
yading@10 101 * @param n number of samples
yading@10 102 */
yading@10 103 void ff_celp_circ_addf(float *out, const float *in,
yading@10 104 const float *lagged, int lag, float fac, int n);
yading@10 105
yading@10 106 /**
yading@10 107 * LP synthesis filter.
yading@10 108 * @param[out] out pointer to output buffer
yading@10 109 * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
yading@10 110 * @param in input signal
yading@10 111 * @param buffer_length amount of data to process
yading@10 112 * @param filter_length filter length (10 for 10th order LP filter)
yading@10 113 * @param stop_on_overflow 1 - return immediately if overflow occurs
yading@10 114 * 0 - ignore overflows
yading@10 115 * @param shift the result is shifted right by this value
yading@10 116 * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
yading@10 117 *
yading@10 118 * @return 1 if overflow occurred, 0 - otherwise
yading@10 119 *
yading@10 120 * @note Output buffer must contain filter_length samples of past
yading@10 121 * speech data before pointer.
yading@10 122 *
yading@10 123 * Routine applies 1/A(z) filter to given speech data.
yading@10 124 */
yading@10 125 int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
yading@10 126 const int16_t *in, int buffer_length,
yading@10 127 int filter_length, int stop_on_overflow,
yading@10 128 int shift, int rounder);
yading@10 129
yading@10 130 /**
yading@10 131 * LP synthesis filter.
yading@10 132 * @param[out] out pointer to output buffer
yading@10 133 * - the array out[-filter_length, -1] must
yading@10 134 * contain the previous result of this filter
yading@10 135 * @param filter_coeffs filter coefficients.
yading@10 136 * @param in input signal
yading@10 137 * @param buffer_length amount of data to process
yading@10 138 * @param filter_length filter length (10 for 10th order LP filter). Must be
yading@10 139 * greater than 4 and even.
yading@10 140 *
yading@10 141 * @note Output buffer must contain filter_length samples of past
yading@10 142 * speech data before pointer.
yading@10 143 *
yading@10 144 * Routine applies 1/A(z) filter to given speech data.
yading@10 145 */
yading@10 146 void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
yading@10 147 const float *in, int buffer_length,
yading@10 148 int filter_length);
yading@10 149
yading@10 150 /**
yading@10 151 * LP zero synthesis filter.
yading@10 152 * @param[out] out pointer to output buffer
yading@10 153 * @param filter_coeffs filter coefficients.
yading@10 154 * @param in input signal
yading@10 155 * - the array in[-filter_length, -1] must
yading@10 156 * contain the previous input of this filter
yading@10 157 * @param buffer_length amount of data to process
yading@10 158 * @param filter_length filter length (10 for 10th order LP filter)
yading@10 159 *
yading@10 160 * @note Output buffer must contain filter_length samples of past
yading@10 161 * speech data before pointer.
yading@10 162 *
yading@10 163 * Routine applies A(z) filter to given speech data.
yading@10 164 */
yading@10 165 void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
yading@10 166 const float *in, int buffer_length,
yading@10 167 int filter_length);
yading@10 168
yading@10 169 #endif /* AVCODEC_CELP_FILTERS_H */