28 float *synth_buf_ptr,
int *synth_buf_offset,
29 float synth_buf2[32],
const float window[512],
30 float out[32],
const float in[32],
float scale)
32 float *synth_buf = synth_buf_ptr + *synth_buf_offset;
37 for (i = 0; i < 16; i++) {
38 float a = synth_buf2[i ];
39 float b = synth_buf2[i + 16];
42 for (j = 0; j < 512 - *synth_buf_offset; j += 64) {
43 a += window[i + j ] * (-synth_buf[15 - i + j ]);
44 b += window[i + j + 16] * ( synth_buf[ i + j ]);
45 c += window[i + j + 32] * ( synth_buf[16 + i + j ]);
46 d += window[i + j + 48] * ( synth_buf[31 - i + j ]);
48 for ( ; j < 512; j += 64) {
49 a += window[i + j ] * (-synth_buf[15 - i + j - 512]);
50 b += window[i + j + 16] * ( synth_buf[ i + j - 512]);
51 c += window[i + j + 32] * ( synth_buf[16 + i + j - 512]);
52 d += window[i + j + 48] * ( synth_buf[31 - i + j - 512]);
55 out[i + 16] = b * scale;
57 synth_buf2[i + 16] = d;
60 *synth_buf_offset = (*synth_buf_offset - 32) & 511;
64 float *synth_buf_ptr,
int *synth_buf_offset,
65 float synth_buf2[64],
const float window[1024],
66 float out[64],
const float in[64],
float scale)
68 float *synth_buf = synth_buf_ptr + *synth_buf_offset;
73 for (i = 0; i < 32; i++) {
74 float a = synth_buf2[i ];
75 float b = synth_buf2[i + 32];
78 for (j = 0; j < 1024 - *synth_buf_offset; j += 128) {
79 a += window[i + j ] * (-synth_buf[31 - i + j ]);
80 b += window[i + j + 32] * ( synth_buf[ i + j ]);
81 c += window[i + j + 64] * ( synth_buf[32 + i + j ]);
82 d += window[i + j + 96] * ( synth_buf[63 - i + j ]);
84 for ( ; j < 1024; j += 128) {
85 a += window[i + j ] * (-synth_buf[31 - i + j - 1024]);
86 b += window[i + j + 32] * ( synth_buf[ i + j - 1024]);
87 c += window[i + j + 64] * ( synth_buf[32 + i + j - 1024]);
88 d += window[i + j + 96] * ( synth_buf[63 - i + j - 1024]);
91 out[i + 32] = b * scale;
93 synth_buf2[i + 32] = d;
96 *synth_buf_offset = (*synth_buf_offset - 64) & 1023;
100 int32_t *synth_buf_ptr,
int *synth_buf_offset,
104 int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset;
109 for (i = 0; i < 16; i++) {
110 int64_t
a = synth_buf2[i ] * (INT64_C(1) << 21);
111 int64_t
b = synth_buf2[i + 16] * (INT64_C(1) << 21);
114 for (j = 0; j < 512 - *synth_buf_offset; j += 64) {
115 a += (int64_t)window[i + j ] * synth_buf[ i + j ];
116 b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j ];
117 c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j ];
118 d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j ];
120 for ( ; j < 512; j += 64) {
121 a += (int64_t)window[i + j ] * synth_buf[ i + j - 512];
122 b += (int64_t)window[i + j + 16] * synth_buf[15 - i + j - 512];
123 c += (int64_t)window[i + j + 32] * synth_buf[16 + i + j - 512];
124 d += (int64_t)window[i + j + 48] * synth_buf[31 - i + j - 512];
128 synth_buf2[i ] =
norm21(c);
129 synth_buf2[i + 16] =
norm21(d);
132 *synth_buf_offset = (*synth_buf_offset - 32) & 511;
136 int32_t *synth_buf_ptr,
int *synth_buf_offset,
140 int32_t *synth_buf = synth_buf_ptr + *synth_buf_offset;
145 for (i = 0; i < 32; i++) {
146 int64_t
a = synth_buf2[i ] * (INT64_C(1) << 20);
147 int64_t
b = synth_buf2[i + 32] * (INT64_C(1) << 20);
150 for (j = 0; j < 1024 - *synth_buf_offset; j += 128) {
151 a += (int64_t)window[i + j ] * synth_buf[ i + j ];
152 b += (int64_t)window[i + j + 32] * synth_buf[31 - i + j ];
153 c += (int64_t)window[i + j + 64] * synth_buf[32 + i + j ];
154 d += (int64_t)window[i + j + 96] * synth_buf[63 - i + j ];
156 for ( ; j < 1024; j += 128) {
157 a += (int64_t)window[i + j ] * synth_buf[ i + j - 1024];
158 b += (int64_t)window[i + j + 32] * synth_buf[31 - i + j - 1024];
159 c += (int64_t)window[i + j + 64] * synth_buf[32 + i + j - 1024];
160 d += (int64_t)window[i + j + 96] * synth_buf[63 - i + j - 1024];
164 synth_buf2[i ] =
norm20(c);
165 synth_buf2[i + 32] =
norm20(d);
168 *synth_buf_offset = (*synth_buf_offset - 64) & 1023;
void ff_synth_filter_init_x86(SynthFilterContext *c)
static void synth_filter_float_64(FFTContext *imdct, float *synth_buf_ptr, int *synth_buf_offset, float synth_buf2[64], const float window[1024], float out[64], const float in[64], float scale)
void(* synth_filter_float_64)(FFTContext *imdct, float *synth_buf_ptr, int *synth_buf_offset, float synth_buf2[64], const float window[1024], float out[64], const float in[64], float scale)
av_cold void ff_synth_filter_init(SynthFilterContext *c)
void(* synth_filter_fixed_64)(DCADCTContext *imdct, int32_t *synth_buf_ptr, int *synth_buf_offset, int32_t synth_buf2[64], const int32_t window[1024], int32_t out[64], const int32_t in[64])
static void synth_filter_fixed_64(DCADCTContext *imdct, int32_t *synth_buf_ptr, int *synth_buf_offset, int32_t synth_buf2[64], const int32_t window[1024], int32_t out[64], const int32_t in[64])
static int32_t clip23(int32_t a)
static int32_t norm20(int64_t a)
av_cold void ff_synth_filter_init_arm(SynthFilterContext *s)
static void synth_filter_float(FFTContext *imdct, float *synth_buf_ptr, int *synth_buf_offset, float synth_buf2[32], const float window[512], float out[32], const float in[32], float scale)
static int32_t norm21(int64_t a)
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 FFTContext *s, FFTSample *output, const FFTSample *input)
av_cold void ff_synth_filter_init_aarch64(SynthFilterContext *s)
void(* synth_filter_float)(FFTContext *imdct, float *synth_buf_ptr, int *synth_buf_offset, float synth_buf2[32], const float window[512], float out[32], const float in[32], float scale)
static void synth_filter_fixed(DCADCTContext *imdct, int32_t *synth_buf_ptr, int *synth_buf_offset, int32_t synth_buf2[32], const int32_t window[512], int32_t out[32], const int32_t in[32])
void(* synth_filter_fixed)(DCADCTContext *imdct, int32_t *synth_buf_ptr, int *synth_buf_offset, int32_t synth_buf2[32], const int32_t window[512], int32_t out[32], const int32_t in[32])
void(* imdct_half[2])(int32_t *output, const int32_t *input)