Also apply window from the center out. Based on apply_welch_window() in lpc.c.
---
libavcodec/ac3enc.c | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git libavcodec/ac3enc.c libavcodec/ac3enc.c
index cf0a563..db1bfe9 100644
--- libavcodec/ac3enc.c
+++ libavcodec/ac3enc.c
@@ -351,9 +351,26 @@ static void lshift_tab(int16_t *tab, int n, int lshift)
}
}
+static void apply_window(int16_t *output, const int16_t *input,
+ const int16_t *window, int n)
+{
+ int i;
+ int n2 = n >> 1;
+
+ window += n2;
+ input += n2;
+ output += n2;
+
+ for (i = 0; i < n2; i++) {
+ int16_t w = window[-i-1];
+ output[-i-1] = MUL16(input[-i-1], w) >> 15;
+ output[ i ] = MUL16(input[ i ], w) >> 15;
+ }
+}
+
static void apply_mdct(AC3EncodeContext *s)
{
- int blk, ch, i, v;
+ int blk, ch, v;
for (ch = 0; ch < s->channels; ch++) {
/* fixed mdct to the six sub blocks & exponent computation */
@@ -361,12 +378,8 @@ static void apply_mdct(AC3EncodeContext *s)
int16_t *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
/* apply the MDCT window */
- for (i = 0; i < AC3_BLOCK_SIZE; i++) {
- s->windowed_samples[i] = MUL16(input_samples[i],
- ff_ac3_window[i]) >> 15;
- s->windowed_samples[AC3_BLOCK_SIZE*2-i-1] = MUL16(input_samples[AC3_BLOCK_SIZE*2-i-1],
- ff_ac3_window[i]) >> 15;
- }
+ apply_window(s->windowed_samples, input_samples, ff_ac3_window,
+ AC3_BLOCK_SIZE*2);
/* Normalize the samples to use the maximum available precision */
v = 14 - log2_tab(s->windowed_samples, AC3_BLOCK_SIZE*2);
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc