39 #define CMUL3(cre, cim, are, aim, bre, bim) \
41 cre = are * bre - aim * bim; \
42 cim = are * bim + aim * bre; \
45 #define CMUL(c, a, b) CMUL3((c).re, (c).im, (a).re, (a).im, (b).re, (b).im)
65 ptrdiff_t
stride,
float scale);
71 const int l_ptwo = 1 << b_ptwo;
72 const int inv_1 = l_ptwo << ((4 - b_ptwo) & 3);
73 const int inv_2 = 0xeeeeeeef & ((1
U << b_ptwo) - 1);
84 for (i = 0; i < l_ptwo; i++) {
85 for (j = 0; j < 15; j++) {
86 const int q_pre = ((l_ptwo * j)/15 + i) >> b_ptwo;
87 const int q_post = (((j*inv_1)/15) + (i*inv_2)) >> b_ptwo;
88 const int k_pre = 15*i + (j - q_pre*15)*l_ptwo;
89 const int k_post = i*inv_2*15 + j*inv_1 - 15*q_post*l_ptwo;
101 int len2 = 15 * (1 <<
N);
106 if ((N < 2) || (N > 13))
132 for (i = 0; i < s->
len4; i++) {
138 for (i = 0; i < 19; i++) {
140 double theta = (2.0f *
M_PI * i) / 15.0f;
173 t[0].
re = in[3].
re + in[12].
re;
174 t[0].
im = in[3].
im + in[12].
im;
175 t[1].
im = in[3].
re - in[12].
re;
176 t[1].
re = in[3].
im - in[12].
im;
177 t[2].
re = in[6].
re + in[ 9].
re;
178 t[2].
im = in[6].
im + in[ 9].
im;
179 t[3].
im = in[6].
re - in[ 9].
re;
180 t[3].
re = in[6].
im - in[ 9].
im;
182 out[0].
re = in[0].
re + in[3].
re + in[6].
re + in[9].
re + in[12].
re;
183 out[0].
im = in[0].
im + in[3].
im + in[6].
im + in[9].
im + in[12].
im;
185 t[4].
re = exptab[0].
re * t[2].
re - exptab[1].
re * t[0].
re;
186 t[4].
im = exptab[0].
re * t[2].
im - exptab[1].
re * t[0].
im;
187 t[0].
re = exptab[0].
re * t[0].
re - exptab[1].
re * t[2].
re;
188 t[0].
im = exptab[0].
re * t[0].
im - exptab[1].
re * t[2].
im;
189 t[5].
re = exptab[0].
im * t[3].
re - exptab[1].
im * t[1].
re;
190 t[5].
im = exptab[0].
im * t[3].
im - exptab[1].
im * t[1].
im;
191 t[1].
re = exptab[0].
im * t[1].
re + exptab[1].
im * t[3].
re;
192 t[1].
im = exptab[0].
im * t[1].
im + exptab[1].
im * t[3].
im;
194 z0[0].
re = t[0].
re - t[1].
re;
195 z0[0].
im = t[0].
im - t[1].
im;
196 z0[1].
re = t[4].
re + t[5].
re;
197 z0[1].
im = t[4].
im + t[5].
im;
199 z0[2].
re = t[4].
re - t[5].
re;
200 z0[2].
im = t[4].
im - t[5].
im;
201 z0[3].
re = t[0].
re + t[1].
re;
202 z0[3].
im = t[0].
im + t[1].
im;
204 out[1].
re = in[0].
re + z0[3].
re;
205 out[1].
im = in[0].
im + z0[0].
im;
206 out[2].
re = in[0].
re + z0[2].
re;
207 out[2].
im = in[0].
im + z0[1].
im;
208 out[3].
re = in[0].
re + z0[1].
re;
209 out[3].
im = in[0].
im + z0[2].
im;
210 out[4].
re = in[0].
re + z0[0].
re;
211 out[4].
im = in[0].
im + z0[3].
im;
220 fft5(exptab + 19, tmp1, in + 0);
221 fft5(exptab + 19, tmp2, in + 1);
222 fft5(exptab + 19, tmp3, in + 2);
224 for (k = 0; k < 5; k++) {
227 CMUL(t[0], tmp2[k], exptab[k]);
228 CMUL(t[1], tmp3[k], exptab[2 * k]);
229 out[stride*k].
re = tmp1[k].
re + t[0].
re + t[1].
re;
230 out[stride*k].
im = tmp1[k].
im + t[0].
im + t[1].
im;
232 CMUL(t[0], tmp2[k], exptab[k + 5]);
233 CMUL(t[1], tmp3[k], exptab[2 * (k + 5)]);
234 out[stride*(k + 5)].
re = tmp1[k].
re + t[0].
re + t[1].
re;
235 out[stride*(k + 5)].
im = tmp1[k].
im + t[0].
im + t[1].
im;
237 CMUL(t[0], tmp2[k], exptab[k + 10]);
238 CMUL(t[1], tmp3[k], exptab[2 * k + 5]);
239 out[stride*(k + 10)].
re = tmp1[k].
re + t[0].
re + t[1].
re;
240 out[stride*(k + 10)].
im = tmp1[k].
im + t[0].
im + t[1].
im;
245 ptrdiff_t
stride,
float scale)
250 const float *in1 =
src, *in2 = src + (s->
len2 - 1) * stride;
253 for (i = 0; i < l_ptwo; i++) {
254 for (j = 0; j < 15; j++) {
263 for (i = 0; i < 15; i++)
267 for (i = 0; i < len8; i++) {
268 float re0, im0, re1, im1;
269 const int i0 = len8 + i, i1 = len8 - i - 1;
274 z[i1].
re = scale * re0;
275 z[i1].
im = scale * im0;
276 z[i0].
re = scale * re1;
277 z[i0].
im = scale * im1;
static void fft5(const FFTComplex exptab[2], FFTComplex *out, const FFTComplex *in)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int init_pfa_reindex_tabs(IMDCT15Context *s)
Macro definitions for various function/variable attributes.
static void imdct15_half(IMDCT15Context *s, float *dst, const float *src, ptrdiff_t stride, float scale)
FFTComplex * twiddle_exptab
av_cold void ff_imdct15_uninit(IMDCT15Context **ps)
Free an iMDCT.
static struct @119 * exptab
static void fft15(const FFTComplex exptab[22], FFTComplex *out, const FFTComplex *in, size_t stride)
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
void(* imdct_half)(struct IMDCT15Context *s, float *dst, const float *src, ptrdiff_t src_stride, float scale)
Calculate the middle half of the iMDCT.
av_cold int ff_imdct15_init(IMDCT15Context **ps, int N)
Init an iMDCT of the length 2 * 15 * (2^N)
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().
#define av_malloc_array(a, b)
#define CMUL3(cre, cim, are, aim, bre, bim)