diff options
author | Reynaldo H. Verdejo Pinochet <reynaldo@opendot.cl> | 2009-03-09 21:55:24 +0000 |
---|---|---|
committer | Reynaldo H. Verdejo Pinochet <reynaldo@opendot.cl> | 2009-03-09 21:55:24 +0000 |
commit | 95e83257715818d113724eb92035f4e685d1ec11 (patch) | |
tree | c0bf7092251919b30fc7610f3c513078f077240d | |
parent | 88c4339bda6f2ad0e6e431b5c45e32d44d44a344 (diff) | |
download | ffmpeg-95e83257715818d113724eb92035f4e685d1ec11.tar.gz |
Functional part Kenan Gillet's 'extract and share weighted_vector_sumf'
patchset. Idea is to share this common code between the AMR and QCELP
decoders.
Originally committed as revision 17916 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/Makefile | 2 | ||||
-rw-r--r-- | libavcodec/acelp_vectors.c | 10 | ||||
-rw-r--r-- | libavcodec/acelp_vectors.h | 14 | ||||
-rw-r--r-- | libavcodec/qcelpdec.c | 16 |
4 files changed, 28 insertions, 14 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ee0d24d403..13415fc0d2 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -165,7 +165,7 @@ OBJS-$(CONFIG_PNG_DECODER) += png.o pngdec.o OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PTX_DECODER) += ptx.o -OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o qcelp_lsp.o celp_math.o celp_filters.o +OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o qcelp_lsp.o celp_math.o celp_filters.o acelp_vectors.o OBJS-$(CONFIG_QDM2_DECODER) += qdm2.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o OBJS-$(CONFIG_QDRAW_DECODER) += qdrw.o OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c index cae6318fa0..5443006718 100644 --- a/libavcodec/acelp_vectors.c +++ b/libavcodec/acelp_vectors.c @@ -145,3 +145,13 @@ void ff_acelp_weighted_vector_sum( in_b[i] * weight_coeff_b + rounder) >> shift); } + +void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, + float weight_coeff_a, float weight_coeff_b, int length) +{ + int i; + + for(i=0; i<length; i++) + out[i] = weight_coeff_a * in_a[i] + + weight_coeff_b * in_b[i]; +} diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h index a5e71fc128..3a47a7b61c 100644 --- a/libavcodec/acelp_vectors.h +++ b/libavcodec/acelp_vectors.h @@ -150,4 +150,18 @@ void ff_acelp_weighted_vector_sum( int shift, int length); +/** + * float implementation of weighted sum of two vectors. + * @param out [out] result of addition + * @param in_a first vector + * @param in_b second vector + * @param weight_coeff_a first vector weight coefficient + * @param weight_coeff_a second vector weight coefficient + * @param length vectors length + * + * @note It is safe to pass the same buffer for out and in_a or in_b. + */ +void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, + float weight_coeff_a, float weight_coeff_b, int length); + #endif /* AVCODEC_ACELP_VECTORS_H */ diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c index c7d2938c0a..9af3467a96 100644 --- a/libavcodec/qcelpdec.c +++ b/libavcodec/qcelpdec.c @@ -37,6 +37,7 @@ #include "celp_math.h" #include "celp_filters.h" +#include "acelp_vectors.h" #undef NDEBUG #include <assert.h> @@ -81,17 +82,6 @@ typedef struct */ void ff_celp_lspf2lpc(const double *lspf, float *lpc); -static void weighted_vector_sumf(float *out, const float *in_a, - const float *in_b, float weight_coeff_a, - float weight_coeff_b, int length) -{ - int i; - - for(i=0; i<length; i++) - out[i] = weight_coeff_a * in_a[i] - + weight_coeff_b * in_b[i]; -} - /** * Initialize the speech codec according to the specification. * @@ -174,7 +164,7 @@ static int decode_lspf(QCELPContext *q, float *lspf) lspf[i-1] = FFMIN(lspf[i-1], (lspf[i] - QCELP_LSP_SPREAD_FACTOR)); // Low-pass filter the LSP frequencies. - weighted_vector_sumf(lspf, lspf, q->prev_lspf, smooth, 1.0-smooth, 10); + ff_weighted_vector_sumf(lspf, lspf, q->prev_lspf, smooth, 1.0-smooth, 10); }else { q->octave_count = 0; @@ -640,7 +630,7 @@ void interpolate_lpc(QCELPContext *q, const float *curr_lspf, float *lpc, if(weight != 1.0) { - weighted_vector_sumf(interpolated_lspf, curr_lspf, q->prev_lspf, + ff_weighted_vector_sumf(interpolated_lspf, curr_lspf, q->prev_lspf, weight, 1.0 - weight, 10); lspf2lpc(interpolated_lspf, lpc); }else if(q->bitrate >= RATE_QUARTER || |