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);
#define AV_CH_LAYOUT_7POINT1
ptrdiff_t const GLvoid * data
memory handling functions
void av_log_set_level(int level)
Set the log level.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
static enum AVSampleFormat formats[]
#define AV_CH_LAYOUT_STEREO
void avresample_free(AVAudioResampleContext **avr)
Free AVAudioResampleContext and associated AVOption values.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
static av_cold int end(AVCodecContext *avctx)
static double dbl_rand(AVLFG *lfg)
void avresample_close(AVAudioResampleContext *avr)
Close AVAudioResampleContext.
#define AV_CH_LAYOUT_5POINT1
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
static const uint64_t layouts[]
#define FF_ARRAY_ELEMS(a)
int main(int argc, char **argv)
int avresample_get_delay(AVAudioResampleContext *avr)
Return the number of samples currently in the resampling delay buffer.
int avresample_available(AVAudioResampleContext *avr)
Return the number of available samples in the output FIFO.
#define AV_LOG_INFO
Standard information.
AVSampleFormat
Audio sample formats.
#define AVRESAMPLE_MAX_CHANNELS
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Replacements for frequently missing libm functions.
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
int avresample_convert(AVAudioResampleContext *avr, uint8_t **output, int out_plane_size, int out_samples, uint8_t **input, int in_plane_size, int in_samples)
Convert input samples and write them to the output FIFO.
static av_always_inline av_const long int lrint(double x)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static void audiogen(AVLFG *rnd, void **data, enum AVSampleFormat sample_fmt, int channels, int sample_rate, int nb_samples)
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
AVAudioResampleContext * avresample_alloc_context(void)
Allocate AVAudioResampleContext and set options.
common internal and external API header
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill plane data pointers and linesize for samples with sample format sample_fmt.
#define AV_CH_LAYOUT_MONO
int avresample_open(AVAudioResampleContext *avr)
Initialize AVAudioResampleContext.
#define PUT_FUNC(name, fmt, type, expr)