Revision 7d485f16 libavcodec/mdct.c

View differences:

libavcodec/mdct.c
68 68
/**
69 69
 * init MDCT or IMDCT computation.
70 70
 */
71
av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
71
av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale)
72 72
{
73 73
    int n, n4, i;
74
    double alpha;
74
    double alpha, theta;
75 75

  
76 76
    memset(s, 0, sizeof(*s));
77 77
    n = 1 << nbits;
......
85 85
    if (!s->tsin)
86 86
        goto fail;
87 87

  
88
    theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
89
    scale = sqrt(fabs(scale));
88 90
    for(i=0;i<n4;i++) {
89
        alpha = 2 * M_PI * (i + 1.0 / 8.0) / n;
90
        s->tcos[i] = -cos(alpha);
91
        s->tsin[i] = -sin(alpha);
91
        alpha = 2 * M_PI * (i + theta) / n;
92
        s->tcos[i] = -cos(alpha) * scale;
93
        s->tsin[i] = -sin(alpha) * scale;
92 94
    }
93 95
    if (ff_fft_init(&s->fft, s->nbits - 2, inverse) < 0)
94 96
        goto fail;

Also available in: Unified diff