[FFmpeg-devel] [PATCH 4/5] avcodec/on2avc: Avoid indirection when calling float dsp function
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Mon Oct 19 14:07:05 EEST 2020
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
libavcodec/on2avc.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c
index 625e733ca3..3b566e1e4b 100644
--- a/libavcodec/on2avc.c
+++ b/libavcodec/on2avc.c
@@ -46,7 +46,8 @@ enum WindowTypes {
typedef struct On2AVCContext {
AVCodecContext *avctx;
- AVFloatDSPContext *fdsp;
+ void (*vector_fmul_window)(float *dst, const float *src0,
+ const float *src1, const float *win, int len);
FFTContext mdct, mdct_half, mdct_small;
FFTContext fft128, fft256, fft512, fft1024;
void (*wtf)(struct On2AVCContext *ctx, float *out, float *in, int size);
@@ -720,7 +721,7 @@ static int on2avc_reconstruct_channel_ext(On2AVCContext *c, AVFrame *dst, int of
}
memcpy(out, saved, 448 * sizeof(float));
- c->fdsp->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
+ c->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
memcpy(wout + 128, buf + 64, 448 * sizeof(float));
memcpy(saved, buf + 512, 448 * sizeof(float));
memcpy(saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
@@ -756,20 +757,20 @@ static int on2avc_reconstruct_channel(On2AVCContext *c, int channel,
c->prev_window_type == WINDOW_TYPE_LONG_STOP) &&
(c->window_type == WINDOW_TYPE_LONG ||
c->window_type == WINDOW_TYPE_LONG_START)) {
- c->fdsp->vector_fmul_window(out, saved, buf, c->long_win, 512);
+ c->vector_fmul_window(out, saved, buf, c->long_win, 512);
} else {
float *wout = out + 448;
memcpy(out, saved, 448 * sizeof(float));
if (c->window_type == WINDOW_TYPE_8SHORT) {
- c->fdsp->vector_fmul_window(wout + 0*128, saved + 448, buf + 0*128, c->short_win, 64);
- c->fdsp->vector_fmul_window(wout + 1*128, buf + 0*128 + 64, buf + 1*128, c->short_win, 64);
- c->fdsp->vector_fmul_window(wout + 2*128, buf + 1*128 + 64, buf + 2*128, c->short_win, 64);
- c->fdsp->vector_fmul_window(wout + 3*128, buf + 2*128 + 64, buf + 3*128, c->short_win, 64);
- c->fdsp->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, c->short_win, 64);
+ c->vector_fmul_window(wout + 0*128, saved + 448, buf + 0*128, c->short_win, 64);
+ c->vector_fmul_window(wout + 1*128, buf + 0*128 + 64, buf + 1*128, c->short_win, 64);
+ c->vector_fmul_window(wout + 2*128, buf + 1*128 + 64, buf + 2*128, c->short_win, 64);
+ c->vector_fmul_window(wout + 3*128, buf + 2*128 + 64, buf + 3*128, c->short_win, 64);
+ c->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, c->short_win, 64);
memcpy(wout + 4*128, temp, 64 * sizeof(float));
} else {
- c->fdsp->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
+ c->vector_fmul_window(wout, saved + 448, buf, c->short_win, 64);
memcpy(wout + 128, buf + 64, 448 * sizeof(float));
}
}
@@ -778,9 +779,9 @@ static int on2avc_reconstruct_channel(On2AVCContext *c, int channel,
switch (c->window_type) {
case WINDOW_TYPE_8SHORT:
memcpy(saved, temp + 64, 64 * sizeof(float));
- c->fdsp->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, c->short_win, 64);
- c->fdsp->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, c->short_win, 64);
- c->fdsp->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, c->short_win, 64);
+ c->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, c->short_win, 64);
+ c->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, c->short_win, 64);
+ c->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, c->short_win, 64);
memcpy(saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
break;
case WINDOW_TYPE_LONG_START:
@@ -906,6 +907,7 @@ static av_cold void on2avc_free_vlcs(On2AVCContext *c)
static av_cold int on2avc_decode_init(AVCodecContext *avctx)
{
On2AVCContext *c = avctx->priv_data;
+ AVFloatDSPContext *fdsp;
int i;
if (avctx->channels > 2U) {
@@ -952,9 +954,11 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx)
ff_fft_init(&c->fft256, 7, 0);
ff_fft_init(&c->fft512, 8, 1);
ff_fft_init(&c->fft1024, 9, 1);
- c->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
- if (!c->fdsp)
+ fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+ if (!fdsp)
return AVERROR(ENOMEM);
+ c->vector_fmul_window = fdsp->vector_fmul_window;
+ av_free(fdsp);
if (init_vlc(&c->scale_diff, 9, ON2AVC_SCALE_DIFFS,
ff_on2avc_scale_diff_bits, 1, 1,
@@ -975,7 +979,6 @@ static av_cold int on2avc_decode_init(AVCodecContext *avctx)
vlc_fail:
av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n");
on2avc_free_vlcs(c);
- av_freep(&c->fdsp);
return AVERROR(ENOMEM);
}
@@ -991,8 +994,6 @@ static av_cold int on2avc_decode_close(AVCodecContext *avctx)
ff_fft_end(&c->fft512);
ff_fft_end(&c->fft1024);
- av_freep(&c->fdsp);
-
on2avc_free_vlcs(c);
return 0;
--
2.25.1
More information about the ffmpeg-devel
mailing list