27 #include "libavutil/avstring.h"
28 #include "libavutil/channel_layout.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/samplefmt.h"
31 #include "libavutil/avassert.h"
32 #include "libswresample/swresample.h"
53 if (!aresample->
swr) {
83 uint64_t out_layout =
av_get_int(aresample->
swr,
"ocl", NULL);
132 char inchl_buf[128], outchl_buf[128];
173 int n_out = n_in * aresample->
ratio * 2 + 256;
260 return prev ? NULL : s->
swr;
263 #define OFFSET(x) offsetof(AResampleContext, x)
264 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
306 .priv_class = &aresample_class,
307 .
inputs = aresample_inputs,
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
This structure describes decoded (raw) audio or video data.
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.
static const AVFilterPad aresample_inputs[]
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
#define LIBAVUTIL_VERSION_INT
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
struct SwrContext * swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)
Allocate SwrContext if needed and set/reset common parameters.
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
uint8_t ** extended_data
pointers to the data planes/channels.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int64_t swr_next_pts(struct SwrContext *s, int64_t pts)
Convert the next timestamp from input to output timestamps are in 1/(in_sample_rate * out_sample_rate...
struct SwrContext * swr_alloc(void)
Allocate SwrContext.
void av_frame_set_channels(AVFrame *frame, int val)
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const char * av_default_item_name(void *ctx)
Return the context name.
struct AVFilterChannelLayouts * in_channel_layouts
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static av_cold int end(AVCodecContext *avctx)
AVFilter avfilter_af_aresample
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in, int in_count)
Convert audio.
#define AV_LOG_VERBOSE
Detailed information.
const OptionDef options[]
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
static void * resample_child_next(void *obj, void *prev)
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_dict_free(AVDictionary **m)
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)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
uint64_t channel_layout
Channel layout of the audio data.
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const
Rescale a 64-bit integer with rounding to nearest.
static const AVClass aresample_class
int64_t av_get_int(void *obj, const char *name, const AVOption **o_out)
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
int format
agreed upon media format
A list of supported channel layouts.
AVFilterFormats * out_samplerates
Main libavfilter public API header.
static av_cold void uninit(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
AVSampleFormat
Audio Sample Formats.
static const AVFilterPad aresample_outputs[]
AVFilterFormats * out_formats
void swr_free(struct SwrContext **s)
Free the given SwrContext and set the pointer to NULL.
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
rational number numerator/denominator
AVFilterContext * dst
dest filter
#define ROUNDED_DIV(a, b)
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
static const AVClass * resample_child_class_next(const AVClass *prev)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
struct AVFilterChannelLayouts * out_channel_layouts
#define AV_DICT_IGNORE_SUFFIX
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static int query_formats(AVFilterContext *ctx)
const AVClass * swr_get_class(void)
Get the AVClass for swrContext.
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
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int request_frame(AVFilterLink *outlink)
int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
static int config_output(AVFilterLink *outlink)
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.