[FFmpeg-devel] [PATCH] Common ACELP code & G.729 [3/7] - vectors operations
Michael Niedermayer
michaelni
Fri May 2 23:02:29 CEST 2008
On Fri, May 02, 2008 at 06:43:18PM +0700, Vladimir Voroshilov wrote:
> This patch contains routines for operating with adaptive and algebraic vectors.
>
> FIR filter was moved here.
> It now does not use any "frac=-frac" or "if(frac<9)" and can be called
> as foo(delay/6, delay%6).
> This possibility was not obvious for me due to loop asymmetry,
> introduced in reference code (and in specification too)
> to avoid "out of bounds" error.
[...]
> +static const uint8_t mul_5x[8] = {0, 5, 10, 15, 20, 25, 30, 35};
*5 should do :)
> +
> +static const uint8_t fc_2pulses_9bits_track1[16] =
> +{
> + 1, 3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38
> +};
((x*5)>>1)+1
> +
> +/*
> + (EE) This table (from reference code) does not comply with specifiation !
> + Specification contains following table:
> + 0, 1, 2, 4,
> + 5, 6, 7, 9,
> + 10, 11, 12, 14,
> + 15, 16, 17, 19,
> + 20, 21, 22, 24,
> + 25, 26, 27, 29,
> + 30, 31, 32, 34,
> + 35, 36, 37, 39,
> +*/
> +static const uint8_t fc_2pulses_9bits_track2[32] =
> +{
> + 0, 2, 4,
> + 5, 7, 9,
> + 10, 12, 14,
> + 15, 17, 19,
> + 20, 22, 24,
> + 25, 27, 29,
> + 30, 32, 34,
> + 35, 37, 39,
> + 1,
> + 6,
> + 11,
> + 16,
> + 21,
> + 26,
> + 31,
> + 36
> +};
> +
> +static uint8_t gray_decode[32] =
> +{
> + 0, 1, 3, 2, 7, 6, 4, 5,
> + 15, 14, 12, 13, 8, 9, 11, 10,
> + 31, 30, 28, 29, 24, 25, 27, 26,
> + 16, 17, 19, 18, 23, 22, 20, 21
> +};
this is just x^(x>>1)
of course only replace the table with above if its smaller/faster, same
applies to the other suggested replacements for the tables
[...]
> +void ff_acelp_fc_4pulses_13bits(
> + int16_t* fc_v,
> + int fc_index,
> + int pulses_signs)
> +{
> + int i;
> + int index;
> +
> + for(i=0; i<3; i++)
> + {
> + index = i + mul_5x[fc_index & 7];
> + fc_v[ index ] += (pulses_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
> +
> + fc_index >>= 3;
> + pulses_signs >>= 1;
> + }
> +
> + index = 3 + (fc_index & 1) + mul_5x[(fc_index>>1) & 7];
> + fc_v[ index ] += (pulses_signs & 1) ? 8191 : -8192;
> +}
> +
> +void ff_acelp_fc_2pulses_9bits_g729d(
> + int16_t* fc_v,
> + int fc_index,
> + int pulses_signs)
> +{
> + int index;
> +
> + index = fc_2pulses_9bits_track1[gray_decode[fc_index & 15]];
> + fc_v[ index ] += (pulses_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
> +
> + pulses_signs >>= 1;
> + fc_index >>= 4;
> +
> + index = fc_2pulses_9bits_track2[gray_decode[fc_index & 31]];
> + fc_v[ index ] += (pulses_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
> +}
> +
> +void ff_acelp_fc_4pulses_21bits(
> + int16_t* fc_v,
> + int fc_index,
> + int pulses_signs)
> +{
> + int i;
> + int index;
> +
> + for(i=0; i<3; i++)
> + {
> + index = i + 5 *(fc_index & 15);
> + fc_v[ index ] += (pulses_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
> +
> + fc_index >>= 4;
> + pulses_signs >>= 1;
> + }
> +
> + index = 3 + (fc_index & 1);
> + fc_index >>= 1;
> + index += 5 * (fc_index & 15);
> + fc_v[ index ] += (pulses_signs & 1) ? 8191 : -8192;
> +}
> +
duplicate of ff_acelp_fc_4pulses_13bits()
also the
fc_v[ index ] += (pulses_signs & 1) ? 8191 : -8192;
stuff is duplicated all over the place
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- 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/20080502/607021b2/attachment.pgp>
More information about the ffmpeg-devel
mailing list