#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096
{
struct sample_fmt_entry {
} sample_fmt_entries[] = {
};
struct sample_fmt_entry *entry = &sample_fmt_entries[
i];
if (sample_fmt == entry->sample_fmt) {
*fmt =
AV_NE(entry->fmt_be, entry->fmt_le);
return 0;
}
}
fprintf(stderr,
"sample format %s is not supported as output format\n",
return -1;
}
{
if (ret < 0) {
fprintf(stderr, "Error submitting the packet to the decoder\n");
exit(1);
}
while (ret >= 0) {
return;
else if (ret < 0) {
fprintf(stderr, "Error during decoding\n");
exit(1);
}
if (data_size < 0) {
fprintf(stderr, "Failed to calculate data size\n");
exit(1);
}
for (ch = 0; ch < dec_ctx->
channels; ch++)
fwrite(frame->
data[ch] + data_size*i, 1, data_size, outfile);
}
}
int main(
int argc,
char **argv)
{
const char *outfilename, *filename;
size_t data_size;
int n_channels = 0;
const char *fmt;
if (argc <= 2) {
fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
exit(0);
}
filename = argv[1];
outfilename = argv[2];
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
if (!parser) {
fprintf(stderr, "Parser not found\n");
exit(1);
}
if (!c) {
fprintf(stderr, "Could not allocate audio codec context\n");
exit(1);
}
fprintf(stderr, "Could not open codec\n");
exit(1);
}
f = fopen(filename, "rb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
outfile = fopen(outfilename, "wb");
if (!outfile) {
exit(1);
}
data = inbuf;
while (data_size > 0) {
if (!decoded_frame) {
fprintf(stderr, "Could not allocate audio frame\n");
exit(1);
}
}
data, data_size,
if (ret < 0) {
fprintf(stderr, "Error while parsing\n");
exit(1);
}
decode(c, pkt, decoded_frame, outfile);
memmove(inbuf, data, data_size);
data = inbuf;
len = fread(data + data_size, 1,
if (len > 0)
}
}
decode(c, pkt, decoded_frame, outfile);
printf(
"Warning: the sample format the decoder produced is planar " "(%s). This example will output the first channel only.\n",
packed ? packed : "?");
}
goto end;
printf(
"Play the output audio file with the command:\n" "ffplay -f %s -ac %d -ar %d %s\n",
outfilename);
end:
fclose(outfile);
fclose(f);
return 0;
}