40 double value = -12345.0;
44 fprintf(stderr,
"%s: av_opt_get_double(\"%s\") failed: %s\n",
49 fprintf(stderr,
"%s: %s = %g, expected %g\n",
62 fprintf(stderr,
"%s: av_opt_get_int(\"%s\") failed: %s\n",
66 if (
value != expected) {
67 fprintf(stderr,
"%s: %s = %"PRId64
", expected %"PRId64
"\n",
81 fprintf(stderr,
"%s: av_opt_get_chlayout(\"downmix\") failed: %s\n",
87 if (strcmp(buf,
"stereo") != 0) {
88 fprintf(stderr,
"%s: downmix = %s, expected stereo\n",
89 ctx->codec->name, buf);
102 if (has_target_level)
151 ctx->sample_rate = 48000;
152 ctx->bit_rate = 128000;
161 frame->nb_samples =
ctx->frame_size;
169 for (
int ch = 0; ch <
ctx->ch_layout.nb_channels; ch++) {
170 float *samples = (
float *)
frame->extended_data[ch];
171 for (
int i = 0;
i <
frame->nb_samples;
i++)
172 samples[
i] = 0.25f * ((
i % 64) / 32.0f - 1.0f) * (ch ? -1.0f : 1.0f);
244 int has_target_level;
263 fprintf(stderr,
"%s: failed to set decoder options\n",
name);
268 fprintf(stderr,
"%s: avcodec_open2() failed\n",
name);
279 fprintf(stderr,
"%s: failed to decode a frame\n",
name);
289 fprintf(stderr,
"%s: exported downmix fields were not set by decoding\n",
305 printf(
"%s: options preserved across avcodec_flush_buffers()\n",
name);
314 static const char *
const decoder_names[] = {
"ac3",
"eac3",
"ac3_fixed" };
323 fprintf(stderr,
"failed to generate an AC-3 packet: %s\n",
330 for (
int i = 0;
i < (int)(
sizeof(decoder_names) /
sizeof(decoder_names[0]));
i++) {
339 fprintf(stderr,
"no (E-)AC-3 decoder available\n");
static int get_export_values(AVCodecContext *ctx, struct ExportValues *values)
static int run_test(const char *name, const AVPacket *pkt)
static int check_downmix(AVCodecContext *ctx)
static int check_int(AVCodecContext *ctx, const char *name, int64_t expected)
static int decode_one_frame(AVCodecContext *ctx, const AVPacket *src_pkt)
static int check_options(AVCodecContext *ctx, int has_target_level)
static int check_double(AVCodecContext *ctx, const char *name, double expected)
static int check_export_values(AVCodecContext *ctx, const struct ExportValues *expected)
static int generate_ac3_packet(AVPacket *pkt)
static AVFormatContext * ctx
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
__device__ int printf(const char *,...)
static __device__ float fabs(float a)
reference-counted frame API
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
const AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
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)
Alias for avcodec_receive_frame_flags(avctx, frame, 0).
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 avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
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.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
#define AV_CHANNEL_LAYOUT_STEREO
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define AVERROR_ENCODER_NOT_FOUND
Encoder not found.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
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.
@ AV_SAMPLE_FMT_FLTP
float, planar
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val)
int av_opt_get_chlayout(void *obj, const char *name, int search_flags, AVChannelLayout *cl)
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
int av_opt_set_double(void *obj, const char *name, double val, int search_flags)
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
An AVChannelLayout holds information about the channel layout of audio data.
main external API structure.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
Rational number (pair of numerator and denominator).