diff mbox series

[FFmpeg-devel,14/17] avcodec/ac3enc: Avoid function pointers to initialize MDCT

Message ID GV1P250MB0737CCEE70D970834AE7B1868F012@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 2281ab5c24448782886513cc07cff6aaa6b85bfc
Headers show
Series [FFmpeg-devel,01/17] avcodec/ac3enc: Don't presume ch_layout to be AV_CHANNEL_ORDER_NATIVE | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt April 7, 2024, 9:09 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ac3enc.c       |  4 ----
 libavcodec/ac3enc.h       |  3 ---
 libavcodec/ac3enc_fixed.c | 12 +++++++++---
 libavcodec/ac3enc_float.c |  7 ++++++-
 4 files changed, 15 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 7adb1c444a..8ad89b6a84 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2589,10 +2589,6 @@  av_cold int ff_ac3_encode_init(AVCodecContext *avctx)
 
     bit_alloc_init(s);
 
-    ret = s->mdct_init(s);
-    if (ret)
-        return ret;
-
     ret = allocate_buffers(s);
     if (ret)
         return ret;
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index 271f0eb8eb..227744d27f 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -257,9 +257,6 @@  typedef struct AC3EncodeContext {
     /** fixed vs. float function pointers */
     void (*encode_frame)(struct AC3EncodeContext *s);
 
-    /* fixed vs. float function pointers */
-    int  (*mdct_init)(struct AC3EncodeContext *s);
-
     /* AC-3 vs. E-AC-3 function pointers */
     void (*output_frame_header)(struct AC3EncodeContext *s);
 } AC3EncodeContext;
diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index b8a4d88a42..d2f4cecd72 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -74,7 +74,7 @@  static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
  * @param s  AC-3 encoder private context
  * @return   0 on success, negative error code on failure
  */
-static av_cold int ac3_fixed_mdct_init(AC3EncodeContext *s)
+static av_cold int ac3_fixed_mdct_init(AVCodecContext *avctx, AC3EncodeContext *s)
 {
     float fwin[AC3_BLOCK_SIZE];
     const float scale = -1.0f;
@@ -89,7 +89,7 @@  static av_cold int ac3_fixed_mdct_init(AC3EncodeContext *s)
 
     s->mdct_window = iwin;
 
-    s->fdsp = avpriv_alloc_fixed_dsp(s->avctx->flags & AV_CODEC_FLAG_BITEXACT);
+    s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
     if (!s->fdsp)
         return AVERROR(ENOMEM);
 
@@ -101,9 +101,15 @@  static av_cold int ac3_fixed_mdct_init(AC3EncodeContext *s)
 static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx)
 {
     AC3EncodeContext *s = avctx->priv_data;
+    int ret;
+
     s->fixed_point = 1;
     s->encode_frame            = encode_frame;
-    s->mdct_init               = ac3_fixed_mdct_init;
+
+    ret = ac3_fixed_mdct_init(avctx, s);
+    if (ret < 0)
+        return ret;
+
     return ff_ac3_encode_init(avctx);
 }
 
diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c
index cbe87dc5fe..cfd233da09 100644
--- a/libavcodec/ac3enc_float.c
+++ b/libavcodec/ac3enc_float.c
@@ -102,12 +102,17 @@  static av_cold int ac3_float_mdct_init(AC3EncodeContext *s)
 av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx)
 {
     AC3EncodeContext *s = avctx->priv_data;
+    int ret;
 
     s->encode_frame            = encode_frame;
-    s->mdct_init               = ac3_float_mdct_init;
     s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
     if (!s->fdsp)
         return AVERROR(ENOMEM);
+
+    ret = ac3_float_mdct_init(s);
+    if (ret < 0)
+        return ret;
+
     return ff_ac3_encode_init(avctx);
 }