53 if (!aresample->
swr) {
83 int64_t out_rate, out_layout;
110 int ratelist[] = { out_rate, -1 };
120 int formatlist[] = { out_format, -1 };
128 int64_t layout_list[] = { out_layout, -1 };
143 int64_t out_rate, out_layout;
145 char inchl_buf[128], outchl_buf[128];
187 int n_out = n_in * aresample->
ratio + 32;
242 *outsamplesref_ret = outsamplesref;
273 if (
flush_frame(outlink, 0, &outsamplesref) >= 0) {
286 if ((ret =
flush_frame(outlink, 1, &outsamplesref)) < 0)
305 #define OFFSET(x) offsetof(AResampleContext, x)
306 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
348 .priv_class = &aresample_class,
349 .
inputs = aresample_inputs,
void av_frame_set_channels(AVFrame *frame, int val)
This structure describes decoded (raw) audio or video data.
static const AVFilterPad aresample_inputs[]
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
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...
static const AVOption options[]
struct AVFilterChannelLayouts * in_channel_layouts
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
#define ROUNDED_DIV(a, b)
A filter pad used for either input or output.
A link between two filters.
libswresample public header
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.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
The libswresample context.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
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)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
struct AVFilterChannelLayouts * out_channel_layouts
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
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.
int64_t swr_get_delay(struct SwrContext *s, int64_t base)
Gets the delay the next input sample will experience relative to the next output sample.
uint64_t channel_layout
Channel layout of the audio data.
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt)
audio channel layout utility functions
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int flush_frame(AVFilterLink *outlink, int final, AVFrame **outsamplesref_ret)
static const AVClass aresample_class
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
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.
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
AVFilterFormats * out_samplerates
int format
agreed upon media format
A list of supported channel layouts.
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.
static av_cold void uninit(AVFilterContext *ctx)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
static const AVFilterPad inputs[]
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
AVSampleFormat
Audio sample formats.
static const AVFilterPad aresample_outputs[]
av_cold void swr_free(SwrContext **ss)
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.
rational number numerator/denominator
const char * name
Filter name.
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg[SWR_CH_MAX], int in_count)
AVFilterLink ** outputs
array of pointers to output links
static int64_t pts
Global timestamp for the audio frames.
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
static const AVClass * resample_child_class_next(const AVClass *prev)
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
AVFilterContext * dst
dest filter
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
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)
uint8_t ** extended_data
pointers to the data planes/channels.
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 av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int request_frame(AVFilterLink *outlink)
AVFilterFormats * out_formats
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
static int config_output(AVFilterLink *outlink)