[FFmpeg-devel] [PATCH] Fix for inverted sign in ffvorbis?audio?output (resubmit)

Reimar Döffinger Reimar.Doeffinger
Thu May 14 10:29:37 CEST 2009


On Thu, May 14, 2009 at 11:06:21AM +0300, Siarhei Siamashka wrote:
> And what about this variant?
>  
> +    alpha = (scale < 0 ? 0.5 * M_PI : 0) + 0.25 * M_PI / n;
> +    scale = -sqrt(fabs(scale));
>      for(i=0;i<n4;i++) {
> -        alpha = 2 * M_PI * (i + 1.0 / 8.0) / n;
> -        s->tcos[i] = -cos(alpha);
> -        s->tsin[i] = -sin(alpha);
> +        s->tcos[i] = cos(alpha) * scale;
> +        s->tsin[i] = sin(alpha) * scale;
> +        alpha += 2.0 * M_PI / n;

Rounding errors accumulate like that, IMO you really should never do
that unless a) you know the value you add can be represented exactly
or b) you absolutely can't avoid it for performance reasons.



More information about the ffmpeg-devel mailing list