Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2022-09-24 01:46:44 +0300
committerLynne <dev@lynne.ee>2022-09-26 21:26:54 +0300
commit543a46b4b2ff0f02fa85e45d7b7bcda19d3be9b4 (patch)
tree0eab3a15b25135cdeb66087ac54b1f3355744d97 /libavcodec/opusenc.c
parentdd2ea014ef273157fe9a0e928e77841fbbee9b2f (diff)
opus: convert encoder and decoder to lavu/tx
This commit changes both the encoder and decoder to use the new lavu/tx code, which has faster C transforms and more assembly optimizations.
Diffstat (limited to 'libavcodec/opusenc.c')
-rw-r--r--libavcodec/opusenc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index a7a9d3a5f5..8cdd27d930 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -40,7 +40,8 @@ typedef struct OpusEncContext {
AVCodecContext *avctx;
AudioFrameQueue afq;
AVFloatDSPContext *dsp;
- MDCT15Context *mdct[CELT_BLOCK_NB];
+ AVTXContext *tx[CELT_BLOCK_NB];
+ av_tx_fn tx_fn[CELT_BLOCK_NB];
CeltPVQ *pvq;
struct FFBufQueue bufqueue;
@@ -204,7 +205,7 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f)
s->dsp->vector_fmul_reverse(&win[CELT_OVERLAP], src2,
ff_celt_window - 8, 128);
src1 = src2;
- s->mdct[0]->mdct(s->mdct[0], b->coeffs + t, win, f->blocks);
+ s->tx_fn[0](s->tx[0], b->coeffs + t, win, sizeof(float)*f->blocks);
}
}
} else {
@@ -226,7 +227,7 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f)
ff_celt_window - 8, 128);
memcpy(win + lap_dst + blk_len, temp, CELT_OVERLAP*sizeof(float));
- s->mdct[f->size]->mdct(s->mdct[f->size], b->coeffs, win, 1);
+ s->tx_fn[f->size](s->tx[f->size], b->coeffs, win, sizeof(float));
}
}
@@ -612,7 +613,7 @@ static av_cold int opus_encode_end(AVCodecContext *avctx)
OpusEncContext *s = avctx->priv_data;
for (int i = 0; i < CELT_BLOCK_NB; i++)
- ff_mdct15_uninit(&s->mdct[i]);
+ av_tx_uninit(&s->tx[i]);
ff_celt_pvq_uninit(&s->pvq);
av_freep(&s->dsp);
@@ -668,9 +669,11 @@ static av_cold int opus_encode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM);
/* I have no idea why a base scaling factor of 68 works, could be the twiddles */
- for (int i = 0; i < CELT_BLOCK_NB; i++)
- if ((ret = ff_mdct15_init(&s->mdct[i], 0, i + 3, 68 << (CELT_BLOCK_NB - 1 - i))))
+ for (int i = 0; i < CELT_BLOCK_NB; i++) {
+ const float scale = 68 << (CELT_BLOCK_NB - 1 - i);
+ if ((ret = av_tx_init(&s->tx[i], &s->tx_fn[i], AV_TX_FLOAT_MDCT, 0, 15 << (i + 3), &scale, 0)))
return AVERROR(ENOMEM);
+ }
/* Zero out previous energy (matters for inter first frame) */
for (int ch = 0; ch < s->channels; ch++)