Revision 932963b8 libavcodec/aacsbr.c
libavcodec/aacsbr.c  

71  71 
static VLC vlc_sbr[10]; 
72  72 
static const int8_t vlc_sbr_lav[10] = 
73  73 
{ 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 }; 
74 
static DECLARE_ALIGNED(16, float, analysis_cos_pre)[64]; 

75 
static DECLARE_ALIGNED(16, float, analysis_sin_pre)[64]; 

76 
static DECLARE_ALIGNED(16, float, analysis_cossin_post)[32][2]; 

77  74 
static const DECLARE_ALIGNED(16, float, zero64)[64]; 
78  75  
79  76 
#define SBR_INIT_VLC_STATIC(num, size) \ 
...  ...  
116  113 
SBR_INIT_VLC_STATIC(8, 592); 
117  114 
SBR_INIT_VLC_STATIC(9, 512); 
118  115  
119 
for (n = 0; n < 64; n++) { 

120 
float pre = M_PI * n / 64; 

121 
analysis_cos_pre[n] = cosf(pre); 

122 
analysis_sin_pre[n] = sinf(pre); 

123 
} 

124 
for (k = 0; k < 32; k++) { 

125 
float post = M_PI * (k + 0.5) / 128; 

126 
analysis_cossin_post[k][0] = 4.0 * cosf(post); 

127 
analysis_cossin_post[k][1] = 4.0 * sinf(post); 

128 
} 

129  116 
for (n = 1; n < 320; n++) 
130  117 
sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320  n]; 
131  118 
sbr_qmf_window_us[384] = sbr_qmf_window_us[384]; 
...  ...  
142  129 
sbr>data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE  (1280  128); 
143  130 
sbr>data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE  (1280  128); 
144  131 
ff_mdct_init(&sbr>mdct, 7, 1, 1.0/64); 
145 
ff_rdft_init(&sbr>rdft, 6, IDFT_R2C);


132 
ff_mdct_init(&sbr>mdct_ana, 7, 1, 2.0);


146  133 
} 
147  134  
148  135 
av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) 
149  136 
{ 
150  137 
ff_mdct_end(&sbr>mdct); 
151 
ff_rdft_end(&sbr>rdft);


138 
ff_mdct_end(&sbr>mdct_ana);


152  139 
} 
153  140  
154  141 
static int qsort_comparison_function_int16(const void *a, const void *b) 
...  ...  
1139  1126 
* @param x pointer to the beginning of the first sample window 
1140  1127 
* @param W array of complexvalued samples split into subbands 
1141  1128 
*/ 
1142 
static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *rdft, const float *in, float *x,


1129 
static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *mdct, const float *in, float *x,


1143  1130 
float z[320], float W[2][32][32][2], 
1144  1131 
float scale) 
1145  1132 
{ 
...  ...  
1156  1143 
dsp>vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); 
1157  1144 
for (k = 0; k < 64; k++) { 
1158  1145 
float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; 
1159 
z[k] = f * analysis_cos_pre[k]; 

1160 
z[k+64] = f; 

1146 
z[k] = f; 

1161  1147 
} 
1162 
ff_rdft_calc(rdft, z); 

1163 
re = z[0] * 0.5f; 

1164 
im = 0.5f * dsp>scalarproduct_float(z+64, analysis_sin_pre, 64); 

1165 
W[1][i][0][0] = re * analysis_cossin_post[0][0]  im * analysis_cossin_post[0][1]; 

1166 
W[1][i][0][1] = re * analysis_cossin_post[0][1] + im * analysis_cossin_post[0][0]; 

1148 
//Shuffle to IMDCT 

1149 
z[64] = z[0]; 

1167  1150 
for (k = 1; k < 32; k++) { 
1168 
re = z[2*k ]  re; 

1169 
im = z[2*k+1]  im; 

1170 
W[1][i][k][0] = re * analysis_cossin_post[k][0]  im * analysis_cossin_post[k][1]; 

1171 
W[1][i][k][1] = re * analysis_cossin_post[k][1] + im * analysis_cossin_post[k][0]; 

1151 
z[64+2*k1] = z[ k]; 

1152 
z[64+2*k ] = z[64k]; 

1153 
} 

1154 
z[64+63] = z[32]; 

1155  
1156 
ff_imdct_half(mdct, z, z+64); 

1157 
for (k = 0; k < 32; k++) { 

1158 
W[1][i][k][0] = z[63k]; 

1159 
W[1][i][k][1] = z[k]; 

1172  1160 
} 
1173  1161 
x += 32; 
1174  1162 
} 
...  ...  
1730  1718 
} 
1731  1719 
for (ch = 0; ch < nch; ch++) { 
1732  1720 
/* decode channel */ 
1733 
sbr_qmf_analysis(&ac>dsp, &sbr>rdft, ch ? R : L, sbr>data[ch].analysis_filterbank_samples,


1721 
sbr_qmf_analysis(&ac>dsp, &sbr>mdct_ana, ch ? R : L, sbr>data[ch].analysis_filterbank_samples,


1734  1722 
(float*)sbr>qmf_filter_scratch, 
1735  1723 
sbr>data[ch].W, 1/(1024 * ac>sf_scale)); 
1736  1724 
sbr_lf_gen(ac, sbr, sbr>X_low, sbr>data[ch].W); 
Also available in: Unified diff