Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
---
 libavcodec/ac3enc.c          | 1 -
 libavcodec/ac3enc.h          | 5 ++++-
 libavcodec/ac3enc_fixed.c    | 7 +------
 libavcodec/ac3enc_float.c    | 7 +------
 libavcodec/ac3enc_template.c | 4 ++--
 5 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index a31b528597..a3a05b3ac8 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2183,7 +2183,6 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
     int blk, ch;
     AC3EncodeContext *s = avctx->priv_data;
 
-    av_freep(&s->mdct_window);
     if (s->planar_samples)
         for (ch = 0; ch < s->channels; ch++)
             av_freep(&s->planar_samples[ch]);
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index 618c952a18..41b9a3a20b 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -169,7 +169,6 @@ typedef struct AC3EncodeContext {
     AC3DSPContext ac3dsp;                   ///< AC-3 optimized functions
     AVTXContext *tx;                        ///< FFT context for MDCT 
calculation
     av_tx_fn tx_fn;
-    const SampleType *mdct_window;          ///< MDCT window function array
 
     AC3Block blocks[AC3_MAX_BLOCKS];        ///< per-block info
 
@@ -260,6 +259,10 @@ typedef struct AC3EncodeContext {
     /* AC-3 vs. E-AC-3 function pointers */
     void (*output_frame_header)(struct AC3EncodeContext *s);
 
+    union {
+        DECLARE_ALIGNED(32, float,   mdct_window_float)[AC3_BLOCK_SIZE];
+        DECLARE_ALIGNED(32, int32_t, mdct_window_fixed)[AC3_BLOCK_SIZE];
+    };
     union {
         DECLARE_ALIGNED(32, float,   windowed_samples_float)[AC3_WINDOW_SIZE];
         DECLARE_ALIGNED(32, int32_t, windowed_samples_fixed)[AC3_WINDOW_SIZE];
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index d2f4cecd72..869e1f27a2 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -27,7 +27,6 @@
  */
 
 #define AC3ENC_FLOAT 0
-#include "libavutil/mem.h"
 #include "audiodsp.h"
 #include "ac3enc.h"
 #include "codec_internal.h"
@@ -79,16 +78,12 @@ static av_cold int ac3_fixed_mdct_init(AVCodecContext 
*avctx, AC3EncodeContext *
     float fwin[AC3_BLOCK_SIZE];
     const float scale = -1.0f;
 
-    int32_t *iwin = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*iwin));
-    if (!iwin)
-        return AVERROR(ENOMEM);
+    int32_t *iwin = s->mdct_window_fixed;
 
     ff_kbd_window_init(fwin, 5.0, AC3_BLOCK_SIZE);
     for (int i = 0; i < AC3_BLOCK_SIZE; i++)
         iwin[i] = lrintf(fwin[i] * (1 << 22));
 
-    s->mdct_window = iwin;
-
     s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
     if (!s->fdsp)
         return AVERROR(ENOMEM);
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index cfd233da09..94e8ebc42d 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -27,7 +27,6 @@
  */
 
 #define AC3ENC_FLOAT 1
-#include "libavutil/mem.h"
 #include "audiodsp.h"
 #include "ac3enc.h"
 #include "codec_internal.h"
@@ -87,12 +86,8 @@ static void sum_square_butterfly(AC3EncodeContext *s, float 
sum[4],
 static av_cold int ac3_float_mdct_init(AC3EncodeContext *s)
 {
     const float scale = -2.0 / AC3_WINDOW_SIZE;
-    float *window = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*window));
-    if (!window)
-        return AVERROR(ENOMEM);
 
-    ff_kbd_window_init(window, 5.0, AC3_BLOCK_SIZE);
-    s->mdct_window = window;
+    ff_kbd_window_init(s->mdct_window_float, 5.0, AC3_BLOCK_SIZE);
 
     return av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_MDCT, 0,
                       AC3_BLOCK_SIZE, &scale, 0);
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 6070e14961..698042ae5c 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -59,10 +59,10 @@ static void apply_mdct(AC3EncodeContext *s)
             SampleType *windowed_samples = s->RENAME(windowed_samples);
 
             s->fdsp->vector_fmul(windowed_samples, input_samples,
-                                 s->mdct_window, AC3_BLOCK_SIZE);
+                                 s->RENAME(mdct_window), AC3_BLOCK_SIZE);
             s->fdsp->vector_fmul_reverse(windowed_samples + AC3_BLOCK_SIZE,
                                          &input_samples[AC3_BLOCK_SIZE],
-                                         s->mdct_window, AC3_BLOCK_SIZE);
+                                         s->RENAME(mdct_window), 
AC3_BLOCK_SIZE);
 
             s->tx_fn(s->tx, block->mdct_coef[ch+1],
                      windowed_samples, sizeof(*windowed_samples));
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to