Go to the documentation of this file.
40 #define MAX_CHANNELS 64
68 int len,
i, channel_id = 0;
73 if (sscanf(*
arg,
"%7[A-Z]%n", buf, &
len)) {
76 for (
i = 32;
i > 0;
i >>= 1) {
77 if (
layout >= (int64_t)1 <<
i) {
83 if (channel_id >=
MAX_CHANNELS || layout0 != (int64_t)1 << channel_id)
85 *rchannel = channel_id;
91 if (sscanf(*
arg,
"c%d%n", &channel_id, &
len) &&
93 *rchannel = channel_id;
105 int out_ch_id, in_ch_id,
len, named,
ret, sign = 1;
106 int nb_in_channels[2] = { 0, 0 };
112 "pan filter needs a channel layout and a set "
113 "of channel definitions as parameter\n");
135 "Expected out channel name, got \"%.8s\"\n",
arg);
142 "Channel \"%.8s\" does not exist in the chosen layout\n", arg0);
154 "Invalid out channel name \"%.8s\"\n", arg0);
158 if (used_out_ch[out_ch_id]) {
160 "Can not reference out channel %d twice\n", out_ch_id);
164 used_out_ch[out_ch_id] = 1;
168 }
else if (*
arg ==
'<') {
173 "Syntax error after channel name in \"%.8s\"\n", arg0);
181 if (sscanf(
arg,
"%lf%n *%n", &gain, &
len, &
len))
185 "Expected in channel name, got \"%.8s\"\n",
arg);
189 nb_in_channels[named]++;
190 if (nb_in_channels[!named]) {
192 "Can not mix named and numbered channels\n");
196 if (used_in_ch[in_ch_id]) {
198 "Can not reference in channel %d twice\n", in_ch_id);
202 used_in_ch[in_ch_id] = 1;
203 pan->
gain[out_ch_id][in_ch_id] = sign * gain;
209 }
else if (*
arg !=
'+') {
235 double gain = pan->
gain[
i][j];
239 if (gain != 0. && gain != 1.)
242 if (gain && nb_gain++)
285 char buf[1024], *cur;
305 "af_pan supports a maximum of %d channels. "
306 "Feel free to ask for a higher limit.\n",
MAX_CHANNELS);
333 if (pan->
gain[
i][j]) {
351 t += fabs(pan->
gain[
i][j]);
352 if (t > -1
E-5 && t < 1
E-5) {
356 "Degenerate coefficients while renormalizing\n");
360 pan->
gain[
i][j] /= t;
375 r =
snprintf(cur, buf +
sizeof(buf) - cur,
"%s%.3g i%d",
376 j ?
" + " :
"", pan->
gain[
i][j], j);
377 cur +=
FFMIN(buf +
sizeof(buf) - cur,
r);
424 #define OFFSET(x) offsetof(PanContext, x)
455 .priv_class = &pan_class,
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
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.
enum MovChannelLayoutTag * layouts
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.
This structure describes decoded (raw) audio or video data.
static int config_props(AVFilterLink *link)
static const AVFilterPad pan_outputs[]
#define AV_LOG_VERBOSE
Detailed information.
int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map)
Set a customized input channel mapping.
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
const char * name
Filter name.
A link between two filters.
#define AV_OPT_FLAG_FILTERING_PARAM
a generic parameter which can be set by the user for filtering
int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
Set a customized remix matrix.
int channels
Number of channels.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t out_channel_layout
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
int channels
number of audio channels, only used for audio.
static int query_formats(AVFilterContext *ctx)
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
static void skip_spaces(char **arg)
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)
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.
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 link
#define AV_OPT_FLAG_AUDIO_PARAM
Describe the class of an AVClass context structure.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
static const AVFilterPad pan_inputs[]
static int are_gains_pure(const PanContext *pan)
static const AVOption pan_options[]
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_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int sample_rate
Sample rate of the audio data.
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,...
uint64_t channel_layout
Channel layout of the audio data.
int channel_map[MAX_CHANNELS]
#define AV_LOG_INFO
Standard information.
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 layout
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
uint8_t ** extended_data
pointers to the data planes/channels.
const char * name
Pad name.
static av_cold int init(AVFilterContext *ctx)
char * av_strdup(const char *s)
Duplicate a string.
static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
double gain[MAX_CHANNELS][MAX_CHANNELS]
AVFILTER_DEFINE_CLASS(pan)
static av_cold void uninit(AVFilterContext *ctx)