Go to the documentation of this file.
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];
153 if (!
inlink->channel_layout)
187 int n_out = n_in * aresample->
ratio + 32;
244 *outsamplesref_ret = outsamplesref;
275 if (
flush_frame(outlink, 0, &outsamplesref) >= 0) {
304 return prev ?
NULL :
s->swr;
307 #define OFFSET(x) offsetof(AResampleContext, x)
308 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
A list of supported channel layouts.
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
struct AVFilterChannelLayouts * in_channel_layouts
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int end(AVCodecContext *avctx)
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.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static int config_output(AVFilterLink *outlink)
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define AV_LOG_VERBOSE
Detailed information.
const char * name
Filter name.
A link between two filters.
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
int channels
Number of channels.
static const AVFilterPad aresample_inputs[]
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
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...
A filter pad used for either input or output.
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.
static const AVOption options[]
static void * resample_child_next(void *obj, void *prev)
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int channels
number of audio channels, only used for audio.
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const AVFilterPad outputs[]
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)
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.
The libswresample context.
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.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Rational number (pair of numerator and denominator).
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
AVFilterLink ** inputs
array of pointers to input links
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define ROUNDED_DIV(a, b)
const char * av_default_item_name(void *ptr)
Return the context name.
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
static av_cold void uninit(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
int sample_rate
Sample rate of the audio data.
int format
agreed upon media format
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const AVFilterPad aresample_outputs[]
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
uint64_t channel_layout
Channel layout of the audio data.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static const AVClass * resample_child_class_next(const AVClass *prev)
static int flush_frame(AVFilterLink *outlink, int final, AVFrame **outsamplesref_ret)
static const AVClass aresample_class
int sample_rate
samples per second
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t ** extended_data
pointers to the data planes/channels.
AVSampleFormat
Audio sample formats.
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
const char * name
Pad name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static int query_formats(AVFilterContext *ctx)
static int request_frame(AVFilterLink *outlink)