41 #define CMUL3(c, a, b) CMUL((c).re, (c).im, (a).re, (a).im, (b).re, (b).im) 64 const int l_ptwo = 1 << b_ptwo;
65 const int inv_1 = l_ptwo << ((4 - b_ptwo) & 3);
66 const int inv_2 = 0xeeeeeeef & ((1
U << b_ptwo) - 1);
77 for (i = 0; i < l_ptwo; i++) {
78 for (j = 0; j < 15; j++) {
79 const int q_pre = ((l_ptwo * j)/15 + i) >> b_ptwo;
80 const int q_post = (((j*inv_1)/15) + (i*inv_2)) >> b_ptwo;
81 const int k_pre = 15*i + (j - q_pre*15)*(1 << b_ptwo);
82 const int k_post = i*inv_2*15 + j*inv_1 - 15*q_post*l_ptwo;
96 t[0].
re = in[3].
re + in[12].
re;
97 t[0].
im = in[3].
im + in[12].
im;
98 t[1].
im = in[3].
re - in[12].
re;
99 t[1].
re = in[3].
im - in[12].
im;
100 t[2].
re = in[6].
re + in[ 9].
re;
101 t[2].
im = in[6].
im + in[ 9].
im;
102 t[3].
im = in[6].
re - in[ 9].
re;
103 t[3].
re = in[6].
im - in[ 9].
im;
105 out[0].
re = in[0].
re + in[3].
re + in[6].
re + in[9].
re + in[12].
re;
106 out[0].
im = in[0].
im + in[3].
im + in[6].
im + in[9].
im + in[12].
im;
108 t[4].
re = exptab[0].
re * t[2].
re - exptab[1].
re * t[0].
re;
109 t[4].
im = exptab[0].
re * t[2].
im - exptab[1].
re * t[0].
im;
110 t[0].
re = exptab[0].
re * t[0].
re - exptab[1].
re * t[2].
re;
111 t[0].
im = exptab[0].
re * t[0].
im - exptab[1].
re * t[2].
im;
112 t[5].
re = exptab[0].
im * t[3].
re - exptab[1].
im * t[1].
re;
113 t[5].
im = exptab[0].
im * t[3].
im - exptab[1].
im * t[1].
im;
114 t[1].
re = exptab[0].
im * t[1].
re + exptab[1].
im * t[3].
re;
115 t[1].
im = exptab[0].
im * t[1].
im + exptab[1].
im * t[3].
im;
117 z0[0].
re = t[0].
re - t[1].
re;
118 z0[0].
im = t[0].
im - t[1].
im;
119 z0[1].
re = t[4].
re + t[5].
re;
120 z0[1].
im = t[4].
im + t[5].
im;
122 z0[2].
re = t[4].
re - t[5].
re;
123 z0[2].
im = t[4].
im - t[5].
im;
124 z0[3].
re = t[0].
re + t[1].
re;
125 z0[3].
im = t[0].
im + t[1].
im;
127 out[1].
re = in[0].
re + z0[3].
re;
128 out[1].
im = in[0].
im + z0[0].
im;
129 out[2].
re = in[0].
re + z0[2].
re;
130 out[2].
im = in[0].
im + z0[1].
im;
131 out[3].
re = in[0].
re + z0[1].
re;
132 out[3].
im = in[0].
im + z0[2].
im;
133 out[4].
re = in[0].
re + z0[0].
re;
134 out[4].
im = in[0].
im + z0[3].
im;
142 fft5(tmp1, in + 0, exptab + 19);
143 fft5(tmp2, in + 1, exptab + 19);
144 fft5(tmp3, in + 2, exptab + 19);
146 for (k = 0; k < 5; k++) {
149 CMUL3(t[0], tmp2[k], exptab[k]);
150 CMUL3(t[1], tmp3[k], exptab[2 * k]);
151 out[stride*k].
re = tmp1[k].
re + t[0].
re + t[1].
re;
152 out[stride*k].
im = tmp1[k].
im + t[0].
im + t[1].
im;
154 CMUL3(t[0], tmp2[k], exptab[k + 5]);
155 CMUL3(t[1], tmp3[k], exptab[2 * (k + 5)]);
156 out[stride*(k + 5)].
re = tmp1[k].
re + t[0].
re + t[1].
re;
157 out[stride*(k + 5)].
im = tmp1[k].
im + t[0].
im + t[1].
im;
159 CMUL3(t[0], tmp2[k], exptab[k + 10]);
160 CMUL3(t[1], tmp3[k], exptab[2 * k + 5]);
161 out[stride*(k + 10)].
re = tmp1[k].
re + t[0].
re + t[1].
re;
162 out[stride*(k + 10)].
im = tmp1[k].
im + t[0].
im + t[1].
im;
169 const int len4 = s->
len4, len3 = len4 * 3, len8 = len4 >> 1;
174 for (i = 0; i < l_ptwo; i++) {
175 for (j = 0; j < 15; j++) {
179 tmp.
re = -src[ len4 + k] + src[1*len4 - 1 - k];
180 tmp.
im = -src[ len3 + k] - src[1*len3 - 1 - k];
182 tmp.
re = -src[ len4 + k] - src[5*len4 - 1 - k];
183 tmp.
im = src[-len4 + k] - src[1*len3 - 1 - k];
191 for (i = 0; i < 15; i++)
195 for (i = 0; i < len8; i++) {
196 const int i0 = len8 + i, i1 = len8 - i - 1;
199 CMUL(dst[2*i1*stride + stride], dst[2*i0*stride], s->
tmp[s0].
re, s->
tmp[s0].
im,
212 const float *in1 =
src, *in2 = src + (s->
len2 - 1) * stride;
215 for (i = 0; i < l_ptwo; i++) {
216 for (j = 0; j < 15; j++) {
225 for (i = 0; i < 15; i++)
233 int *lut, ptrdiff_t len8)
238 for (i = 0; i < len8; i++) {
239 const int i0 = len8 + i, i1 = len8 - i - 1;
240 const int s0 = lut[i0],
s1 = lut[i1];
242 CMUL(out[i1].
re, out[i0].
im, in[s1].im, in[s1].re, exp[i1].im, exp[i1].re);
243 CMUL(out[i0].re, out[i1].im, in[s0].im, in[s0].re, exp[i0].im, exp[i0].re);
251 int len2 = 15 * (1 <<
N);
256 if ((N < 2) || (N > 13))
286 theta = 0.125f + (scale < 0 ? s->
len4 : 0);
287 scale = sqrt(fabs(scale));
288 for (i = 0; i < s->
len4; i++) {
289 alpha = 2 *
M_PI * (i + theta) / len;
295 for (i = 0; i < 19; i++) {
297 double theta = (2.0f *
M_PI * i) / 15.0f;
static float alpha(float a)
static void mdct15(MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
static void fft5(FFTComplex *out, FFTComplex *in, FFTComplex exptab[2])
Macro definitions for various function/variable attributes.
static int init_pfa_reindex_tabs(MDCT15Context *s)
void(* mdct)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
#define CMUL(dre, dim, are, aim, bre, bim)
static void postrotate_c(FFTComplex *out, FFTComplex *in, FFTComplex *exp, int *lut, ptrdiff_t len8)
av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
FFTComplex * twiddle_exptab
void ff_mdct15_init_x86(MDCT15Context *s)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static void imdct15_half(MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
void(* postreindex)(FFTComplex *out, FFTComplex *in, FFTComplex *exp, int *lut, ptrdiff_t len8)
void(* imdct_half)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static void fft15_c(FFTComplex *out, FFTComplex *in, FFTComplex *exptab, ptrdiff_t stride)
common internal and external API header
void(* fft_calc)(struct FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in ff_fft_init().
av_cold void ff_mdct15_uninit(MDCT15Context **ps)
void(* fft15)(FFTComplex *out, FFTComplex *in, FFTComplex *exptab, ptrdiff_t stride)
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
#define av_malloc_array(a, b)
static struct @125 * exptab