#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
{
if (*p == sample_fmt)
return 1;
p++;
}
return 0;
}
{
const int *p;
int best_samplerate = 0;
return 44100;
while (*p) {
if (!best_samplerate || abs(44100 - *p) < abs(44100 - best_samplerate))
best_samplerate = *p;
p++;
}
return best_samplerate;
}
{
const uint64_t *p;
uint64_t best_ch_layout = 0;
int best_nb_channels = 0;
while (*p) {
if (nb_channels > best_nb_channels) {
best_ch_layout = *p;
}
p++;
}
return best_ch_layout;
}
FILE *output)
{
int ret;
if (ret < 0) {
fprintf(stderr, "Error sending the frame to the encoder\n");
exit(1);
}
while (ret >= 0) {
return;
else if (ret < 0) {
fprintf(stderr, "Error encoding audio frame\n");
exit(1);
}
fwrite(pkt->
data, 1, pkt->
size, output);
}
}
int main(
int argc,
char **argv)
{
const char *filename;
int i, j, k, ret;
FILE *f;
uint16_t *samples;
float t, tincr;
if (argc <= 1) {
fprintf(stderr, "Usage: %s <output file>\n", argv[0]);
return 0;
}
filename = argv[1];
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
if (!c) {
fprintf(stderr, "Could not allocate audio codec context\n");
exit(1);
}
fprintf(stderr, "Encoder does not support sample format %s",
exit(1);
}
fprintf(stderr, "Could not open codec\n");
exit(1);
}
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
if (!pkt) {
fprintf(stderr, "could not allocate the packet\n");
exit(1);
}
if (!frame) {
fprintf(stderr, "Could not allocate audio frame\n");
exit(1);
}
if (ret < 0) {
fprintf(stderr, "Could not allocate audio data buffers\n");
exit(1);
}
t = 0;
for (i = 0; i < 200; i++) {
if (ret < 0)
exit(1);
samples = (uint16_t*)frame->
data[0];
samples[2*j] = (
int)(sin(t) * 10000);
samples[2*j + k] = samples[2*j];
t += tincr;
}
}
fclose(f);
return 0;
}