40 #define CELT_MIN_IMDCT_SIZE 120
43 #define CMUL3(cre, cim, are, aim, bre, bim) \
45 cre = are * bre - aim * bim; \
46 cim = are * bim + aim * bre; \
49 #define CMUL(c, a, b) CMUL3((c).re, (c).im, (a).re, (a).im, (b).re, (b).im)
53 #define CMUL2(c, d, a, b) \
59 float rr = are * bre; \
60 float ri = are * bim; \
61 float ir = aim * bre; \
62 float ii = aim * bim; \
88 ptrdiff_t
stride,
float scale);
93 int len2 = 15 * (1 <<
N);
116 for (i = 0; i < s->
len4; i++) {
122 int N = 15 * (1 << i);
127 for (j = 0; j <
N; j++) {
134 for (j = 15; j < 19; j++)
154 static const FFTComplex fact[] = { { 0.30901699437494745, 0.95105651629515353 },
155 { -0.80901699437494734, 0.58778525229247325 } };
159 CMUL2(z[0][0], z[0][3], in[1 * stride], fact[0]);
160 CMUL2(z[0][1], z[0][2], in[1 * stride], fact[1]);
161 CMUL2(z[1][0], z[1][3], in[2 * stride], fact[0]);
162 CMUL2(z[1][1], z[1][2], in[2 * stride], fact[1]);
163 CMUL2(z[2][0], z[2][3], in[3 * stride], fact[0]);
164 CMUL2(z[2][1], z[2][2], in[3 * stride], fact[1]);
165 CMUL2(z[3][0], z[3][3], in[4 * stride], fact[0]);
166 CMUL2(z[3][1], z[3][2], in[4 * stride], fact[1]);
171 out[1].
re = in[0].
re + z[0][0].
re + z[1][1].
re + z[2][2].
re + z[3][3].
re;
172 out[1].
im = in[0].
im + z[0][0].
im + z[1][1].
im + z[2][2].
im + z[3][3].
im;
174 out[2].
re = in[0].
re + z[0][1].
re + z[1][3].
re + z[2][0].
re + z[3][2].
re;
175 out[2].
im = in[0].
im + z[0][1].
im + z[1][3].
im + z[2][0].
im + z[3][2].
im;
177 out[3].
re = in[0].
re + z[0][2].
re + z[1][0].
re + z[2][3].
re + z[3][1].
re;
178 out[3].
im = in[0].
im + z[0][2].
im + z[1][0].
im + z[2][3].
im + z[3][1].
im;
180 out[4].
re = in[0].
re + z[0][3].
re + z[1][2].
re + z[2][1].
re + z[3][0].
re;
181 out[4].
im = in[0].
im + z[0][3].
im + z[1][2].
im + z[2][1].
im + z[3][0].
im;
193 fft5(tmp, in, stride * 3);
194 fft5(tmp1, in + stride, stride * 3);
195 fft5(tmp2, in + 2 * stride, stride * 3);
197 for (k = 0; k < 5; k++) {
200 CMUL(t1, tmp1[k], exptab[k]);
201 CMUL(t2, tmp2[k], exptab[2 * k]);
202 out[k].
re = tmp[k].
re + t1.
re + t2.
re;
203 out[k].
im = tmp[k].
im + t1.
im + t2.
im;
205 CMUL(t1, tmp1[k], exptab[k + 5]);
206 CMUL(t2, tmp2[k], exptab[2 * (k + 5)]);
207 out[k + 5].
re = tmp[k].
re + t1.
re + t2.
re;
208 out[k + 5].
im = tmp[k].
im + t1.
im + t2.
im;
210 CMUL(t1, tmp1[k], exptab[k + 10]);
211 CMUL(t2, tmp2[k], exptab[2 * k + 5]);
212 out[k + 10].
re = tmp[k].
re + t1.
re + t2.
re;
213 out[k + 10].
im = tmp[k].
im + t1.
im + t2.
im;
225 const int len2 = 15 * (1 << (N - 1));
228 fft_calc(s, out, in, N - 1, stride * 2);
229 fft_calc(s, out + len2, in + stride, N - 1, stride * 2);
231 for (k = 0; k < len2; k++) {
234 CMUL(t, out[len2 + k], exptab[k]);
236 out[len2 + k].
re = out[k].
re - t.
re;
237 out[len2 + k].
im = out[k].
im - t.
im;
243 fft15(s, out, in, stride);
247 ptrdiff_t
stride,
float scale)
250 const int len8 = s->
len4 / 2;
251 const float *in1 =
src;
252 const float *in2 = src + (s->
len2 - 1) * stride;
255 for (i = 0; i < s->
len4; i++) {
264 for (i = 0; i < len8; i++) {
265 float r0, i0, r1, i1;
269 z[len8 - i - 1].
re = scale * r0;
270 z[len8 - i - 1].
im = scale * i0;
271 z[len8 + i].
re = scale * r1;
272 z[len8 + i].
im = scale * i1;
#define FF_ARRAY_ELEMS(a)
Macro definitions for various function/variable attributes.
static void imdct15_half(IMDCT15Context *s, float *dst, const float *src, ptrdiff_t stride, float scale)
static void fft_calc(IMDCT15Context *s, FFTComplex *out, const FFTComplex *in, int N, ptrdiff_t stride)
void ff_imdct15_init_aarch64(IMDCT15Context *s)
static void fft5(FFTComplex *out, const FFTComplex *in, ptrdiff_t stride)
FFTComplex * twiddle_exptab
av_cold void ff_imdct15_uninit(IMDCT15Context **ps)
Free an iMDCT.
#define CELT_MIN_IMDCT_SIZE
#define CMUL2(c, d, a, b)
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
static struct @45 * exptab
#define CELT_MAX_FRAME_SIZE
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-> out
#define av_malloc_array(a, b)
static void fft15(IMDCT15Context *s, FFTComplex *out, const FFTComplex *in, ptrdiff_t stride)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define CMUL3(cre, cim, are, aim, bre, bim)