[FFmpeg-devel] Review request - ra288.{c,h} ra144.{c,h}
Michael Niedermayer
michaelni
Fri Aug 1 18:56:59 CEST 2008
On Tue, Jul 29, 2008 at 08:20:45PM +0200, Vitor Sessak wrote:
> Hi,
>
> Those four files never passed a review. I've just finished cleaning them
> up, so if anyone wants to review them (Michael already said he will),
> now is time.
heres 288
[...]
> static void decode(RA288Context *ractx, float gain, int cb_coef)
> {
> int i, j;
> double sumsum;
> float sum, buffer[5];
>
> memmove(ractx->sp_block + 5, ractx->sp_block, 36*sizeof(*ractx->sp_block));
>
> for (i=4; i >= 0; i--)
> ractx->sp_block[i] = -scalar_product_float(ractx->sp_block + i + 1,
> ractx->sp_lpc, 36);
>
> /* block 46 of G.728 spec */
> sum = 32. - scalar_product_float(ractx->gain_lpc, ractx->gain_block, 10);
>
> /* block 47 of G.728 spec */
> sum = av_clipf(sum, 0, 60);
>
> /* block 48 of G.728 spec */
> sumsum = exp(sum * 0.1151292546497) * gain; /* pow(10.0,sum/20)*gain */
>
> for (i=0; i < 5; i++)
> buffer[i] = codetable[cb_coef][i] * sumsum;
>
> sum = scalar_product_float(buffer, buffer, 5) / 5;
>
> sum = FFMAX(sum, 1);
>
> /* shift and store */
> memmove(ractx->gain_block, ractx->gain_block - 1,
> 10 * sizeof(*ractx->gain_block));
>
> *ractx->gain_block = 10 * log10(sum) - 32;
>
> for (i=1; i < 5; i++)
> for (j=i-1; j >= 0; j--)
> buffer[i] -= ractx->sp_lpc[i-j-1] * buffer[j];
duplicate of scalar_product_float() if half of the arrays wherent stored
in right to left order
>
> /* output */
> for (i=0; i < 5; i++)
> ractx->sp_block[4-i] =
> av_clipf(ractx->sp_block[4-i] + buffer[i], -4095, 4095);
i think some of the arrays can be fliped 0..N wise which would clear up
things a little
> }
>
> /**
> * Converts autocorrelation coefficients to LPC coefficients using the
> * Levinson-Durbin algorithm. See blocks 37 and 50 of the G.728 specification.
> *
> * @return 0 if success, -1 if fail
> */
> static int eval_lpc_coeffs(const float *in, float *tgt, int n)
> {
> int i, j;
> double f0, f1, f2;
>
> if (in[n] == 0)
> return -1;
>
> if ((f0 = *in) <= 0)
> return -1;
>
> in--; // To avoid a -1 subtraction in the inner loop
>
> for (i=1; i <= n; i++) {
> f1 = in[i+1];
>
> for (j=0; j < i - 1; j++)
> f1 += in[i-j]*tgt[j];
>
> tgt[i-1] = f2 = -f1/f0;
> for (j=0; j < i >> 1; j++) {
> float temp = tgt[j] + tgt[i-j-2]*f2;
> tgt[i-j-2] += tgt[j]*f2;
> tgt[j] = temp;
> }
> if ((f0 += f1*f2) < 0)
> return -1;
> }
>
> return 0;
> }
duplicate of compute_lpc_coefs() ?
>
> static void prodsum(float *tgt, const float *src, int len, int n)
> {
> for (; n >= 0; n--)
> tgt[n] = scalar_product_float(src, src - n, len);
>
> }
i think convolution() is a better name
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080801/09ffab0b/attachment.pgp>
More information about the ffmpeg-devel
mailing list