mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/ac3enc: Avoid function pointers to initialize MDCT
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
6c55cb95ed
commit
2281ab5c24
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user