aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mdct15.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2017-07-29 21:27:01 +0100
committerRostislav Pehlivanov <atomnuker@gmail.com>2017-07-30 07:38:39 +0100
commit70eb77b34e9f08cd5e431921a2792f31e4b5265c (patch)
treedc163df43e5fa5c29176cc88a5ae261825c625af /libavcodec/mdct15.c
parentb0c61209cd30f9ddf3356d5ded6df488f25d1bd5 (diff)
downloadffmpeg-70eb77b34e9f08cd5e431921a2792f31e4b5265c.tar.gz
mdct15: add inverse transform postrotation SIMD
2.5ms frames: Before (c): 2638 decicycles in postrotate, 2097040 runs, 112 skips After (sse3): 1467 decicycles in postrotate, 2097083 runs, 69 skips After (avx2): 1244 decicycles in postrotate, 2097085 runs, 67 skips 5ms frames: Before (c): 4987 decicycles in postrotate, 1048371 runs, 205 skips After (sse3): 2644 decicycles in postrotate, 1048509 runs, 67 skips After (avx2): 2031 decicycles in postrotate, 1048523 runs, 53 skips 10ms frames: Before (c): 9153 decicycles in postrotate, 523575 runs, 713 skips After (sse3): 5110 decicycles in postrotate, 523726 runs, 562 skips After (avx2): 3738 decicycles in postrotate, 524223 runs, 65 skips 20ms frames: Before (c): 17857 decicycles in postrotate, 261866 runs, 278 skips After (sse3): 10041 decicycles in postrotate, 261746 runs, 398 skips After (avx2): 7050 decicycles in postrotate, 262116 runs, 28 skips Improves total decoding performance for real world content by 9% with avx2. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/mdct15.c')
-rw-r--r--libavcodec/mdct15.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/libavcodec/mdct15.c b/libavcodec/mdct15.c
index d68372c344..6f35059bfe 100644
--- a/libavcodec/mdct15.c
+++ b/libavcodec/mdct15.c
@@ -65,11 +65,11 @@ static inline int init_pfa_reindex_tabs(MDCT15Context *s)
const int inv_1 = l_ptwo << ((4 - b_ptwo) & 3); /* (2^b_ptwo)^-1 mod 15 */
const int inv_2 = 0xeeeeeeef & ((1U << b_ptwo) - 1); /* 15^-1 mod 2^b_ptwo */
- s->pfa_prereindex = av_malloc(15 * l_ptwo * sizeof(*s->pfa_prereindex));
+ s->pfa_prereindex = av_malloc_array(15 * l_ptwo, sizeof(*s->pfa_prereindex));
if (!s->pfa_prereindex)
return 1;
- s->pfa_postreindex = av_malloc(15 * l_ptwo * sizeof(*s->pfa_postreindex));
+ s->pfa_postreindex = av_malloc_array(15 * l_ptwo, sizeof(*s->pfa_postreindex));
if (!s->pfa_postreindex)
return 1;
@@ -226,14 +226,21 @@ static void imdct15_half(MDCT15Context *s, float *dst, const float *src,
s->ptwo_fft.fft_calc(&s->ptwo_fft, s->tmp + l_ptwo*i);
/* Reindex again, apply twiddles and output */
+ s->postreindex(z, s->tmp, s->twiddle_exptab, s->pfa_postreindex, len8);
+}
+
+static void postrotate_c(FFTComplex *out, FFTComplex *in, FFTComplex *exp,
+ int *lut, ptrdiff_t len8)
+{
+ int i;
+
+ /* Reindex again, apply twiddles and output */
for (i = 0; i < len8; i++) {
const int i0 = len8 + i, i1 = len8 - i - 1;
- const int s0 = s->pfa_postreindex[i0], s1 = s->pfa_postreindex[i1];
+ const int s0 = lut[i0], s1 = lut[i1];
- CMUL(z[i1].re, z[i0].im, s->tmp[s1].im, s->tmp[s1].re,
- s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re);
- CMUL(z[i0].re, z[i1].im, s->tmp[s0].im, s->tmp[s0].re,
- s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re);
+ CMUL(out[i1].re, out[i0].im, in[s1].im, in[s1].re, exp[i1].im, exp[i1].re);
+ CMUL(out[i0].re, out[i1].im, in[s0].im, in[s0].re, exp[i0].im, exp[i0].re);
}
}
@@ -253,13 +260,14 @@ av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
if (!s)
return AVERROR(ENOMEM);
- s->fft_n = N - 1;
- s->len4 = len2 / 2;
- s->len2 = len2;
- s->inverse = inverse;
- s->fft15 = fft15_c;
- s->mdct = mdct15;
- s->imdct_half = imdct15_half;
+ s->fft_n = N - 1;
+ s->len4 = len2 / 2;
+ s->len2 = len2;
+ s->inverse = inverse;
+ s->fft15 = fft15_c;
+ s->mdct = mdct15;
+ s->imdct_half = imdct15_half;
+ s->postreindex = postrotate_c;
if (ff_fft_init(&s->ptwo_fft, N - 1, s->inverse) < 0)
goto fail;
@@ -271,7 +279,7 @@ av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
if (!s->tmp)
goto fail;
- s->twiddle_exptab = av_malloc_array(s->len4, sizeof(*s->twiddle_exptab));
+ s->twiddle_exptab = av_malloc_array(s->len4, sizeof(*s->twiddle_exptab));
if (!s->twiddle_exptab)
goto fail;