[FFmpeg-cvslog] r15680 - in trunk/libavcodec: Makefile acelp_filters.c acelp_filters.h celp_filters.c celp_filters.h ra144.c
diego
subversion
Fri Oct 24 23:29:23 CEST 2008
Author: diego
Date: Fri Oct 24 23:29:23 2008
New Revision: 15680
Log:
Split off celp_filters.[ch] from acelp_filters.[ch] for the QCELP decoder.
patch by Kenan Gillet, kenan.gillet gmail com
Added:
trunk/libavcodec/celp_filters.c (contents, props changed)
- copied, changed from r15678, /trunk/libavcodec/acelp_filters.c
trunk/libavcodec/celp_filters.h (contents, props changed)
- copied, changed from r15678, /trunk/libavcodec/acelp_filters.h
Modified:
trunk/libavcodec/Makefile
trunk/libavcodec/acelp_filters.c
trunk/libavcodec/acelp_filters.h
trunk/libavcodec/ra144.c
Modified: trunk/libavcodec/Makefile
==============================================================================
--- trunk/libavcodec/Makefile (original)
+++ trunk/libavcodec/Makefile Fri Oct 24 23:29:23 2008
@@ -156,7 +156,7 @@ OBJS-$(CONFIG_QDRAW_DECODER) +
OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o
OBJS-$(CONFIG_QTRLE_DECODER) += qtrle.o
OBJS-$(CONFIG_QTRLE_ENCODER) += qtrleenc.o
-OBJS-$(CONFIG_RA_144_DECODER) += ra144.o acelp_filters.o
+OBJS-$(CONFIG_RA_144_DECODER) += ra144.o celp_filters.o
OBJS-$(CONFIG_RA_288_DECODER) += ra288.o
OBJS-$(CONFIG_RAWVIDEO_DECODER) += rawdec.o
OBJS-$(CONFIG_RAWVIDEO_ENCODER) += rawenc.o
Modified: trunk/libavcodec/acelp_filters.c
==============================================================================
--- trunk/libavcodec/acelp_filters.c (original)
+++ trunk/libavcodec/acelp_filters.c Fri Oct 24 23:29:23 2008
@@ -81,65 +81,6 @@ void ff_acelp_interpolate(
}
}
-void ff_acelp_convolve_circ(
- int16_t* fc_out,
- const int16_t* fc_in,
- const int16_t* filter,
- int len)
-{
- int i, k;
-
- memset(fc_out, 0, len * sizeof(int16_t));
-
- /* Since there are few pulses over an entire subframe (i.e. almost
- all fc_in[i] are zero) it is faster to loop over fc_in first. */
- for(i=0; i<len; i++)
- {
- if(fc_in[i])
- {
- for(k=0; k<i; k++)
- fc_out[k] += (fc_in[i] * filter[len + k - i]) >> 15;
-
- for(k=i; k<len; k++)
- fc_out[k] += (fc_in[i] * filter[ k - i]) >> 15;
- }
- }
-}
-
-int ff_acelp_lp_synthesis_filter(
- int16_t *out,
- const int16_t* filter_coeffs,
- const int16_t* in,
- int buffer_length,
- int filter_length,
- int stop_on_overflow,
- int rounder)
-{
- int i,n;
-
- // These two lines are to avoid a -1 subtraction in the main loop
- filter_length++;
- filter_coeffs--;
-
- for(n=0; n<buffer_length; n++)
- {
- int sum = rounder;
- for(i=1; i<filter_length; i++)
- sum -= filter_coeffs[i] * out[n-i];
-
- sum = (sum >> 12) + in[n];
-
- if(sum + 0x8000 > 0xFFFFU)
- {
- if(stop_on_overflow)
- return 1;
- sum = (sum >> 31) ^ 32767;
- }
- out[n] = sum;
- }
-
- return 0;
-}
void ff_acelp_high_pass_filter(
int16_t* out,
Modified: trunk/libavcodec/acelp_filters.h
==============================================================================
--- trunk/libavcodec/acelp_filters.h (original)
+++ trunk/libavcodec/acelp_filters.h Fri Oct 24 23:29:23 2008
@@ -60,50 +60,6 @@ void ff_acelp_interpolate(
int filter_length,
int length);
-/**
- * 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_acelp_convolve_circ(
- int16_t* fc_out,
- const int16_t* fc_in,
- const int16_t* filter,
- int len);
-
-/**
- * LP synthesis filter.
- * @param out [out] pointer to output buffer
- * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
- * @param in input signal
- * @param buffer_length amount of data to process
- * @param filter_length filter length (10 for 10th order LP filter)
- * @param stop_on_overflow 1 - return immediately if overflow occurs
- * 0 - ignore overflows
- * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
- *
- * @return 1 if overflow occurred, 0 - otherwise
- *
- * @note Output buffer must contain 10 samples of past
- * speech data before pointer.
- *
- * Routine applies 1/A(z) filter to given speech data.
- */
-int ff_acelp_lp_synthesis_filter(
- int16_t *out,
- const int16_t* filter_coeffs,
- const int16_t* in,
- int buffer_length,
- int filter_length,
- int stop_on_overflow,
- int rounder);
-
/**
* high-pass filtering and upscaling (4.2.5 of G.729).
Copied: trunk/libavcodec/celp_filters.c (from r15678, /trunk/libavcodec/acelp_filters.c)
==============================================================================
--- /trunk/libavcodec/acelp_filters.c (original)
+++ trunk/libavcodec/celp_filters.c Fri Oct 24 23:29:23 2008
@@ -23,65 +23,9 @@
#include <inttypes.h>
#include "avcodec.h"
-#include "acelp_filters.h"
-
-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,
- 2259, 1170, 0, -1001, -1652, -1868,
- -1666, -1147, -464, 218, 756, 1060,
- 1099, 904, 550, 135, -245, -514,
- -634, -602, -451, -231, 0, 191,
- 308, 340, 296, 198, 78, -36,
- -120, -163, -165, -132, -79, -19,
- 34, 73, 91, 89, 70, 38,
- 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(pitch_delay_frac >= 0 && pitch_delay_frac < 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;
- }
-}
+#include "celp_filters.h"
-void ff_acelp_convolve_circ(
+void ff_celp_convolve_circ(
int16_t* fc_out,
const int16_t* fc_in,
const int16_t* filter,
@@ -106,7 +50,7 @@ void ff_acelp_convolve_circ(
}
}
-int ff_acelp_lp_synthesis_filter(
+int ff_celp_lp_synthesis_filter(
int16_t *out,
const int16_t* filter_coeffs,
const int16_t* in,
@@ -140,27 +84,3 @@ int ff_acelp_lp_synthesis_filter(
return 0;
}
-
-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;
- }
-}
Copied: trunk/libavcodec/celp_filters.h (from r15678, /trunk/libavcodec/acelp_filters.h)
==============================================================================
--- /trunk/libavcodec/acelp_filters.h (original)
+++ trunk/libavcodec/celp_filters.h Fri Oct 24 23:29:23 2008
@@ -1,5 +1,5 @@
/*
- * various filters for ACELP-based codecs
+ * various filters for CELP-based codecs
*
* Copyright (c) 2008 Vladimir Voroshilov
*
@@ -20,47 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_ACELP_FILTERS_H
-#define AVCODEC_ACELP_FILTERS_H
+#ifndef AVCODEC_CELP_FILTERS_H
+#define AVCODEC_CELP_FILTERS_H
#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.
- * @param out [out] buffer for interpolated data
- * @param in input data
- * @param filter_coeffs interpolation filter coefficients (0.15)
- * @param precision sub sample factor, that is the precision of the position
- * @param frac_pos fractional part of position [0..precision-1]
- * @param filter_length filter length
- * @param length length of output
- *
- * filter_coeffs contains coefficients of the right half of the symmetric
- * interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient.
- * 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);
-
-/**
* 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
@@ -71,7 +36,7 @@ void ff_acelp_interpolate(
*
* \note fc_in and fc_out should not overlap!
*/
-void ff_acelp_convolve_circ(
+void ff_celp_convolve_circ(
int16_t* fc_out,
const int16_t* fc_in,
const int16_t* filter,
@@ -95,7 +60,7 @@ void ff_acelp_convolve_circ(
*
* Routine applies 1/A(z) filter to given speech data.
*/
-int ff_acelp_lp_synthesis_filter(
+int ff_celp_lp_synthesis_filter(
int16_t *out,
const int16_t* filter_coeffs,
const int16_t* in,
@@ -104,34 +69,4 @@ int ff_acelp_lp_synthesis_filter(
int stop_on_overflow,
int rounder);
-
-/**
- * high-pass filtering and upscaling (4.2.5 of G.729).
- * @param out [out] output buffer for filtered speech data
- * @param hpf_f [in/out] 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);
-
-#endif /* AVCODEC_ACELP_FILTERS_H */
+#endif /* AVCODEC_CELP_FILTERS_H */
Modified: trunk/libavcodec/ra144.c
==============================================================================
--- trunk/libavcodec/ra144.c (original)
+++ trunk/libavcodec/ra144.c Fri Oct 24 23:29:23 2008
@@ -25,7 +25,7 @@
#include "avcodec.h"
#include "bitstream.h"
#include "ra144.h"
-#include "acelp_filters.h"
+#include "celp_filters.h"
#define NBLOCKS 4 ///< number of subblocks within a block
#define BLOCKSIZE 40 ///< subblock size in 16-bit words
@@ -201,8 +201,8 @@ static void do_output_subblock(RA144Cont
memcpy(ractx->curr_sblock, ractx->curr_sblock + 40,
10*sizeof(*ractx->curr_sblock));
- if (ff_acelp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
- block, BLOCKSIZE, 10, 1, 0xfff))
+ if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
+ block, BLOCKSIZE, 10, 1, 0xfff))
memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock));
}
More information about the ffmpeg-cvslog
mailing list