aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2010-12-14 14:50:54 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2010-12-14 14:50:54 +0000
commita8d2b06b7c3c16cd624c846f9808408057a62935 (patch)
tree7b6bcca813137f1a9492548347655a768d3ece02
parent07965463707c61274c4c8073a789cbd2a09a95ab (diff)
downloadffmpeg-a8d2b06b7c3c16cd624c846f9808408057a62935.tar.gz
Split out initialization of MDCT tables into a separate function.
Originally committed as revision 25954 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/ac3enc.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 84f6e224a7..88c2f64082 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -115,6 +115,22 @@ static av_cold void fft_init(int ln)
}
}
+static av_cold void mdct_init(int nbits)
+{
+ int i;
+ float alpha;
+ int n = 1 << nbits;
+ int n4 = n >> 2;
+
+ fft_init(nbits - 2);
+
+ for(i=0;i<n4;i++) {
+ alpha = 2 * M_PI * (i + 1.0 / 8.0) / n;
+ xcos1[i] = fix15(-cos(alpha));
+ xsin1[i] = fix15(-sin(alpha));
+ }
+}
+
/* butter fly op */
#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
{\
@@ -637,7 +653,6 @@ static av_cold int AC3_encode_init(AVCodecContext *avctx)
int bitrate = avctx->bit_rate;
AC3EncodeContext *s = avctx->priv_data;
int i, j, ch;
- float alpha;
int bw_code;
avctx->frame_size = AC3_FRAME_SIZE;
@@ -705,13 +720,7 @@ static av_cold int AC3_encode_init(AVCodecContext *avctx)
/* initial snr offset */
s->coarse_snr_offset = 40;
- /* mdct init */
- fft_init(MDCT_NBITS - 2);
- for(i=0;i<MDCT_SAMPLES/4;i++) {
- alpha = 2 * M_PI * (i + 1.0 / 8.0) / (float)MDCT_SAMPLES;
- xcos1[i] = fix15(-cos(alpha));
- xsin1[i] = fix15(-sin(alpha));
- }
+ mdct_init(9);
avctx->coded_frame= avcodec_alloc_frame();
avctx->coded_frame->key_frame= 1;