34 #define NUMBER_OF_AUDIO_FRAMES 200 35 #define NAME_BUFF_SIZE 100 44 frame_data[channels * j] = 10000 * ((j / 10 *
i) % 2);
46 frame_data[channels * j + k] = frame_data[channels * j] * (k + 1);
114 int in_offset = 0, out_offset = 0;
118 int in_frame_bytes, out_frame_bytes;
160 if (in_frame_bytes > in_frame->
linesize[0]) {
164 memcpy(raw_in + in_offset, in_frame->
data[0], in_frame_bytes);
165 in_offset += in_frame_bytes;
181 if (result != enc_pkt.
size) {
182 av_log(
NULL,
AV_LOG_INFO,
"Decoder consumed only part of a packet, it is allowed to do so -- need to update this test\n");
201 if (out_frame_bytes > out_frame->
linesize[0]) {
205 memcpy(raw_out + out_offset, out_frame->
data[0], out_frame_bytes);
206 out_offset += out_frame_bytes;
212 if (memcmp(raw_in, raw_out, out_frame_bytes * NUMBER_OF_AUDIO_FRAMES) != 0) {
248 if (
init_encoder(enc, &enc_ctx, channel_layouts[cl], sample_rates[sr]) != 0)
250 if (
init_decoder(dec, &dec_ctx, channel_layouts[cl]) != 0)
252 if (
run_test(enc, dec, enc_ctx, dec_ctx) != 0)
This structure describes decoded (raw) audio or video data.
static int run_test(AVCodec *enc, AVCodec *dec, AVCodecContext *enc_ctx, AVCodecContext *dec_ctx)
#define AV_CH_LAYOUT_SURROUND
attribute_deprecated int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
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.
#define FF_ARRAY_ELEMS(a)
#define AV_CH_LAYOUT_STEREO
enum AVSampleFormat sample_fmt
audio sample format
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.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
enum AVSampleFormat request_sample_fmt
desired sample format
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
uint64_t channel_layout
Audio channel layout.
uint64_t channel_layout
Channel layout of the audio data.
int channels
number of audio channels, only used for audio.
#define AV_CH_LAYOUT_STEREO_DOWNMIX
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_CH_LAYOUT_5POINT1_BACK
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.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int frame_size
Number of samples per channel in an audio frame.
#define AV_LOG_INFO
Standard information.
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...
int sample_rate
samples per second
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static const uint16_t channel_layouts[7]
static int init_encoder(AVCodec *enc, AVCodecContext **enc_ctx, int64_t ch_layout, int sample_rate)
int 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.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define NUMBER_OF_AUDIO_FRAMES
common internal and external API header
static AVCodecContext * dec_ctx
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate, int channels, int frame_size)
int channels
number of audio channels
static int init_decoder(AVCodec *dec, AVCodecContext **dec_ctx, int64_t ch_layout)
and forward the result(frame or status change) to the corresponding input.If nothing is possible
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
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame