Revision 1366f059 libavcodec/rdft.c

View differences:

libavcodec/rdft.c
50 50
    ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536,
51 51
};
52 52

  
53
static void ff_rdft_calc_c(RDFTContext* s, FFTSample* data);
54

  
55
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
56
{
57
    int n = 1 << nbits;
58
    int i;
59
    const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1)*2*M_PI/n;
60

  
61
    s->nbits           = nbits;
62
    s->inverse         = trans == IDFT_C2R || trans == DFT_C2R;
63
    s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
64

  
65
    if (nbits < 4 || nbits > 16)
66
        return -1;
67

  
68
    if (ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C) < 0)
69
        return -1;
70

  
71
    ff_init_ff_cos_tabs(nbits);
72
    s->tcos = ff_cos_tabs[nbits];
73
    s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
74
#if !CONFIG_HARDCODED_TABLES
75
    for (i = 0; i < (n>>2); i++) {
76
        s->tsin[i] = sin(i*theta);
77
    }
78
#endif
79
    s->rdft_calc   = ff_rdft_calc_c;
80
    return 0;
81
}
82

  
83 53
/** Map one real FFT into two parallel real even and odd FFTs. Then interleave
84 54
 * the two real FFTs into one complex FFT. Unmangle the results.
85 55
 * ref: http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM
......
126 96
    }
127 97
}
128 98

  
99
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
100
{
101
    int n = 1 << nbits;
102
    int i;
103
    const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1)*2*M_PI/n;
104

  
105
    s->nbits           = nbits;
106
    s->inverse         = trans == IDFT_C2R || trans == DFT_C2R;
107
    s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
108

  
109
    if (nbits < 4 || nbits > 16)
110
        return -1;
111

  
112
    if (ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C) < 0)
113
        return -1;
114

  
115
    ff_init_ff_cos_tabs(nbits);
116
    s->tcos = ff_cos_tabs[nbits];
117
    s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
118
#if !CONFIG_HARDCODED_TABLES
119
    for (i = 0; i < (n>>2); i++) {
120
        s->tsin[i] = sin(i*theta);
121
    }
122
#endif
123
    s->rdft_calc   = ff_rdft_calc_c;
124
    return 0;
125
}
126

  
129 127
av_cold void ff_rdft_end(RDFTContext *s)
130 128
{
131 129
    ff_fft_end(&s->fft);

Also available in: Unified diff