[FFmpeg-soc] [soc]: r4836 - in amr: amr-ffmpeg.diff amrnbdec.c
cmcq
subversion at mplayerhq.hu
Wed Jul 29 16:38:54 CEST 2009
Author: cmcq
Date: Wed Jul 29 16:38:54 2009
New Revision: 4836
Log:
Simplify the zero filter because it is no longer used by the high-pass filter
The difference from ff_celp_lp_synthesis_filterf was a headache, and scaling
can always be done separately if needed.
Modified:
amr/amr-ffmpeg.diff
amr/amrnbdec.c
Modified: amr/amr-ffmpeg.diff
==============================================================================
--- amr/amr-ffmpeg.diff Wed Jul 29 14:31:04 2009 (r4835)
+++ amr/amr-ffmpeg.diff Wed Jul 29 16:38:54 2009 (r4836)
@@ -85,81 +85,14 @@ Index: libavcodec/celp_filters.c
void ff_celp_lp_synthesis_filterf(
float *out,
const float* filter_coeffs,
-@@ -113,13 +138,10 @@
- {
- int i,n;
-
-- // Avoids a +1 in the inner loop.
-- filter_length++;
--
- for(n=0; n<buffer_length; n++)
+@@ -120,6 +145,6 @@
{
-- out[n] = in[n];
-- for(i=1; i<filter_length; i++)
+ out[n] = in[n];
+ for(i=1; i<filter_length; i++)
- out[n] -= filter_coeffs[i-1] * in[n-i];
-+ out[n] = 0;
-+ for(i=0; i<filter_length; i++)
-+ out[n] += filter_coeffs[i] * in[n-i];
++ out[n] += filter_coeffs[i-1] * in[n-i];
}
}
-Index: libavcodec/celp_filters.h
-===================================================================
---- libavcodec/celp_filters.h (revision 19401)
-+++ libavcodec/celp_filters.h (working copy)
-@@ -70,14 +70,31 @@
- int rounder);
-
- /**
-+ * Circularly convolve fixed vector with a phase dispersion impulse
-+ * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
-+ * @param fc_out vector with filter applied
-+ * @param fc_in source vector
-+ * @param filter phase filter coefficients
-+ *
-+ * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
-+ *
-+ * \note fc_in and fc_out should not overlap!
-+ */
-+void ff_celp_convolve_circf(
-+ float* fc_out,
-+ const float* fc_in,
-+ const float* filter,
-+ int len);
-+
-+/**
- * LP synthesis filter.
- * @param out [out] pointer to output buffer
- * - the array out[-filter_length, -1] must
- * contain the previous result of this filter
-- * @param filter_coeffs filter coefficients.
-+ * @param filter_coeffs filter coefficients not including z^0
- * @param in input signal
- * @param buffer_length amount of data to process
-- * @param filter_length filter length (10 for 10th order LP filter)
-+ * @param filter_length filter_coeffs length (10 for 10th order LP filter)
- *
- * @note Output buffer must contain filter_length samples of past
- * speech data before pointer.
-@@ -94,16 +111,13 @@
- /**
- * LP zero synthesis filter.
- * @param out [out] pointer to output buffer
-- * @param filter_coeffs filter coefficients.
-+ * @param filter_coeffs filter coefficients including z^0 coefficient
- * @param in input signal
-- * - the array in[-filter_length, -1] must
-+ * - the array in[-filter_length+1, -1] must
- * contain the previous input of this filter
- * @param buffer_length amount of data to process
-- * @param filter_length filter length (10 for 10th order LP filter)
-+ * @param filter_length filter_coeffs length (11 for 10th order LP filter)
- *
-- * @note Output buffer must contain filter_length samples of past
-- * speech data before pointer.
-- *
- * Routine applies A(z) filter to given speech data.
- */
- void ff_celp_lp_zero_synthesis_filterf(
Index: libavcodec/acelp_filters.c
===================================================================
--- libavcodec/acelp_filters.c (revision 19401)
Modified: amr/amrnbdec.c
==============================================================================
--- amr/amrnbdec.c Wed Jul 29 14:31:04 2009 (r4835)
+++ amr/amrnbdec.c Wed Jul 29 16:38:54 2009 (r4836)
@@ -973,7 +973,7 @@ static void update_state(AMRContext *p)
/**
* Get the tilt factor of a formant filter from its transfer function
*
- * @param lpc_n LP_FILTER_ORDER + 1 coefficients of the numerator
+ * @param lpc_n LP_FILTER_ORDER coefficients of the numerator
* @param lpc_d LP_FILTER_ORDER coefficients of the denominator
*/
static float tilt_factor(float *lpc_n, float *lpc_d)
@@ -985,7 +985,8 @@ static float tilt_factor(float *lpc_n, f
float rh0 = 0.0, rh1 = 0.0;
// Get impulse response of the transfer function given by lpc_n and lpc_d
- memcpy(hf, lpc_n, sizeof(float) * (LP_FILTER_ORDER + 1));
+ hf[0] = 1.0;
+ memcpy(hf + 1, lpc_n, sizeof(float) * LP_FILTER_ORDER);
ff_celp_lp_synthesis_filterf(hf, lpc_d, hf, AMR_TILT_RESPONSE,
LP_FILTER_ORDER);
@@ -1033,7 +1034,7 @@ static void postfilter(AMRContext *p, fl
float postfilter_gain;
float tmp[AMR_SUBFRAME_SIZE + LP_FILTER_ORDER];
const float *gamma_n, *gamma_d; // Formant filter factor table
- float lpc_n[LP_FILTER_ORDER + 1], // Transfer function coefficients
+ float lpc_n[LP_FILTER_ORDER], // Transfer function coefficients
lpc_d[LP_FILTER_ORDER]; //
if (p->cur_frame_mode == MODE_122 || p->cur_frame_mode == MODE_102) {
@@ -1044,9 +1045,8 @@ static void postfilter(AMRContext *p, fl
gamma_d = formant_low_d;
}
- lpc_n[0] = 1;
for (i = 0; i < LP_FILTER_ORDER; i++) {
- lpc_n[i + 1] = lpc[i] * gamma_n[i];
+ lpc_n[i] = lpc[i] * gamma_n[i];
lpc_d[i] = lpc[i] * gamma_d[i];
}
@@ -1057,7 +1057,7 @@ static void postfilter(AMRContext *p, fl
memcpy(p->postfilter_mem, tmp + AMR_SUBFRAME_SIZE,
sizeof(float) * LP_FILTER_ORDER);
ff_celp_lp_zero_synthesis_filterf(buf_out, lpc_n, tmp + LP_FILTER_ORDER,
- AMR_SUBFRAME_SIZE, LP_FILTER_ORDER + 1);
+ AMR_SUBFRAME_SIZE, LP_FILTER_ORDER);
// Apply tilt compensation
tilt_compensation(&p->tilt_mem, tilt_factor(lpc_n, lpc_d), buf_out);
More information about the FFmpeg-soc
mailing list