[FFmpeg-cvslog] atrac3: simplify MDCT window calculation

Justin Ruggles git at videolan.org
Tue Oct 23 13:12:07 CEST 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Thu Oct 18 23:11:20 2012 -0400| [327747de15be919f8060e12a2e82afa37500629f] | committer: Justin Ruggles

atrac3: simplify MDCT window calculation

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=327747de15be919f8060e12a2e82afa37500629f
---

 libavcodec/atrac3.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 9e0f273..76e251b 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -177,19 +177,16 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes)
 
 static av_cold void init_atrac3_window(void)
 {
-    float enc_window[256];
-    int i;
+    int i, j;
 
     /* generate the mdct window, for details see
      * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */
-    for (i = 0; i < 256; i++)
-        enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5;
-
-    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, j = 255; i < 128; i++, j--) {
+        float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
+        float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
+        float w  = 0.5 * (wi * wi + wj * wj);
+        mdct_window[i] = mdct_window[511 - i] = wi / w;
+        mdct_window[j] = mdct_window[511 - j] = wj / w;
     }
 }
 



More information about the ffmpeg-cvslog mailing list