[FFmpeg-devel] [PATCH 06/11] Reduce interface exported by acelp_filters.c
Diego Elio Pettenò
flameeyes
Tue Jan 25 02:29:39 CET 2011
Mark ff_acelp_interp_filter as static to the unit.
Remove ff_acelp_interpolate (the integer version) since the code only ever
uses the floating-point version.
Remove ff_acelp_high_pass_filter as it's never used.
---
libavcodec/acelp_filters.c | 66 ++++++-------------------------------------
libavcodec/acelp_filters.h | 47 +------------------------------
2 files changed, 11 insertions(+), 102 deletions(-)
diff --git a/libavcodec/acelp_filters.c b/libavcodec/acelp_filters.c
index 31f0e86..1a6e3a2 100644
--- a/libavcodec/acelp_filters.c
+++ b/libavcodec/acelp_filters.c
@@ -25,7 +25,16 @@
#include "avcodec.h"
#include "acelp_filters.h"
-const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */
+/**
+ * low-pass Finite Impulse Response filter coefficients.
+ *
+ * Hamming windowed sinc filter with cutoff freq 3/40 of the sampling freq,
+ * the coefficients are scaled by 2^15.
+ * This array only contains the right half of the filter.
+ * This filter is likely identical to the one used in G.729, though this
+ * could not be determined from the original comments with certainity.
+ */
+static const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */
29443, 28346, 25207, 20449, 14701, 8693,
3143, -1352, -4402, -5865, -5850, -4673,
-2783, -672, 1211, 2536, 3130, 2991,
@@ -39,40 +48,6 @@ const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */
0,
};
-void ff_acelp_interpolate(int16_t* out, const int16_t* in,
- const int16_t* filter_coeffs, int precision,
- int frac_pos, int filter_length, int length)
-{
- int n, i;
-
- assert(frac_pos >= 0 && frac_pos < precision);
-
- for (n = 0; n < length; n++) {
- int idx = 0;
- int v = 0x4000;
-
- for (i = 0; i < filter_length;) {
-
- /* The reference G.729 and AMR fixed point code performs clipping after
- each of the two following accumulations.
- Since clipping affects only the synthetic OVERFLOW test without
- causing an int type overflow, it was moved outside the loop. */
-
- /* R(x):=ac_v[-k+x]
- v += R(n-i)*ff_acelp_interp_filter(t+6i)
- v += R(n+i+1)*ff_acelp_interp_filter(6-t+6i) */
-
- v += in[n + i] * filter_coeffs[idx + frac_pos];
- idx += precision;
- i++;
- v += in[n - i] * filter_coeffs[idx - frac_pos];
- }
- if (av_clip_int16(v >> 15) != (v >> 15))
- av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n");
- out[n] = v >> 15;
- }
-}
-
void ff_acelp_interpolatef(float *out, const float *in,
const float *filter_coeffs, int precision,
int frac_pos, int filter_length, int length)
@@ -93,27 +68,6 @@ void ff_acelp_interpolatef(float *out, const float *in,
}
}
-
-void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
- const int16_t* in, int length)
-{
- int i;
- int tmp;
-
- for (i = 0; i < length; i++) {
- tmp = (hpf_f[0]* 15836LL) >> 13;
- tmp += (hpf_f[1]* -7667LL) >> 13;
- tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]);
-
- /* With "+0x800" rounding, clipping is needed
- for ALGTHM and SPEECH tests. */
- out[i] = av_clip_int16((tmp + 0x800) >> 12);
-
- hpf_f[1] = hpf_f[0];
- hpf_f[0] = tmp;
- }
-}
-
void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
const float zero_coeffs[2],
const float pole_coeffs[2],
diff --git a/libavcodec/acelp_filters.h b/libavcodec/acelp_filters.h
index 0b1ccf4..2114f2f 100644
--- a/libavcodec/acelp_filters.h
+++ b/libavcodec/acelp_filters.h
@@ -26,18 +26,7 @@
#include <stdint.h>
/**
- * low-pass Finite Impulse Response filter coefficients.
- *
- * Hamming windowed sinc filter with cutoff freq 3/40 of the sampling freq,
- * the coefficients are scaled by 2^15.
- * This array only contains the right half of the filter.
- * This filter is likely identical to the one used in G.729, though this
- * could not be determined from the original comments with certainity.
- */
-extern const int16_t ff_acelp_interp_filter[61];
-
-/**
- * Generic FIR interpolation routine.
+ * Floating point FIR interpolation routine.
* @param[out] out buffer for interpolated data
* @param in input data
* @param filter_coeffs interpolation filter coefficients (0.15)
@@ -51,44 +40,10 @@ extern const int16_t ff_acelp_interp_filter[61];
* See ff_acelp_interp_filter for an example.
*
*/
-void ff_acelp_interpolate(int16_t* out, const int16_t* in,
- const int16_t* filter_coeffs, int precision,
- int frac_pos, int filter_length, int length);
-
-/**
- * Floating point version of ff_acelp_interpolate()
- */
void ff_acelp_interpolatef(float *out, const float *in,
const float *filter_coeffs, int precision,
int frac_pos, int filter_length, int length);
-
-/**
- * high-pass filtering and upscaling (4.2.5 of G.729).
- * @param[out] out output buffer for filtered speech data
- * @param[in,out] hpf_f past filtered data from previous (2 items long)
- * frames (-0x20000000 <= (14.13) < 0x20000000)
- * @param in speech data to process
- * @param length input data size
- *
- * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] +
- * 1.9330735 * out[i-1] - 0.93589199 * out[i-2]
- *
- * The filter has a cut-off frequency of 1/80 of the sampling freq
- *
- * @note Two items before the top of the out buffer must contain two items from the
- * tail of the previous subframe.
- *
- * @remark It is safe to pass the same array in in and out parameters.
- *
- * @remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula,
- * but constants differs in 5th sign after comma). Fortunately in
- * fixed-point all coefficients are the same as in G.729. Thus this
- * routine can be used for the fixed-point AMR decoder, too.
- */
-void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
- const int16_t* in, int length);
-
/**
* Apply an order 2 rational transfer function in-place.
*
--
1.7.4.rc2
More information about the ffmpeg-devel
mailing list