39 #define AUDIO_INBUF_SIZE 20480
40 #define AUDIO_REFILL_THRESH 4096
42 int main(
int argc,
char **argv)
44 const char *outfilename, *filename;
54 fprintf(stderr,
"Usage: %s <input file> <output file>\n", argv[0]);
58 outfilename = argv[2];
68 fprintf(stderr,
"Codec not found\n");
74 fprintf(stderr,
"Could not allocate audio codec context\n");
80 fprintf(stderr,
"Could not open codec\n");
84 f = fopen(filename,
"rb");
86 fprintf(stderr,
"Could not open %s\n", filename);
89 outfile = fopen(outfilename,
"wb");
99 while (avpkt.
size > 0) {
103 if (!decoded_frame) {
105 fprintf(stderr,
"Could not allocate audio frame\n");
112 fprintf(stderr,
"Error while decoding\n");
120 fprintf(stderr,
"Failed to calculate data size\n");
125 fwrite(decoded_frame->
data[ch] + data_size*i, 1, data_size, outfile);
136 memmove(inbuf, avpkt.
data, avpkt.
size);
138 len = fread(avpkt.
data + avpkt.
size, 1,
This structure describes decoded (raw) audio or video data.
Memory handling functions.
attribute_deprecated int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time...
enum AVSampleFormat sample_fmt
audio sample format
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AUDIO_REFILL_THRESH
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
reference-counted frame API
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Libavcodec external API header.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
void av_free(void *ptr)
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int channels
number of audio channels
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int main(int argc, char **argv)
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.