34 #define NUMBER_OF_AUDIO_FRAMES 200
35 #define NAME_BUFF_SIZE 100
44 frame_data[
channels * j] = 10000 * ((j / 10 *
i) % 2);
69 ctx->channel_layout = ch_layout;
95 ctx->request_channel_layout = ch_layout;
96 ctx->channel_layout = ch_layout;
114 int in_offset = 0, out_offset = 0;
117 int in_frame_bytes, out_frame_bytes;
165 if (in_frame_bytes > in_frame->
linesize[0]) {
169 memcpy(raw_in + in_offset, in_frame->
data[0], in_frame_bytes);
170 in_offset += in_frame_bytes;
177 while (result >= 0) {
195 if (result ==
AVERROR(EAGAIN)) {
198 }
else if (result ==
AVERROR(EOF)) {
201 }
else if (result < 0) {
221 if (out_frame_bytes > out_frame->
linesize[0]) {
225 memcpy(raw_out + out_offset, out_frame->
data[0], out_frame_bytes);
226 out_offset += out_frame_bytes;
static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate, int channels, int frame_size)
#define NUMBER_OF_AUDIO_FRAMES
static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx, int64_t ch_layout, int sample_rate)
static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx, int64_t ch_layout)
static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, AVCodecContext *dec_ctx)
Libavcodec external API header.
common internal and external API header
static const uint16_t channel_layouts[7]
static AVCodecContext * dec_ctx
#define AV_CH_LAYOUT_STEREO_DOWNMIX
#define AV_CH_LAYOUT_SURROUND
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT1_BACK
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder.
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_EOF
End of file.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVSampleFormat sample_fmt
audio sample format
int sample_rate
samples per second
int channels
number of audio channels
uint64_t channel_layout
Audio channel layout.
int frame_size
Number of samples per channel in an audio frame.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int channels
number of audio channels, only used for audio.
uint64_t channel_layout
Channel layout of the audio data.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This structure stores compressed data.