[libav-commits] atrac3: separate window initialization from IMDCT initialization

Justin Ruggles git at libav.org
Mon Oct 22 16:09:43 CEST 2012


Module: libav
Branch: master
Commit: 78edce3f1973cf8d611e0408b8d3681038828cfc

Author:    Justin Ruggles <justin.ruggles at gmail.com>
Committer: Justin Ruggles <justin.ruggles at gmail.com>
Date:      Thu Oct 18 22:56:10 2012 -0400

atrac3: separate window initialization from IMDCT initialization

---

 libavcodec/atrac3.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 21403d2..69b42fd 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 */



More information about the libav-commits mailing list