Go to the documentation of this file.
35 #define NUMBER_OF_AUDIO_FRAMES 200
36 #define NAME_BUFF_SIZE 100
112 uint8_t *raw_in =
NULL, *raw_out =
NULL;
113 int in_offset = 0, out_offset = 0;
116 int in_frame_bytes, out_frame_bytes;
166 if (in_frame_bytes > in_frame->
linesize[0]) {
170 memcpy(raw_in + in_offset, in_frame->
data[0], in_frame_bytes);
171 in_offset += in_frame_bytes;
222 if (out_frame_bytes > out_frame->
linesize[0]) {
226 memcpy(raw_out + out_offset, out_frame->
data[0], out_frame_bytes);
227 out_offset += out_frame_bytes;
int frame_size
Number of samples per channel in an audio frame.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX
static AVCodecContext * dec_ctx
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
#define AV_CHANNEL_LAYOUT_STEREO
int sample_rate
samples per second
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
This structure describes decoded (raw) audio or video data.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int nb_channels
Number of channels in this layout.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVChannelLayout ch_layout
Audio channel layout.
AVChannelLayout ch_layout
Channel layout of the audio data.
#define AV_CHANNEL_LAYOUT_SURROUND
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_decoder(const AVCodec *dec, AVCodecContext **dec_ctx, const AVChannelLayout *ch_layout)
#define FF_ARRAY_ELEMS(a)
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
static int init_encoder(const AVCodec *enc, AVCodecContext **enc_ctx, const AVChannelLayout *ch_layout, int sample_rate)
and forward the result(frame or status change) to the corresponding input. If nothing is possible
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
An AVChannelLayout holds information about the channel layout of audio data.
enum AVSampleFormat sample_fmt
audio sample format
static int run_test(const AVCodec *enc, const AVCodec *dec, AVCodecContext *enc_ctx, AVCodecContext *dec_ctx)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define AV_LOG_INFO
Standard information.
#define NUMBER_OF_AUDIO_FRAMES
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
@ AV_SAMPLE_FMT_S16
signed 16 bits
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
main external API structure.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
This structure stores compressed data.
static const uint16_t channel_layouts[7]
static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate, int channels, int frame_size)
#define AV_CHANNEL_LAYOUT_5POINT1_BACK
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...