mirror of https://github.com/FFmpeg/FFmpeg.git
It's not needed nor used by anything anymore, lavu/tx is faster, and better in every way. RIP.pull/388/head
parent
774ea6a00b
commit
b85e106d5f
8 changed files with 0 additions and 727 deletions
@ -1,331 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2013-2014 Mozilla Corporation |
||||
* Copyright (c) 2017 Rostislav Pehlivanov <atomnuker@gmail.com> |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* Celt non-power of 2 iMDCT |
||||
*/ |
||||
|
||||
#include <float.h> |
||||
#include <math.h> |
||||
#include <stddef.h> |
||||
#include <stdint.h> |
||||
|
||||
#include "config.h" |
||||
|
||||
#include "libavutil/attributes.h" |
||||
#include "libavutil/error.h" |
||||
|
||||
#include "mdct15.h" |
||||
|
||||
#define FFT_FLOAT 1 |
||||
#include "fft-internal.h" |
||||
|
||||
#define CMUL3(c, a, b) CMUL((c).re, (c).im, (a).re, (a).im, (b).re, (b).im) |
||||
|
||||
av_cold void ff_mdct15_uninit(MDCT15Context **ps) |
||||
{ |
||||
MDCT15Context *s = *ps; |
||||
|
||||
if (!s) |
||||
return; |
||||
|
||||
ff_fft_end(&s->ptwo_fft); |
||||
|
||||
av_freep(&s->pfa_prereindex); |
||||
av_freep(&s->pfa_postreindex); |
||||
av_freep(&s->twiddle_exptab); |
||||
av_freep(&s->tmp); |
||||
|
||||
av_freep(ps); |
||||
} |
||||
|
||||
static inline int init_pfa_reindex_tabs(MDCT15Context *s) |
||||
{ |
||||
int i, j; |
||||
const int b_ptwo = s->ptwo_fft.nbits; /* Bits for the power of two FFTs */ |
||||
const int l_ptwo = 1 << b_ptwo; /* Total length for the power of two FFTs */ |
||||
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_array(15 * l_ptwo, sizeof(*s->pfa_prereindex)); |
||||
if (!s->pfa_prereindex) |
||||
return 1; |
||||
|
||||
s->pfa_postreindex = av_malloc_array(15 * l_ptwo, sizeof(*s->pfa_postreindex)); |
||||
if (!s->pfa_postreindex) |
||||
return 1; |
||||
|
||||
/* Pre/Post-reindex */ |
||||
for (i = 0; i < l_ptwo; i++) { |
||||
for (j = 0; j < 15; j++) { |
||||
const int q_pre = ((l_ptwo * j)/15 + i) >> b_ptwo; |
||||
const int q_post = (((j*inv_1)/15) + (i*inv_2)) >> b_ptwo; |
||||
const int k_pre = 15*i + (j - q_pre*15)*(1 << b_ptwo); |
||||
const int k_post = i*inv_2*15 + j*inv_1 - 15*q_post*l_ptwo; |
||||
s->pfa_prereindex[i*15 + j] = k_pre << 1; |
||||
s->pfa_postreindex[k_post] = l_ptwo*j + i; |
||||
} |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/* Stride is hardcoded to 3 */ |
||||
static inline void fft5(FFTComplex *out, FFTComplex *in, FFTComplex exptab[2]) |
||||
{ |
||||
FFTComplex z0[4], t[6]; |
||||
|
||||
t[0].re = in[3].re + in[12].re; |
||||
t[0].im = in[3].im + in[12].im; |
||||
t[1].im = in[3].re - in[12].re; |
||||
t[1].re = in[3].im - in[12].im; |
||||
t[2].re = in[6].re + in[ 9].re; |
||||
t[2].im = in[6].im + in[ 9].im; |
||||
t[3].im = in[6].re - in[ 9].re; |
||||
t[3].re = in[6].im - in[ 9].im; |
||||
|
||||
out[0].re = in[0].re + in[3].re + in[6].re + in[9].re + in[12].re; |
||||
out[0].im = in[0].im + in[3].im + in[6].im + in[9].im + in[12].im; |
||||
|
||||
t[4].re = exptab[0].re * t[2].re - exptab[1].re * t[0].re; |
||||
t[4].im = exptab[0].re * t[2].im - exptab[1].re * t[0].im; |
||||
t[0].re = exptab[0].re * t[0].re - exptab[1].re * t[2].re; |
||||
t[0].im = exptab[0].re * t[0].im - exptab[1].re * t[2].im; |
||||
t[5].re = exptab[0].im * t[3].re - exptab[1].im * t[1].re; |
||||
t[5].im = exptab[0].im * t[3].im - exptab[1].im * t[1].im; |
||||
t[1].re = exptab[0].im * t[1].re + exptab[1].im * t[3].re; |
||||
t[1].im = exptab[0].im * t[1].im + exptab[1].im * t[3].im; |
||||
|
||||
z0[0].re = t[0].re - t[1].re; |
||||
z0[0].im = t[0].im - t[1].im; |
||||
z0[1].re = t[4].re + t[5].re; |
||||
z0[1].im = t[4].im + t[5].im; |
||||
|
||||
z0[2].re = t[4].re - t[5].re; |
||||
z0[2].im = t[4].im - t[5].im; |
||||
z0[3].re = t[0].re + t[1].re; |
||||
z0[3].im = t[0].im + t[1].im; |
||||
|
||||
out[1].re = in[0].re + z0[3].re; |
||||
out[1].im = in[0].im + z0[0].im; |
||||
out[2].re = in[0].re + z0[2].re; |
||||
out[2].im = in[0].im + z0[1].im; |
||||
out[3].re = in[0].re + z0[1].re; |
||||
out[3].im = in[0].im + z0[2].im; |
||||
out[4].re = in[0].re + z0[0].re; |
||||
out[4].im = in[0].im + z0[3].im; |
||||
} |
||||
|
||||
static void fft15_c(FFTComplex *out, FFTComplex *in, FFTComplex *exptab, ptrdiff_t stride) |
||||
{ |
||||
int k; |
||||
FFTComplex tmp1[5], tmp2[5], tmp3[5]; |
||||
|
||||
fft5(tmp1, in + 0, exptab + 19); |
||||
fft5(tmp2, in + 1, exptab + 19); |
||||
fft5(tmp3, in + 2, exptab + 19); |
||||
|
||||
for (k = 0; k < 5; k++) { |
||||
FFTComplex t[2]; |
||||
|
||||
CMUL3(t[0], tmp2[k], exptab[k]); |
||||
CMUL3(t[1], tmp3[k], exptab[2 * k]); |
||||
out[stride*k].re = tmp1[k].re + t[0].re + t[1].re; |
||||
out[stride*k].im = tmp1[k].im + t[0].im + t[1].im; |
||||
|
||||
CMUL3(t[0], tmp2[k], exptab[k + 5]); |
||||
CMUL3(t[1], tmp3[k], exptab[2 * (k + 5)]); |
||||
out[stride*(k + 5)].re = tmp1[k].re + t[0].re + t[1].re; |
||||
out[stride*(k + 5)].im = tmp1[k].im + t[0].im + t[1].im; |
||||
|
||||
CMUL3(t[0], tmp2[k], exptab[k + 10]); |
||||
CMUL3(t[1], tmp3[k], exptab[2 * k + 5]); |
||||
out[stride*(k + 10)].re = tmp1[k].re + t[0].re + t[1].re; |
||||
out[stride*(k + 10)].im = tmp1[k].im + t[0].im + t[1].im; |
||||
} |
||||
} |
||||
|
||||
static void mdct15(MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride) |
||||
{ |
||||
int i, j; |
||||
const int len4 = s->len4, len3 = len4 * 3, len8 = len4 >> 1; |
||||
const int l_ptwo = 1 << s->ptwo_fft.nbits; |
||||
FFTComplex fft15in[15]; |
||||
|
||||
/* Folding and pre-reindexing */ |
||||
for (i = 0; i < l_ptwo; i++) { |
||||
for (j = 0; j < 15; j++) { |
||||
const int k = s->pfa_prereindex[i*15 + j]; |
||||
FFTComplex tmp, exp = s->twiddle_exptab[k >> 1]; |
||||
if (k < len4) { |
||||
tmp.re = -src[ len4 + k] + src[1*len4 - 1 - k]; |
||||
tmp.im = -src[ len3 + k] - src[1*len3 - 1 - k]; |
||||
} else { |
||||
tmp.re = -src[ len4 + k] - src[5*len4 - 1 - k]; |
||||
tmp.im = src[-len4 + k] - src[1*len3 - 1 - k]; |
||||
} |
||||
CMUL(fft15in[j].im, fft15in[j].re, tmp.re, tmp.im, exp.re, exp.im); |
||||
} |
||||
s->fft15(s->tmp + s->ptwo_fft.revtab[i], fft15in, s->exptab, l_ptwo); |
||||
} |
||||
|
||||
/* Then a 15xN FFT (where N is a power of two) */ |
||||
for (i = 0; i < 15; i++) |
||||
s->ptwo_fft.fft_calc(&s->ptwo_fft, s->tmp + l_ptwo*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]; |
||||
|
||||
CMUL(dst[2*i1*stride + stride], dst[2*i0*stride], s->tmp[s0].re, s->tmp[s0].im, |
||||
s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re); |
||||
CMUL(dst[2*i0*stride + stride], dst[2*i1*stride], s->tmp[s1].re, s->tmp[s1].im, |
||||
s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re); |
||||
} |
||||
} |
||||
|
||||
static void imdct15_half(MDCT15Context *s, float *dst, const float *src, |
||||
ptrdiff_t stride) |
||||
{ |
||||
FFTComplex fft15in[15]; |
||||
FFTComplex *z = (FFTComplex *)dst; |
||||
int i, j, len8 = s->len4 >> 1, l_ptwo = 1 << s->ptwo_fft.nbits; |
||||
const float *in1 = src, *in2 = src + (s->len2 - 1) * stride; |
||||
|
||||
/* Reindex input, putting it into a buffer and doing an Nx15 FFT */ |
||||
for (i = 0; i < l_ptwo; i++) { |
||||
for (j = 0; j < 15; j++) { |
||||
const int k = s->pfa_prereindex[i*15 + j]; |
||||
FFTComplex tmp = { in2[-k*stride], in1[k*stride] }; |
||||
CMUL3(fft15in[j], tmp, s->twiddle_exptab[k >> 1]); |
||||
} |
||||
s->fft15(s->tmp + s->ptwo_fft.revtab[i], fft15in, s->exptab, l_ptwo); |
||||
} |
||||
|
||||
/* Then a 15xN FFT (where N is a power of two) */ |
||||
for (i = 0; i < 15; i++) |
||||
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 = lut[i0], s1 = lut[i1]; |
||||
|
||||
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); |
||||
} |
||||
} |
||||
|
||||
av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale) |
||||
{ |
||||
MDCT15Context *s; |
||||
double alpha, theta; |
||||
int len2 = 15 * (1 << N); |
||||
int len = 2 * len2; |
||||
int i; |
||||
|
||||
/* Tested and verified to work on everything in between */ |
||||
if ((N < 2) || (N > 13)) |
||||
return AVERROR(EINVAL); |
||||
|
||||
s = av_mallocz(sizeof(*s)); |
||||
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->postreindex = postrotate_c; |
||||
|
||||
if (ff_fft_init(&s->ptwo_fft, N - 1, s->inverse) < 0) |
||||
goto fail; |
||||
|
||||
if (init_pfa_reindex_tabs(s)) |
||||
goto fail; |
||||
|
||||
s->tmp = av_malloc_array(len, 2 * sizeof(*s->tmp)); |
||||
if (!s->tmp) |
||||
goto fail; |
||||
|
||||
s->twiddle_exptab = av_malloc_array(s->len4, sizeof(*s->twiddle_exptab)); |
||||
if (!s->twiddle_exptab) |
||||
goto fail; |
||||
|
||||
theta = 0.125f + (scale < 0 ? s->len4 : 0); |
||||
scale = sqrt(fabs(scale)); |
||||
for (i = 0; i < s->len4; i++) { |
||||
alpha = 2 * M_PI * (i + theta) / len; |
||||
s->twiddle_exptab[i].re = cosf(alpha) * scale; |
||||
s->twiddle_exptab[i].im = sinf(alpha) * scale; |
||||
} |
||||
|
||||
/* 15-point FFT exptab */ |
||||
for (i = 0; i < 19; i++) { |
||||
if (i < 15) { |
||||
double theta = (2.0f * M_PI * i) / 15.0f; |
||||
if (!s->inverse) |
||||
theta *= -1; |
||||
s->exptab[i].re = cosf(theta); |
||||
s->exptab[i].im = sinf(theta); |
||||
} else { /* Wrap around to simplify fft15 */ |
||||
s->exptab[i] = s->exptab[i - 15]; |
||||
} |
||||
} |
||||
|
||||
/* 5-point FFT exptab */ |
||||
s->exptab[19].re = cosf(2.0f * M_PI / 5.0f); |
||||
s->exptab[19].im = sinf(2.0f * M_PI / 5.0f); |
||||
s->exptab[20].re = cosf(1.0f * M_PI / 5.0f); |
||||
s->exptab[20].im = sinf(1.0f * M_PI / 5.0f); |
||||
|
||||
/* Invert the phase for an inverse transform, do nothing for a forward transform */ |
||||
if (s->inverse) { |
||||
s->exptab[19].im *= -1; |
||||
s->exptab[20].im *= -1; |
||||
} |
||||
|
||||
#if ARCH_X86 |
||||
ff_mdct15_init_x86(s); |
||||
#endif |
||||
|
||||
*ps = s; |
||||
|
||||
return 0; |
||||
|
||||
fail: |
||||
ff_mdct15_uninit(&s); |
||||
return AVERROR(ENOMEM); |
||||
} |
@ -1,64 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2017 Rostislav Pehlivanov <atomnuker@gmail.com> |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#ifndef AVCODEC_MDCT15_H |
||||
#define AVCODEC_MDCT15_H |
||||
|
||||
#include <stddef.h> |
||||
|
||||
#include "libavutil/mem_internal.h" |
||||
|
||||
#include "fft.h" |
||||
|
||||
typedef struct MDCT15Context { |
||||
int fft_n; |
||||
int len2; |
||||
int len4; |
||||
int inverse; |
||||
int *pfa_prereindex; |
||||
int *pfa_postreindex; |
||||
|
||||
FFTContext ptwo_fft; |
||||
FFTComplex *tmp; |
||||
FFTComplex *twiddle_exptab; |
||||
|
||||
DECLARE_ALIGNED(32, FFTComplex, exptab)[64]; |
||||
|
||||
/* 15-point FFT */ |
||||
void (*fft15)(FFTComplex *out, FFTComplex *in, FFTComplex *exptab, ptrdiff_t stride); |
||||
|
||||
/* PFA postrotate and exptab */ |
||||
void (*postreindex)(FFTComplex *out, FFTComplex *in, FFTComplex *exp, int *lut, ptrdiff_t len8); |
||||
|
||||
/* Calculate a full 2N -> N MDCT */ |
||||
void (*mdct)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride); |
||||
|
||||
/* Calculate the middle half of the iMDCT */ |
||||
void (*imdct_half)(struct MDCT15Context *s, float *dst, const float *src, |
||||
ptrdiff_t stride); |
||||
} MDCT15Context; |
||||
|
||||
/* Init an (i)MDCT of the length 2 * 15 * (2^N) */ |
||||
int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale); |
||||
void ff_mdct15_uninit(MDCT15Context **ps); |
||||
|
||||
void ff_mdct15_init_x86(MDCT15Context *s); |
||||
|
||||
#endif /* AVCODEC_MDCT15_H */ |
@ -1,221 +0,0 @@ |
||||
;****************************************************************************** |
||||
;* SIMD optimized non-power-of-two MDCT functions |
||||
;* |
||||
;* Copyright (C) 2017 Rostislav Pehlivanov <atomnuker@gmail.com> |
||||
;* |
||||
;* This file is part of FFmpeg. |
||||
;* |
||||
;* FFmpeg is free software; you can redistribute it and/or |
||||
;* modify it under the terms of the GNU Lesser General Public |
||||
;* License as published by the Free Software Foundation; either |
||||
;* version 2.1 of the License, or (at your option) any later version. |
||||
;* |
||||
;* FFmpeg is distributed in the hope that it will be useful, |
||||
;* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
;* Lesser General Public License for more details. |
||||
;* |
||||
;* You should have received a copy of the GNU Lesser General Public |
||||
;* License along with FFmpeg; if not, write to the Free Software |
||||
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
;****************************************************************************** |
||||
|
||||
%include "libavutil/x86/x86util.asm" |
||||
|
||||
SECTION_RODATA 32 |
||||
|
||||
perm_neg: dd 2, 5, 3, 4, 6, 1, 7, 0 |
||||
perm_pos: dd 0, 7, 1, 6, 4, 3, 5, 2 |
||||
sign_adjust_r: times 4 dd 0x80000000, 0x00000000 |
||||
|
||||
sign_adjust_5: dd 0x00000000, 0x80000000, 0x80000000, 0x00000000 |
||||
|
||||
SECTION .text |
||||
|
||||
%if ARCH_X86_64 |
||||
|
||||
;***************************************************************************************** |
||||
;void ff_fft15_avx(FFTComplex *out, FFTComplex *in, FFTComplex *exptab, ptrdiff_t stride); |
||||
;***************************************************************************************** |
||||
%macro FFT5 3 ; %1 - in_offset, %2 - dst1 (64bit used), %3 - dst2 |
||||
VBROADCASTSD m0, [inq + %1] ; in[ 0].re, in[ 0].im, in[ 0].re, in[ 0].im |
||||
movsd xm1, [inq + 1*16 + 8 + %1] ; in[ 3].re, in[ 3].im, 0, 0 |
||||
movsd xm4, [inq + 6*16 + 0 + %1] ; in[12].re, in[12].im, 0, 0 |
||||
movhps xm1, [inq + 3*16 + 0 + %1] ; in[ 3].re, in[ 3].im, in[ 6].re, in[ 6].im |
||||
movhps xm4, [inq + 4*16 + 8 + %1] ; in[12].re, in[12].im, in[ 9].re, in[ 9].im |
||||
|
||||
subps xm2, xm1, xm4 ; t[2].im, t[2].re, t[3].im, t[3].re |
||||
addps xm1, xm4 ; t[0].re, t[0].im, t[1].re, t[1].im |
||||
|
||||
movhlps %2, xm1 ; t[0].re, t[1].re, t[0].im, t[1].im |
||||
addps %2, xm1 |
||||
addps %2, xm0 ; DC[0].re, DC[0].im, junk... |
||||
movlhps %2, %2 ; DC[0].re, DC[0].im, DC[0].re, DC[0].im |
||||
|
||||
shufps xm3, xm1, xm2, q0110 ; t[0].re, t[0].im, t[2].re, t[2].im |
||||
shufps xm1, xm2, q2332 ; t[1].re, t[1].im, t[3].re, t[3].im |
||||
|
||||
mulps xm%3, xm1, xm5 |
||||
mulps xm4, xm3, xm6 |
||||
mulps xm1, xm6 |
||||
|
||||
xorps xm1, xm7 |
||||
mulps xm3, xm5 |
||||
addsubps xm3, xm1 ; t[0].re, t[0].im, t[2].re, t[2].im |
||||
subps xm%3, xm4 ; t[4].re, t[4].im, t[5].re, t[5].im |
||||
|
||||
movhlps xm2, xm%3, xm3 ; t[2].re, t[2].im, t[5].re, t[5].im |
||||
movlhps xm3, xm%3 ; t[0].re, t[0].im, t[4].re, t[4].im |
||||
|
||||
xorps xm2, xm7 |
||||
addps xm%3, xm2, xm3 |
||||
subps xm3, xm2 |
||||
|
||||
shufps xm3, xm3, q1032 |
||||
vinsertf128 m%3, m%3, xm3, 1 ; All ACs (tmp[1] through to tmp[4]) |
||||
addps m%3, m%3, m0 ; Finally offset with DCs |
||||
%endmacro |
||||
|
||||
%macro BUTTERFLIES_DC 1 ; %1 - exptab_offset |
||||
mulps xm0, xm9, [exptabq + %1 + 16*0] |
||||
mulps xm1, xm10, [exptabq + %1 + 16*1] |
||||
|
||||
haddps xm0, xm1 |
||||
movhlps xm1, xm0 ; t[0].re, t[1].re, t[0].im, t[1].im |
||||
|
||||
addps xm0, xm1 |
||||
addps xm0, xm8 |
||||
|
||||
movsd [outq], xm0 |
||||
%endmacro |
||||
|
||||
%macro BUTTERFLIES_AC 1 ; %1 - exptab_offset |
||||
mulps m0, m12, [exptabq + 64*0 + 0*mmsize + %1] |
||||
mulps m1, m12, [exptabq + 64*0 + 1*mmsize + %1] |
||||
mulps m2, m13, [exptabq + 64*1 + 0*mmsize + %1] |
||||
mulps m3, m13, [exptabq + 64*1 + 1*mmsize + %1] |
||||
|
||||
addps m0, m0, m2 |
||||
addps m1, m1, m3 |
||||
addps m0, m0, m11 |
||||
|
||||
shufps m1, m1, m1, q2301 |
||||
addps m0, m0, m1 |
||||
|
||||
vextractf128 xm1, m0, 1 |
||||
|
||||
movlps [outq + strideq*1], xm0 |
||||
movhps [outq + strideq*2], xm0 |
||||
movlps [outq + stride3q], xm1 |
||||
movhps [outq + strideq*4], xm1 |
||||
%endmacro |
||||
|
||||
INIT_YMM avx |
||||
cglobal fft15, 4, 5, 14, out, in, exptab, stride, stride5 |
||||
shl strideq, 3 |
||||
|
||||
movaps xm5, [exptabq + 480 + 16*0] |
||||
movaps xm6, [exptabq + 480 + 16*1] |
||||
movaps xm7, [sign_adjust_5] |
||||
|
||||
FFT5 0, xm8, 11 |
||||
FFT5 8, xm9, 12 |
||||
FFT5 16, xm10, 13 |
||||
|
||||
%define stride3q inq |
||||
lea stride3q, [strideq + strideq*2] |
||||
lea stride5q, [strideq + strideq*4] |
||||
|
||||
BUTTERFLIES_DC (8*6 + 4*0)*2*4 |
||||
BUTTERFLIES_AC (8*0 + 0*0)*2*4 |
||||
|
||||
add outq, stride5q |
||||
BUTTERFLIES_DC (8*6 + 4*1)*2*4 |
||||
BUTTERFLIES_AC (8*2 + 0*0)*2*4 |
||||
|
||||
add outq, stride5q |
||||
BUTTERFLIES_DC (8*6 + 4*2)*2*4 |
||||
BUTTERFLIES_AC (8*4 + 0*0)*2*4 |
||||
|
||||
RET |
||||
|
||||
%endif ; ARCH_X86_64 |
||||
|
||||
;******************************************************************************************************* |
||||
;void ff_mdct15_postreindex(FFTComplex *out, FFTComplex *in, FFTComplex *exp, int *lut, ptrdiff_t len8); |
||||
;******************************************************************************************************* |
||||
%macro LUT_LOAD_4D 3 |
||||
mov r4d, [lutq + %3q*4 + 0] |
||||
movsd xmm%1, [inq + r4q*8] |
||||
mov r4d, [lutq + %3q*4 + 4] |
||||
movhps xmm%1, [inq + r4q*8] |
||||
%if cpuflag(avx2) |
||||
mov r4d, [lutq + %3q*4 + 8] |
||||
movsd %2, [inq + r4q*8] |
||||
mov r4d, [lutq + %3q*4 + 12] |
||||
movhps %2, [inq + r4q*8] |
||||
vinsertf128 %1, %1, %2, 1 |
||||
%endif |
||||
%endmacro |
||||
|
||||
%macro POSTROTATE_FN 1 |
||||
cglobal mdct15_postreindex, 5, 7, 8 + cpuflag(avx2)*2, out, in, exp, lut, len8, offset_p, offset_n |
||||
|
||||
xor offset_nq, offset_nq |
||||
lea offset_pq, [len8q*2 - %1] |
||||
|
||||
movaps m7, [sign_adjust_r] |
||||
|
||||
%if cpuflag(avx2) |
||||
movaps m8, [perm_pos] |
||||
movaps m9, [perm_neg] |
||||
%endif |
||||
|
||||
.loop: |
||||
movups m0, [expq + offset_pq*8] ; exp[p0].re, exp[p0].im, exp[p1].re, exp[p1].im, exp[p2].re, exp[p2].im, exp[p3].re, exp[p3].im |
||||
movups m1, [expq + offset_nq*8] ; exp[n3].re, exp[n3].im, exp[n2].re, exp[n2].im, exp[n1].re, exp[n1].im, exp[n0].re, exp[n0].im |
||||
|
||||
LUT_LOAD_4D m3, xm4, offset_p ; in[p0].re, in[p0].im, in[p1].re, in[p1].im, in[p2].re, in[p2].im, in[p3].re, in[p3].im |
||||
LUT_LOAD_4D m4, xm5, offset_n ; in[n3].re, in[n3].im, in[n2].re, in[n2].im, in[n1].re, in[n1].im, in[n0].re, in[n0].im |
||||
|
||||
mulps m5, m3, m0 ; in[p].reim * exp[p].reim |
||||
mulps m6, m4, m1 ; in[n].reim * exp[n].reim |
||||
|
||||
xorps m5, m7 ; in[p].re *= -1, in[p].im *= 1 |
||||
xorps m6, m7 ; in[n].re *= -1, in[n].im *= 1 |
||||
|
||||
shufps m3, m3, m3, q2301 ; in[p].imre |
||||
shufps m4, m4, m4, q2301 ; in[n].imre |
||||
|
||||
mulps m3, m0 ; in[p].imre * exp[p].reim |
||||
mulps m4, m1 ; in[n].imre * exp[n].reim |
||||
|
||||
haddps m3, m6 ; out[n0].im, out[n1].im, out[n3].re, out[n2].re, out[n2].im, out[n3].im, out[n1].re, out[n0].re |
||||
haddps m5, m4 ; out[p0].re, out[p1].re, out[p3].im, out[p2].im, out[p2].re, out[p3].re, out[p1].im, out[p0].im |
||||
|
||||
%if cpuflag(avx2) |
||||
vpermps m3, m9, m3 ; out[n3].im, out[n3].re, out[n2].im, out[n2].re, out[n1].im, out[n1].re, out[n0].im, out[n0].re |
||||
vpermps m5, m8, m5 ; out[p0].re, out[p0].im, out[p1].re, out[p1].im, out[p2].re, out[p2].im, out[p3].re, out[p3].im |
||||
%else |
||||
shufps m3, m3, m3, q0312 |
||||
shufps m5, m5, m5, q2130 |
||||
%endif |
||||
|
||||
movups [outq + offset_nq*8], m3 |
||||
movups [outq + offset_pq*8], m5 |
||||
|
||||
sub offset_pq, %1 |
||||
add offset_nq, %1 |
||||
cmp offset_nq, offset_pq |
||||
jle .loop |
||||
|
||||
REP_RET |
||||
%endmacro |
||||
|
||||
INIT_XMM sse3 |
||||
POSTROTATE_FN 2 |
||||
|
||||
%if ARCH_X86_64 && HAVE_AVX2_EXTERNAL |
||||
INIT_YMM avx2 |
||||
POSTROTATE_FN 4 |
||||
%endif |
@ -1,104 +0,0 @@ |
||||
/*
|
||||
* SIMD optimized non-power-of-two MDCT functions |
||||
* |
||||
* Copyright (C) 2017 Rostislav Pehlivanov <atomnuker@gmail.com> |
||||
* |
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include <string.h> |
||||
|
||||
#include "config.h" |
||||
|
||||
#include "libavutil/attributes.h" |
||||
#include "libavutil/x86/cpu.h" |
||||
#include "libavcodec/mdct15.h" |
||||
|
||||
void ff_mdct15_postreindex_sse3(FFTComplex *out, FFTComplex *in, FFTComplex *exp, int *lut, ptrdiff_t len8); |
||||
void ff_mdct15_postreindex_avx2(FFTComplex *out, FFTComplex *in, FFTComplex *exp, int *lut, ptrdiff_t len8); |
||||
|
||||
void ff_fft15_avx(FFTComplex *out, FFTComplex *in, FFTComplex *exptab, ptrdiff_t stride); |
||||
|
||||
static void perm_twiddles(MDCT15Context *s) |
||||
{ |
||||
int k; |
||||
FFTComplex tmp[30]; |
||||
|
||||
/* 5-point FFT twiddles */ |
||||
s->exptab[60].re = s->exptab[60].im = s->exptab[19].re; |
||||
s->exptab[61].re = s->exptab[61].im = s->exptab[19].im; |
||||
s->exptab[62].re = s->exptab[62].im = s->exptab[20].re; |
||||
s->exptab[63].re = s->exptab[63].im = s->exptab[20].im; |
||||
|
||||
/* 15-point FFT twiddles */ |
||||
for (k = 0; k < 5; k++) { |
||||
tmp[6*k + 0] = s->exptab[k + 0]; |
||||
tmp[6*k + 2] = s->exptab[k + 5]; |
||||
tmp[6*k + 4] = s->exptab[k + 10]; |
||||
|
||||
tmp[6*k + 1] = s->exptab[2 * (k + 0)]; |
||||
tmp[6*k + 3] = s->exptab[2 * (k + 5)]; |
||||
tmp[6*k + 5] = s->exptab[2 * k + 5 ]; |
||||
} |
||||
|
||||
for (k = 0; k < 6; k++) { |
||||
FFTComplex ac_exp[] = { |
||||
{ tmp[6*1 + k].re, tmp[6*1 + k].re }, |
||||
{ tmp[6*2 + k].re, tmp[6*2 + k].re }, |
||||
{ tmp[6*3 + k].re, tmp[6*3 + k].re }, |
||||
{ tmp[6*4 + k].re, tmp[6*4 + k].re }, |
||||
{ tmp[6*1 + k].im, -tmp[6*1 + k].im }, |
||||
{ tmp[6*2 + k].im, -tmp[6*2 + k].im }, |
||||
{ tmp[6*3 + k].im, -tmp[6*3 + k].im }, |
||||
{ tmp[6*4 + k].im, -tmp[6*4 + k].im }, |
||||
}; |
||||
memcpy(s->exptab + 8*k, ac_exp, 8*sizeof(FFTComplex)); |
||||
} |
||||
|
||||
/* Specialcase when k = 0 */ |
||||
for (k = 0; k < 3; k++) { |
||||
FFTComplex dc_exp[] = { |
||||
{ tmp[2*k + 0].re, -tmp[2*k + 0].im }, |
||||
{ tmp[2*k + 0].im, tmp[2*k + 0].re }, |
||||
{ tmp[2*k + 1].re, -tmp[2*k + 1].im }, |
||||
{ tmp[2*k + 1].im, tmp[2*k + 1].re }, |
||||
}; |
||||
memcpy(s->exptab + 8*6 + 4*k, dc_exp, 4*sizeof(FFTComplex)); |
||||
} |
||||
} |
||||
|
||||
av_cold void ff_mdct15_init_x86(MDCT15Context *s) |
||||
{ |
||||
int adjust_twiddles = 0; |
||||
int cpu_flags = av_get_cpu_flags(); |
||||
|
||||
if (EXTERNAL_SSE3(cpu_flags)) |
||||
s->postreindex = ff_mdct15_postreindex_sse3; |
||||
|
||||
#if ARCH_X86_64 |
||||
if (EXTERNAL_AVX(cpu_flags)) { |
||||
s->fft15 = ff_fft15_avx; |
||||
adjust_twiddles = 1; |
||||
} |
||||
|
||||
if (EXTERNAL_AVX2_FAST(cpu_flags)) |
||||
s->postreindex = ff_mdct15_postreindex_avx2; |
||||
#endif |
||||
|
||||
if (adjust_twiddles) |
||||
perm_twiddles(s); |
||||
} |
Loading…
Reference in new issue