[FFmpeg-cvslog] avcodec/ac3enc: Avoid function pointers to initialize MDCT
Andreas Rheinhardt
git at videolan.org
Thu Apr 11 14:00:30 EEST 2024
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Apr 7 19:29:49 2024 +0200| [2281ab5c24448782886513cc07cff6aaa6b85bfc] | committer: Andreas Rheinhardt
avcodec/ac3enc: Avoid function pointers to initialize MDCT
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2281ab5c24448782886513cc07cff6aaa6b85bfc
---
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 --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 48ab52e49c..564c4d96f6 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2590,10 +2590,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);
}
More information about the ffmpeg-cvslog
mailing list