37 return 2.0 * (
av_lfg_get(lfg) / (double)UINT_MAX) - 1.0;
40 #define PUT_FUNC(name, fmt, type, expr) \
41 static void put_sample_ ## name(void **data, enum AVSampleFormat sample_fmt,\
42 int channels, int sample, int ch, \
46 type **out = (type **)data; \
47 if (av_sample_fmt_is_planar(sample_fmt)) \
48 out[ch][sample] = v; \
50 out[0][sample * channels + ch] = v; \
60 int channels,
int sample,
int ch,
double v_dbl)
64 put_sample_u8(data, sample_fmt, channels, sample, ch, v_dbl);
66 case AV_SAMPLE_FMT_S16:
67 put_sample_s16(data, sample_fmt, channels, sample, ch, v_dbl);
69 case AV_SAMPLE_FMT_S32:
70 put_sample_s32(data, sample_fmt, channels, sample, ch, v_dbl);
72 case AV_SAMPLE_FMT_FLT:
73 put_sample_flt(data, sample_fmt, channels, sample, ch, v_dbl);
75 case AV_SAMPLE_FMT_DBL:
76 put_sample_dbl(data, sample_fmt, channels, sample, ch, v_dbl);
90 #define PUT_SAMPLE put_sample(data, sample_fmt, channels, k, ch, v);
96 for (i = 0; i < 1 * sample_rate && k < nb_samples; i++, k++) {
98 for (ch = 0; ch < channels; ch++)
100 a +=
M_PI * 1000.0 * 2.0 / sample_rate;
105 for (i = 0; i < 1 * sample_rate && k < nb_samples; i++, k++) {
107 for (ch = 0; ch < channels; ch++)
109 f = 100.0 + (((10000.0 - 100.0) * i) / sample_rate);
114 for (i = 0; i < sample_rate / 2 && k < nb_samples; i++, k++) {
116 for (ch = 0; ch < channels; ch++)
121 for (i = 0; i < sample_rate / 2 && k < nb_samples; i++, k++) {
123 for (ch = 0; ch < channels; ch++)
128 for (ch = 0; ch < channels; ch++) {
133 for (i = 0; i < 1 * sample_rate && k < nb_samples; i++, k++) {
134 for (ch = 0; ch < channels; ch++) {
135 v = sin(taba[ch]) * 0.30;
137 f = tabf1[ch] + (((tabf2[ch] - tabf1[ch]) * i) /
sample_rate);
145 for (i = 0; i < 2 * sample_rate && k < nb_samples; i++, k++) {
146 for (ch = 0; ch < channels; ch++) {
147 double amp = (1.0 + sin(ampa)) * 0.15;
188 int main(
int argc,
char **argv)
195 unsigned int in_buf_size;
196 unsigned int out_buf_size;
201 uint64_t in_ch_layout;
205 uint64_t out_ch_layout;
209 int num_formats, num_rates, num_layouts;
210 int i, j, k, l,
m,
n;
218 "[<num sample rates> [<num channel layouts>]]]\n"
219 "Default is 2 2 2\n");
222 num_formats = strtol(argv[1], NULL, 0);
226 num_rates = strtol(argv[2], NULL, 0);
230 num_layouts = strtol(argv[3], NULL, 0);
240 out_buf_size = in_buf_size;
256 for (i = 0; i < num_formats; i++) {
258 for (k = 0; k < num_layouts; k++) {
259 in_ch_layout = layouts[k];
261 for (m = 0; m < num_rates; m++) {
265 in_channels, in_rate * 6,
271 audiogen(&rnd, (
void **)in_data, in_fmt, in_channels, in_rate, in_rate * 6);
273 for (j = 0; j < num_formats; j++) {
274 out_fmt = formats[j];
275 for (l = 0; l < num_layouts; l++) {
276 out_ch_layout = layouts[l];
278 for (n = 0; n < num_rates; n++) {
283 in_channels, out_channels, in_rate, out_rate);
286 out_buf, out_channels,
287 out_rate * 6, out_fmt, 0);
309 in_data, in_linesize, in_rate * 6);