40 #define CMUL3(cre, cim, are, aim, bre, bim) \
42 cre = are * bre - aim * bim; \
43 cim = are * bim + aim * bre; \
46 #define CMUL(c, a, b) CMUL3((c).re, (c).im, (a).re, (a).im, (b).re, (b).im)
68 ptrdiff_t
stride,
float scale);
74 const int l_ptwo = 1 << b_ptwo;
75 const int inv_1 = l_ptwo << ((4 - b_ptwo) & 3);
76 const int inv_2 = 0xeeeeeeef & ((1
U << b_ptwo) - 1);
87 for (i = 0; i < l_ptwo; i++) {
88 for (j = 0; j < 15; j++) {
89 const int q_pre = ((l_ptwo * j)/15 + i) >> b_ptwo;
90 const int q_post = (((j*inv_1)/15) + (i*inv_2)) >> b_ptwo;
91 const int k_pre = 15*i + (j - q_pre*15)*(1 << b_ptwo);
92 const int k_post = i*inv_2*15 + j*inv_1 - 15*q_post*l_ptwo;
105 int len2 = 15 * (1 <<
N);
110 if ((N < 2) || (N > 13))
138 theta = 0.125f + (scale < 0 ? s->
len4 : 0);
139 scale = sqrt(fabs(scale));
140 for (i = 0; i < s->
len4; i++) {
141 alpha = 2 *
M_PI * (i + theta) / len;
147 for (i = 0; i < 19; i++) {
149 double theta = (2.0f *
M_PI * i) / 15.0f;
186 t[0].
re = in[3].
re + in[12].
re;
187 t[0].
im = in[3].
im + in[12].
im;
188 t[1].
im = in[3].
re - in[12].
re;
189 t[1].
re = in[3].
im - in[12].
im;
190 t[2].
re = in[6].
re + in[ 9].
re;
191 t[2].
im = in[6].
im + in[ 9].
im;
192 t[3].
im = in[6].
re - in[ 9].
re;
193 t[3].
re = in[6].
im - in[ 9].
im;
195 out[0].
re = in[0].
re + in[3].
re + in[6].
re + in[9].
re + in[12].
re;
196 out[0].
im = in[0].
im + in[3].
im + in[6].
im + in[9].
im + in[12].
im;
198 t[4].
re = exptab[0].
re * t[2].
re - exptab[1].
re * t[0].
re;
199 t[4].
im = exptab[0].
re * t[2].
im - exptab[1].
re * t[0].
im;
200 t[0].
re = exptab[0].
re * t[0].
re - exptab[1].
re * t[2].
re;
201 t[0].
im = exptab[0].
re * t[0].
im - exptab[1].
re * t[2].
im;
202 t[5].
re = exptab[0].
im * t[3].
re - exptab[1].
im * t[1].
re;
203 t[5].
im = exptab[0].
im * t[3].
im - exptab[1].
im * t[1].
im;
204 t[1].
re = exptab[0].
im * t[1].
re + exptab[1].
im * t[3].
re;
205 t[1].
im = exptab[0].
im * t[1].
im + exptab[1].
im * t[3].
im;
207 z0[0].
re = t[0].
re - t[1].
re;
208 z0[0].
im = t[0].
im - t[1].
im;
209 z0[1].
re = t[4].
re + t[5].
re;
210 z0[1].
im = t[4].
im + t[5].
im;
212 z0[2].
re = t[4].
re - t[5].
re;
213 z0[2].
im = t[4].
im - t[5].
im;
214 z0[3].
re = t[0].
re + t[1].
re;
215 z0[3].
im = t[0].
im + t[1].
im;
217 out[1].
re = in[0].
re + z0[3].
re;
218 out[1].
im = in[0].
im + z0[0].
im;
219 out[2].
re = in[0].
re + z0[2].
re;
220 out[2].
im = in[0].
im + z0[1].
im;
221 out[3].
re = in[0].
re + z0[1].
re;
222 out[3].
im = in[0].
im + z0[2].
im;
223 out[4].
re = in[0].
re + z0[0].
re;
224 out[4].
im = in[0].
im + z0[3].
im;
232 fft5(exptab + 19, tmp1, in + 0);
233 fft5(exptab + 19, tmp2, in + 1);
234 fft5(exptab + 19, tmp3, in + 2);
236 for (k = 0; k < 5; k++) {
239 CMUL(t[0], tmp2[k], exptab[k]);
240 CMUL(t[1], tmp3[k], exptab[2 * k]);
241 out[stride*k].
re = tmp1[k].
re + t[0].
re + t[1].
re;
242 out[stride*k].
im = tmp1[k].
im + t[0].
im + t[1].
im;
244 CMUL(t[0], tmp2[k], exptab[k + 5]);
245 CMUL(t[1], tmp3[k], exptab[2 * (k + 5)]);
246 out[stride*(k + 5)].
re = tmp1[k].
re + t[0].
re + t[1].
re;
247 out[stride*(k + 5)].
im = tmp1[k].
im + t[0].
im + t[1].
im;
249 CMUL(t[0], tmp2[k], exptab[k + 10]);
250 CMUL(t[1], tmp3[k], exptab[2 * k + 5]);
251 out[stride*(k + 10)].
re = tmp1[k].
re + t[0].
re + t[1].
re;
252 out[stride*(k + 10)].
im = tmp1[k].
im + t[0].
im + t[1].
im;
259 const int len4 = s->
len4, len3 = len4 * 3, len8 = len4 >> 1;
264 for (i = 0; i < l_ptwo; i++) {
265 for (j = 0; j < 15; j++) {
269 re = -src[2*k+len3] - src[len3-1-2*k];
270 im = -src[len4+2*k] + src[len4-1-2*k];
272 re = src[2*k-len4] - src[1*len3-1-2*k];
273 im = -src[2*k+len4] - src[5*len4-1-2*k];
281 for (i = 0; i < 15; i++)
285 for (i = 0; i < len8; i++) {
286 float re0, im0, re1, im1;
287 const int i0 = len8 + i, i1 = len8 - i - 1;
294 dst[2*i1*stride +
stride] = im0;
296 dst[2*i0*stride +
stride] = im1;
301 ptrdiff_t
stride,
float scale)
306 const float *in1 =
src, *in2 = src + (s->
len2 - 1) * stride;
309 for (i = 0; i < l_ptwo; i++) {
310 for (j = 0; j < 15; j++) {
319 for (i = 0; i < 15; i++)
323 for (i = 0; i < len8; i++) {
324 float re0, im0, re1, im1;
325 const int i0 = len8 + i, i1 = len8 - i - 1;
330 z[i1].
re = scale * re0;
331 z[i1].
im = scale * im0;
332 z[i0].
re = scale * re1;
333 z[i0].
im = scale * im1;
static void mdct15(MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Macro definitions for various function/variable attributes.
static int init_pfa_reindex_tabs(MDCT15Context *s)
av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
Init an (i)MDCT of the length 2 * 15 * (2^N)
static void fft5(const FFTComplex exptab[2], FFTComplex *out, const FFTComplex *in)
FFTComplex * twiddle_exptab
static double alpha(void *priv, double x, double y)
static void fft15(const FFTComplex exptab[22], FFTComplex *out, const FFTComplex *in, size_t stride)
void(* imdct_half)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t src_stride, float scale)
Calculate the middle half of the iMDCT.
#define CMUL3(cre, cim, are, aim, bre, bim)
static struct @119 * exptab
static void imdct15_half(MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride, float scale)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
GLint GLenum GLboolean GLsizei 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)
Frees a context.
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
#define av_malloc_array(a, b)
void(* mdct)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
Calculate a full 2N -> N MDCT.