34 #define RENAME(n) n##_float 43 #define MACS(rt, ra, rb) rt+=(ra)*(rb) 44 #define MULS(ra, rb) ((ra)*(rb)) 45 #define MULH3(x, y, s) ((s)*(y)*(x)) 46 #define MLSS(rt, ra, rb) rt-=(ra)*(rb) 47 #define MULLx(x, y, s) ((y)*(x)) 48 #define FIXHR(x) ((float)(x)) 49 #define FIXR(x) ((float)(x)) 50 #define SHR(a,b) ((a)*(1.0f/(1<<(b)))) 54 #define RENAME(n) n##_fixed 55 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) 65 # define MULS(ra, rb) MUL64(ra, rb) 66 # define MACS(rt, ra, rb) MAC64(rt, ra, rb) 67 # define MLSS(rt, ra, rb) MLS64(rt, ra, rb) 68 # define MULH3(x, y, s) MULH((s)*(x), y) 69 # define MULLx(x, y, s) MULL((int)(x),(y),s) 70 # define SHR(a,b) (((int)(a))>>(b)) 71 # define FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) 72 # define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) 83 #define SUM8(op, sum, w, p) \ 85 op(sum, (w)[0 * 64], (p)[0 * 64]); \ 86 op(sum, (w)[1 * 64], (p)[1 * 64]); \ 87 op(sum, (w)[2 * 64], (p)[2 * 64]); \ 88 op(sum, (w)[3 * 64], (p)[3 * 64]); \ 89 op(sum, (w)[4 * 64], (p)[4 * 64]); \ 90 op(sum, (w)[5 * 64], (p)[5 * 64]); \ 91 op(sum, (w)[6 * 64], (p)[6 * 64]); \ 92 op(sum, (w)[7 * 64], (p)[7 * 64]); \ 95 #define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \ 99 op1(sum1, (w1)[0 * 64], tmp);\ 100 op2(sum2, (w2)[0 * 64], tmp);\ 102 op1(sum1, (w1)[1 * 64], tmp);\ 103 op2(sum2, (w2)[1 * 64], tmp);\ 105 op1(sum1, (w1)[2 * 64], tmp);\ 106 op2(sum2, (w2)[2 * 64], tmp);\ 108 op1(sum1, (w1)[3 * 64], tmp);\ 109 op2(sum2, (w2)[3 * 64], tmp);\ 111 op1(sum1, (w1)[4 * 64], tmp);\ 112 op2(sum2, (w2)[4 * 64], tmp);\ 114 op1(sum1, (w1)[5 * 64], tmp);\ 115 op2(sum2, (w2)[5 * 64], tmp);\ 117 op1(sum1, (w1)[6 * 64], tmp);\ 118 op2(sum2, (w2)[6 * 64], tmp);\ 120 op1(sum1, (w1)[7 * 64], tmp);\ 121 op2(sum2, (w2)[7 * 64], tmp);\ 138 memcpy(synth_buf + 512, synth_buf, 32 *
sizeof(*synth_buf));
140 samples2 = samples + 31 * incr;
157 p = synth_buf + 16 + j;
159 p = synth_buf + 48 - j;
180 int *synth_buf_offset,
188 offset = *synth_buf_offset;
189 synth_buf = synth_buf_ptr +
offset;
191 s->RENAME(
dct32)(synth_buf, sb_samples);
194 offset = (offset - 32) & 511;
195 *synth_buf_offset =
offset;
219 for(j=0; j < 16; j++)
220 window[512+16*i+j] = window[64*i+32-j];
223 for(j=0; j < 16; j++)
224 window[512+128+16*i+j] = window[64*i+48-j];
239 #define C1 FIXHR(0.98480775301220805936/2) 240 #define C2 FIXHR(0.93969262078590838405/2) 241 #define C3 FIXHR(0.86602540378443864676/2) 242 #define C4 FIXHR(0.76604444311897803520/2) 243 #define C5 FIXHR(0.64278760968653932632/2) 244 #define C6 FIXHR(0.5/2) 245 #define C7 FIXHR(0.34202014332566873304/2) 246 #define C8 FIXHR(0.17364817766693034885/2) 250 FIXR(0.50190991877167369479),
251 FIXR(0.51763809020504152469),
252 FIXR(0.55168895948124587824),
253 FIXR(0.61038729438072803416),
254 FIXR(0.70710678118654752439),
255 FIXR(0.87172339781054900991),
256 FIXR(1.18310079157624925896),
257 FIXR(1.93185165257813657349),
258 FIXR(5.73685662283492756461),
263 FIXHR(0.50190991877167369479/2),
264 FIXHR(0.51763809020504152469/2),
265 FIXHR(0.55168895948124587824/2),
266 FIXHR(0.61038729438072803416/2),
267 FIXHR(0.70710678118654752439/2),
268 FIXHR(0.87172339781054900991/2),
269 FIXHR(1.18310079157624925896/4),
270 FIXHR(1.93185165257813657349/4),
281 for (i = 17; i >= 1; i--)
283 for (i = 17; i >= 3; i -= 2)
286 for (j = 0; j < 2; j++) {
290 t2 = in1[2*4] + in1[2*8] - in1[2*2];
292 t3 = in1[2*0] +
SHR(in1[2*6],1);
293 t1 = in1[2*0] - in1[2*6];
294 tmp1[ 6] = t1 -
SHR(t2,1);
297 t0 =
MULH3(in1[2*2] + in1[2*4] ,
C2, 2);
298 t1 =
MULH3(in1[2*4] - in1[2*8] , -2*
C8, 1);
299 t2 =
MULH3(in1[2*2] + in1[2*8] , -
C4, 2);
301 tmp1[10] = t3 - t0 -
t2;
302 tmp1[ 2] = t3 + t0 +
t1;
303 tmp1[14] = t3 + t2 -
t1;
305 tmp1[ 4] =
MULH3(in1[2*5] + in1[2*7] - in1[2*1], -
C3, 2);
306 t2 =
MULH3(in1[2*1] + in1[2*5],
C1, 2);
307 t3 =
MULH3(in1[2*5] - in1[2*7], -2*
C7, 1);
310 t1 =
MULH3(in1[2*1] + in1[2*7], -
C5, 2);
312 tmp1[ 0] = t2 + t3 +
t0;
313 tmp1[12] = t2 + t1 -
t0;
314 tmp1[ 8] = t3 - t1 -
t0;
318 for (j = 0; j < 4; j++) {
326 s1 =
MULH3(t3 + t2, icos36h[ j], 2);
331 out[(9 + j) *
SBLIMIT] =
MULH3(t1, win[ 9 + j], 1) + buf[4*(9 + j)];
332 out[(8 - j) *
SBLIMIT] =
MULH3(t1, win[ 8 - j], 1) + buf[4*(8 - j)];
338 out[(9 + 8 - j) *
SBLIMIT] =
MULH3(t1, win[ 9 + 8 - j], 1) + buf[4*(9 + 8 - j)];
339 out[ j *
SBLIMIT] =
MULH3(t1, win[ j], 1) + buf[4*( j)];
346 s1 =
MULH3(tmp[17], icos36h[4], 2);
349 out[(9 + 4) *
SBLIMIT] =
MULH3(t1, win[ 9 + 4], 1) + buf[4*(9 + 4)];
350 out[(8 - 4) *
SBLIMIT] =
MULH3(t1, win[ 8 - 4], 1) + buf[4*(8 - 4)];
356 int count,
int switch_point,
int block_type)
359 for (j=0 ; j <
count; j++) {
363 int win_idx = (switch_point && j < 2) ? 0 : block_type;
369 buf += ((j&3) != 3 ? 1 : (72-3));
Memory handling functions.
static float win(SuperEqualizerContext *s, float n, int N)
void dct32(INTFLOAT *out, const INTFLOAT *tab_arg)
const int32_t ff_mpa_enwindow[257]
Macro definitions for various function/variable attributes.
#define SUM8P2(sum1, op1, sum2, op2, w1, w2, p)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static const INTFLOAT icos36h[9]
static av_cold void mpa_synth_init(MPA_INT *window)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
#define SUM8(op, sum, w, p)
static SDL_Window * window
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
#define MDCT_BUF_SIZE
For SSE implementation, MDCT_BUF_SIZE/2 should be 128-bit aligned.
static av_cold void mpa_synth_window_init(void)
static void(*const apply_window[4])(AVFloatDSPContext *fdsp, SingleChannelElement *sce, const float *audio)
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)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static int round_sample(int64_t *sum)
static const INTFLOAT icos36[9]
static void imdct36(INTFLOAT *out, INTFLOAT *buf, SUINTFLOAT *in, INTFLOAT *win)
mpeg audio declarations for both encoder and decoder.
static int ff_thread_once(char *control, void(*routine)(void))
Filter the word “frame” indicates either a video frame or a group of audio samples