summaryrefslogtreecommitdiff
path: root/libavcodec/atrac3.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-10-18 22:56:10 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-10-22 10:10:08 -0400
commit78edce3f1973cf8d611e0408b8d3681038828cfc (patch)
tree67f485f670e7d6b0d9b38541d59ad3d4e97425e9 /libavcodec/atrac3.c
parentc51311b907e0397866748d6af14b160d96c4673b (diff)
downloadffmpeg-78edce3f1973cf8d611e0408b8d3681038828cfc.tar.gz
atrac3: separate window initialization from IMDCT initialization
Diffstat (limited to 'libavcodec/atrac3.c')
-rw-r--r--libavcodec/atrac3.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 21403d293c..69b42fd07d 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -174,7 +174,7 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes)
return off;
}
-static av_cold int init_atrac3_transforms(ATRAC3Context *q)
+static av_cold void init_atrac3_window(void)
{
float enc_window[256];
int i;
@@ -184,17 +184,12 @@ static av_cold int init_atrac3_transforms(ATRAC3Context *q)
for (i = 0; i < 256; i++)
enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5;
- if (!mdct_window[0]) {
- for (i = 0; i < 256; i++) {
- mdct_window[i] = enc_window[i] /
- (enc_window[ i] * enc_window[ i] +
- enc_window[255 - i] * enc_window[255 - i]);
- mdct_window[511 - i] = mdct_window[i];
- }
+ for (i = 0; i < 256; i++) {
+ mdct_window[i] = enc_window[i] /
+ (enc_window[ i] * enc_window[ i] +
+ enc_window[255 - i] * enc_window[255 - i]);
+ mdct_window[511 - i] = mdct_window[i];
}
-
- /* initialize the MDCT transform */
- return ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768);
}
static av_cold int atrac3_decode_close(AVCodecContext *avctx)
@@ -956,12 +951,14 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
- if ((ret = init_atrac3_transforms(q))) {
+ /* initialize the MDCT transform */
+ if ((ret = ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
av_freep(&q->decoded_bytes_buffer);
return ret;
}
+ init_atrac3_window();
ff_atrac_generate_tables();
/* Generate gain tables */