Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- The mdct_init and allocate_sample_buffers function pointers could actually be completely avoided by allocating the buffers in the respective init functions after ff_ac3_encode_init() has returned. The end of allocate_buffers() (which already differs based upon whether fixed_point is set or not) could also be moved there.
libavcodec/ac3enc.c | 13 +------------ libavcodec/ac3enc.h | 12 ------------ libavcodec/ac3enc_fixed.c | 7 +++++-- libavcodec/ac3enc_float.c | 7 +++++-- libavcodec/ac3enc_template.c | 2 +- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 3354bf6b45..30f6ca9dce 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2048,8 +2048,7 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) av_freep(&block->cpl_coord_mant); } - if (s->mdct_end) - s->mdct_end(s); + s->mdct_end(s); return 0; } @@ -2436,16 +2435,6 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) s->crc_inv[1] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY); } - /* set function pointers */ - if (CONFIG_AC3_FIXED_ENCODER && s->fixed_point) { - s->mdct_end = ff_ac3_fixed_mdct_end; - s->mdct_init = ff_ac3_fixed_mdct_init; - s->allocate_sample_buffers = ff_ac3_fixed_allocate_sample_buffers; - } else if (CONFIG_AC3_ENCODER || CONFIG_EAC3_ENCODER) { - s->mdct_end = ff_ac3_float_mdct_end; - s->mdct_init = ff_ac3_float_mdct_init; - s->allocate_sample_buffers = ff_ac3_float_allocate_sample_buffers; - } if (CONFIG_EAC3_ENCODER && s->eac3) { static AVOnce init_static_once = AV_ONCE_INIT; ff_thread_once(&init_static_once, ff_eac3_exponent_init); diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 1e4a7405bf..b4e566b4ef 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -295,20 +295,8 @@ void ff_ac3_quantize_mantissas(AC3EncodeContext *s); void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame); -/* prototypes for functions in ac3enc_fixed.c and ac3enc_float.c */ - -void ff_ac3_fixed_mdct_end(AC3EncodeContext *s); -void ff_ac3_float_mdct_end(AC3EncodeContext *s); - -int ff_ac3_fixed_mdct_init(AC3EncodeContext *s); -int ff_ac3_float_mdct_init(AC3EncodeContext *s); - - /* prototypes for functions in ac3enc_template.c */ -int ff_ac3_fixed_allocate_sample_buffers(AC3EncodeContext *s); -int ff_ac3_float_allocate_sample_buffers(AC3EncodeContext *s); - int ff_ac3_fixed_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); int ff_ac3_float_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index d2e67f3214..879e364d4e 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -115,7 +115,7 @@ static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl) * * @param s AC-3 encoder private context */ -av_cold void ff_ac3_fixed_mdct_end(AC3EncodeContext *s) +static av_cold void ac3_fixed_mdct_end(AC3EncodeContext *s) { ff_mdct_end(&s->mdct); } @@ -127,7 +127,7 @@ av_cold void ff_ac3_fixed_mdct_end(AC3EncodeContext *s) * @param s AC-3 encoder private context * @return 0 on success, negative error code on failure */ -av_cold int ff_ac3_fixed_mdct_init(AC3EncodeContext *s) +static av_cold int ac3_fixed_mdct_init(AC3EncodeContext *s) { int ret = ff_mdct_init(&s->mdct, 9, 0, -1.0); s->mdct_window = ff_ac3_window; @@ -139,6 +139,9 @@ static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; s->fixed_point = 1; + s->mdct_end = ac3_fixed_mdct_end; + s->mdct_init = ac3_fixed_mdct_init; + s->allocate_sample_buffers = allocate_sample_buffers; return ff_ac3_encode_init(avctx); } diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 571f603182..ef23b417cf 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -94,7 +94,7 @@ static void sum_square_butterfly(AC3EncodeContext *s, float sum[4], * * @param s AC-3 encoder private context */ -av_cold void ff_ac3_float_mdct_end(AC3EncodeContext *s) +static av_cold void ac3_float_mdct_end(AC3EncodeContext *s) { ff_mdct_end(&s->mdct); av_freep(&s->mdct_window); @@ -107,7 +107,7 @@ av_cold void ff_ac3_float_mdct_end(AC3EncodeContext *s) * @param s AC-3 encoder private context * @return 0 on success, negative error code on failure */ -av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s) +static av_cold int ac3_float_mdct_init(AC3EncodeContext *s) { float *window; int i, n, n2; @@ -132,6 +132,9 @@ av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s) av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; + s->mdct_end = ac3_float_mdct_end; + s->mdct_init = ac3_float_mdct_init; + s->allocate_sample_buffers = allocate_sample_buffers; s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index b85fe51ef5..da5d67afc9 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -37,7 +37,7 @@ #include "eac3enc.h" -int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s) +static int allocate_sample_buffers(AC3EncodeContext *s) { int ch; -- 2.25.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".