#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define AUDIO_INBUF_SIZE 20480
#define AUDIO_REFILL_THRESH 4096
{
int ret, data_size;
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;
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);
}
data += ret;
data_size -= ret;
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);
fclose(outfile);
fclose(f);
return 0;
}