summaryrefslogtreecommitdiff
path: root/libavcodec/ra144.c
diff options
context:
space:
mode:
authorChristophe Gisquet <christophe.gisquet@gmail.com>2012-03-04 13:28:16 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-10 21:45:55 +0100
commitc3390fd56cf55259ea7665ecea6c8aeddf56e2fc (patch)
tree75bec46420b7d4a9eddbfa499af648922a8bc93c /libavcodec/ra144.c
parentdfc99ca04d7698b8f4101dd4f017c1b023ad95f8 (diff)
ra144: use scalarproduct_int16
The buffer holding the coefficients must be padded with 0 so as to use DSP functions that may overread. Currently, the SSE2/3 versions is an example, as they process batches of 16 bytes. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ra144.c')
-rw-r--r--libavcodec/ra144.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c
index fe9a5bcb3c..992972182f 100644
--- a/libavcodec/ra144.c
+++ b/libavcodec/ra144.c
@@ -1681,12 +1681,9 @@ unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy)
}
/** inverse root mean square */
-int ff_irms(const int16_t *data)
+int ff_irms(DSPContext *dsp, const int16_t *data)
{
- unsigned int i, sum = 0;
-
- for (i=0; i < BLOCKSIZE; i++)
- sum += data[i] * data[i];
+ unsigned int sum = dsp->scalarproduct_int16(data, data, BLOCKSIZE);
if (sum == 0)
return 0; /* OOPS - division by zero */
@@ -1698,14 +1695,13 @@ void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
int cba_idx, int cb1_idx, int cb2_idx,
int gval, int gain)
{
- int16_t buffer_a[BLOCKSIZE];
int16_t *block;
int m[3];
if (cba_idx) {
cba_idx += BLOCKSIZE/2 - 1;
- ff_copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx);
- m[0] = (ff_irms(buffer_a) * gval) >> 12;
+ ff_copy_and_dup(ractx->buffer_a, ractx->adapt_cb, cba_idx);
+ m[0] = (ff_irms(&ractx->dsp, ractx->buffer_a) * gval) >> 12;
} else {
m[0] = 0;
}
@@ -1716,7 +1712,7 @@ void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
- add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
+ add_wav(block, gain, cba_idx, m, cba_idx? ractx->buffer_a: NULL,
ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE,