1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avcodec/ac3enc: Avoid function pointers to initialize MDCT

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-04-07 19:29:49 +02:00
parent 6c55cb95ed
commit 2281ab5c24
4 changed files with 15 additions and 11 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}