summaryrefslogtreecommitdiff
path: root/libavcodec/pcm.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-13 00:13:43 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-17 00:09:08 +0200
commit771f91532c5cb65666820f1156b3a0e1661a3102 (patch)
tree6c180eb8a7e7e919463c218feebd71d006e1feaa /libavcodec/pcm.c
parentd3737bde639998f5a021e6fc00547ca2a7b28798 (diff)
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>
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r--libavcodec/pcm.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 96a68f7fe8..12d1b3a2c3 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -235,13 +235,15 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
typedef struct PCMDecode {
short table[256];
- AVFloatDSPContext *fdsp;
+ void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
+ int len);
float scale;
} PCMDecode;
static av_cold int pcm_decode_init(AVCodecContext *avctx)
{
PCMDecode *s = avctx->priv_data;
+ AVFloatDSPContext *fdsp;
int i;
if (avctx->channels <= 0) {
@@ -268,9 +270,11 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1));
- s->fdsp = avpriv_float_dsp_alloc(0);
- if (!s->fdsp)
+ fdsp = avpriv_float_dsp_alloc(0);
+ if (!fdsp)
return AVERROR(ENOMEM);
+ s->vector_fmul_scalar = fdsp->vector_fmul_scalar;
+ av_free(fdsp);
break;
default:
break;
@@ -284,15 +288,6 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
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
* @param size Data size of native machine format
@@ -529,9 +524,9 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
if (avctx->codec_id == AV_CODEC_ID_PCM_F16LE ||
avctx->codec_id == AV_CODEC_ID_PCM_F24LE) {
- s->fdsp->vector_fmul_scalar((float *)frame->extended_data[0],
- (const float *)frame->extended_data[0],
- s->scale, FFALIGN(frame->nb_samples * avctx->channels, 4));
+ s->vector_fmul_scalar((float *)frame->extended_data[0],
+ (const float *)frame->extended_data[0],
+ s->scale, FFALIGN(frame->nb_samples * avctx->channels, 4));
emms_c();
}
@@ -570,7 +565,6 @@ AVCodec ff_ ## name_ ## _decoder = { \
.id = AV_CODEC_ID_ ## id_, \
.priv_data_size = sizeof(PCMDecode), \
.init = pcm_decode_init, \
- .close = pcm_decode_close, \
.decode = pcm_decode_frame, \
.capabilities = AV_CODEC_CAP_DR1, \
.sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \