1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/pcm: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoders' close function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-09-13 00:13:43 +02:00
parent d3737bde63
commit 771f91532c

View File

@ -235,13 +235,15 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
typedef struct PCMDecode { typedef struct PCMDecode {
short table[256]; short table[256];
AVFloatDSPContext *fdsp; void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
int len);
float scale; float scale;
} PCMDecode; } PCMDecode;
static av_cold int pcm_decode_init(AVCodecContext *avctx) static av_cold int pcm_decode_init(AVCodecContext *avctx)
{ {
PCMDecode *s = avctx->priv_data; PCMDecode *s = avctx->priv_data;
AVFloatDSPContext *fdsp;
int i; int i;
if (avctx->channels <= 0) { if (avctx->channels <= 0) {
@ -268,9 +270,11 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1)); s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1));
s->fdsp = avpriv_float_dsp_alloc(0); fdsp = avpriv_float_dsp_alloc(0);
if (!s->fdsp) if (!fdsp)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
s->vector_fmul_scalar = fdsp->vector_fmul_scalar;
av_free(fdsp);
break; break;
default: default:
break; break;
@ -284,15 +288,6 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
return 0; return 0;
} }
static av_cold int pcm_decode_close(AVCodecContext *avctx)
{
PCMDecode *s = avctx->priv_data;
av_freep(&s->fdsp);
return 0;
}
/** /**
* Read PCM samples macro * Read PCM samples macro
* @param size Data size of native machine format * @param size Data size of native machine format
@ -529,7 +524,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
if (avctx->codec_id == AV_CODEC_ID_PCM_F16LE || if (avctx->codec_id == AV_CODEC_ID_PCM_F16LE ||
avctx->codec_id == AV_CODEC_ID_PCM_F24LE) { avctx->codec_id == AV_CODEC_ID_PCM_F24LE) {
s->fdsp->vector_fmul_scalar((float *)frame->extended_data[0], s->vector_fmul_scalar((float *)frame->extended_data[0],
(const float *)frame->extended_data[0], (const float *)frame->extended_data[0],
s->scale, FFALIGN(frame->nb_samples * avctx->channels, 4)); s->scale, FFALIGN(frame->nb_samples * avctx->channels, 4));
emms_c(); emms_c();
@ -570,7 +565,6 @@ AVCodec ff_ ## name_ ## _decoder = { \
.id = AV_CODEC_ID_ ## id_, \ .id = AV_CODEC_ID_ ## id_, \
.priv_data_size = sizeof(PCMDecode), \ .priv_data_size = sizeof(PCMDecode), \
.init = pcm_decode_init, \ .init = pcm_decode_init, \
.close = pcm_decode_close, \
.decode = pcm_decode_frame, \ .decode = pcm_decode_frame, \
.capabilities = AV_CODEC_CAP_DR1, \ .capabilities = AV_CODEC_CAP_DR1, \
.sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ .sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \