Revision 89d7df7c libavcodec/dct.c
libavcodec/dct.c  

31  31 
#include "libavutil/mathematics.h" 
32  32 
#include "fft.h" 
33  33  
34 
av_cold int ff_dct_init(DCTContext *s, int nbits, int inverse) 

35 
{ 

36 
int n = 1 << nbits; 

37 
int i; 

38  
39 
s>nbits = nbits; 

40 
s>inverse = inverse; 

41  
42 
ff_init_ff_cos_tabs(nbits+2); 

43  
44 
s>costab = ff_cos_tabs[nbits+2]; 

45  
46 
s>csc2 = av_malloc(n/2 * sizeof(FFTSample)); 

47  
48 
if (ff_rdft_init(&s>rdft, nbits, inverse) < 0) { 

49 
av_free(s>csc2); 

50 
return 1; 

51 
} 

52  
53 
for (i = 0; i < n/2; i++) 

54 
s>csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1))); 

55  
56 
return 0; 

57 
} 

58  
59  34 
/* sin((M_PI * x / (2*n)) */ 
60  35 
#define SIN(s,n,x) (s>costab[(n)  (x)]) 
61  36  
...  ...  
133  108 
ff_dct_calc_c(s, data); 
134  109 
} 
135  110  
111 
av_cold int ff_dct_init(DCTContext *s, int nbits, int inverse) 

112 
{ 

113 
int n = 1 << nbits; 

114 
int i; 

115  
116 
s>nbits = nbits; 

117 
s>inverse = inverse; 

118  
119 
ff_init_ff_cos_tabs(nbits+2); 

120  
121 
s>costab = ff_cos_tabs[nbits+2]; 

122  
123 
s>csc2 = av_malloc(n/2 * sizeof(FFTSample)); 

124  
125 
if (ff_rdft_init(&s>rdft, nbits, inverse) < 0) { 

126 
av_free(s>csc2); 

127 
return 1; 

128 
} 

129  
130 
for (i = 0; i < n/2; i++) 

131 
s>csc2[i] = 0.5 / sin((M_PI / (2*n) * (2*i + 1))); 

132  
133 
return 0; 

134 
} 

135  
136  136 
av_cold void ff_dct_end(DCTContext *s) 
137  137 
{ 
138  138 
ff_rdft_end(&s>rdft); 
Also available in: Unified diff