diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-10-19 07:11:20 +0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-10-22 18:10:08 +0400 |
commit | 327747de15be919f8060e12a2e82afa37500629f (patch) | |
tree | 2fd90990af050c243b76d34ebfd44b3f8a970578 | |
parent | 5d1007f74dd496d54b932242004382f44e3b22b4 (diff) |
atrac3: simplify MDCT window calculation
-rw-r--r-- | libavcodec/atrac3.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 9e0f27332e..76e251ba1c 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; } } |