56 #define INPUT_SAMPLERATE 48000
57 #define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
58 #define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
60 #define VOLUME_VAL 0.90
84 fprintf(stderr,
"Unable to create filter graph.\n");
92 fprintf(stderr,
"Could not find the abuffer filter.\n");
98 fprintf(stderr,
"Could not allocate the abuffer instance.\n");
113 fprintf(stderr,
"Could not initialize the abuffer filter.\n");
120 fprintf(stderr,
"Could not find the volume filter.\n");
126 fprintf(stderr,
"Could not allocate the volume instance.\n");
136 fprintf(stderr,
"Could not initialize the volume filter.\n");
144 fprintf(stderr,
"Could not find the aformat filter.\n");
150 fprintf(stderr,
"Could not allocate the aformat instance.\n");
156 snprintf(options_str,
sizeof(options_str),
157 "sample_fmts=%s:sample_rates=%d:channel_layouts=0x%"PRIx64,
170 fprintf(stderr,
"Could not find the abuffersink filter.\n");
175 if (!abuffersink_ctx) {
176 fprintf(stderr,
"Could not allocate the abuffersink instance.\n");
183 fprintf(stderr,
"Could not initialize the abuffersink instance.\n");
195 fprintf(stderr,
"Error connecting filters\n");
208 *sink = abuffersink_ctx;
219 int planes = planar ? channels : 1;
221 int plane_size = bps * frame->
nb_samples * (planar ? 1 : channels);
224 for (i = 0; i < planes; i++) {
230 fprintf(stdout,
"plane %d: 0x", i);
231 for (j = 0; j <
sizeof(
checksum); j++)
232 fprintf(stdout,
"%02X", checksum[j]);
233 fprintf(stdout,
"\n");
235 fprintf(stdout,
"\n");
246 #define FRAME_SIZE 1024
260 for (i = 0; i < 5; i++) {
264 data[j] = sin(2 *
M_PI * (frame_num + j) * (i + 1) / FRAME_SIZE);
270 int main(
int argc,
char *argv[])
278 int err, nb_frames, i;
281 fprintf(stderr,
"Usage: %s <duration>\n", argv[0]);
285 duration = atof(argv[1]);
287 if (nb_frames <= 0) {
288 fprintf(stderr,
"Invalid duration: %s\n", argv[1]);
297 fprintf(stderr,
"Error allocating the frame\n");
303 fprintf(stderr,
"Error allocating the MD5 context\n");
310 fprintf(stderr,
"Unable to init filter graph:");
315 for (i = 0; i < nb_frames; i++) {
319 fprintf(stderr,
"Error generating input frame:");
327 fprintf(stderr,
"Error submitting the frame to the filtergraph:");
336 fprintf(stderr,
"Error processing the filtered frame:");
348 }
else if (err < 0) {
350 fprintf(stderr,
"Error filtering the data:");
363 fprintf(stderr,
"%s\n", errstr);
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags)
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
Main libavfilter public API header.
memory handling functions
Memory buffer source API.
AVFilterGraph * filter_graph
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
#define AV_CH_LAYOUT_STEREO
static int get_input(AVFrame *frame, int frame_num)
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
memory buffer sink API for audio and video
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
void avfilter_register_all(void)
Initialize the filter system.
#define AVERROR_EOF
End of file.
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
Hash an array of data.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
#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.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
static int process_output(struct AVMD5 *md5, AVFrame *frame)
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
int main(int argc, char *argv[])
uint64_t channel_layout
Channel layout of the audio data.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
audio channel layout utility functions
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src, AVFilterContext **sink)
static volatile int checksum
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
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...
void av_md5_init(AVMD5 *ctx)
Initialize MD5 hashing.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define INPUT_CHANNEL_LAYOUT
int sample_rate
Sample rate of the audio data.
rational number numerator/denominator
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
uint8_t ** extended_data
pointers to the data planes/channels.
int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
Get a frame with filtered data from sink and put it in frame.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int nb_samples
number of audio samples (per channel) described by this frame
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.