[FFmpeg-devel] [PATCH] WMA Voice postfilter
Michael Niedermayer
michaelni
Mon Apr 12 17:27:58 CEST 2010
On Sun, Apr 11, 2010 at 07:48:07PM -0400, Vitor Sessak wrote:
> Ronald S. Bultje wrote:
>> Hi,
>> On Thu, Apr 1, 2010 at 11:52 AM, Reimar D?ffinger
>> <Reimar.Doeffinger at gmx.de> wrote:
>>> On Thu, Apr 01, 2010 at 11:25:25AM -0400, Ronald S. Bultje wrote:
>>>> I'm probably asking silly questions here, but can I allocate aligned
>>>> memory on the stack? Or do they have to be in the struct?
>>> You better avoid it on the stack, it won't work reliably on all
>>> supported configurations.
>> Thanks for the advice, this patch is tested with yasm and does not
>> crash, so I think alignment is OK now. By putting synth buffer in the
>> context, I was also able to remove one memcpy(). (One or two more of
>> those are possible in the original code, previously already suggested
>> by Vitor, so I might go ahead and do that in a future patch also.)
>
> Some comments:
>
>> +static int kalman_smoothen(WMAVoiceContext *s, int pitch,
>> + const float *in, float *out, int size)
>> +{
>> + int n;
>> + float optimal_gain = 0, dot;
>> + const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)],
>> + *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)],
>> + *best_hist_ptr;
>> +
>> + /* find best fitting point in history */
>> + do {
>> + dot = ff_dot_productf(in, ptr, size);
>> + if (dot > optimal_gain) {
>> + optimal_gain = dot;
>> + best_hist_ptr = ptr;
>> + }
>> + } while (--ptr >= end);
>> +
>> + if (optimal_gain <= 0)
>> + return -1;
>> + dot = ff_dot_productf(best_hist_ptr, best_hist_ptr, size);
>> + if (dot <= 0) // would be 1.0
>> + return -1;
>> +
>> + if (optimal_gain <= dot) {
>> + dot = 0.5 / (0.5 + 0.3 * optimal_gain / dot); // 0.0625-1.0000
>
> This can be done with one less division:
>
> dot = (0.5 * dot) / (0.5 * dot + 0.3 * optimal_gain); // 0.0625-1.0000
and 2 lesss multiplications:
dot / (dot + 0.6 * optimal_gain);
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- 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/20100412/edf3dc4f/attachment.pgp>
More information about the ffmpeg-devel
mailing list