40 #define MAX_CHANNELS 64
61 sscanf(*arg,
" %n", &len);
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 };
111 "pan filter needs a channel layout and a set "
112 "of channel definitions as parameter\n");
133 "Expected out channel name, got \"%.8s\"\n", arg);
140 "Channel \"%.8s\" does not exist in the chosen layout\n", arg0);
152 "Invalid out channel name \"%.8s\"\n", arg0);
159 }
else if (*arg ==
'<') {
164 "Syntax error after channel name in \"%.8s\"\n", arg0);
172 if (sscanf(arg,
"%lf%n *%n", &gain, &len, &len))
176 "Expected in channel name, got \"%.8s\"\n", arg);
180 nb_in_channels[named]++;
181 if (nb_in_channels[!named]) {
183 "Can not mix named and numbered channels\n");
187 pan->
gain[out_ch_id][in_ch_id] = sign * gain;
193 }
else if (*arg !=
'+') {
219 double gain = pan->
gain[i][j];
223 if (gain != 0. && gain != 1.)
226 if (gain && nb_gain++)
269 char buf[1024], *cur;
289 "af_pan supports a maximum of %d channels. "
290 "Feel free to ask for a higher limit.\n",
MAX_CHANNELS);
316 for (j = 0; j < link->
channels; j++) {
317 if (pan->
gain[i][j]) {
334 for (j = 0; j < link->
channels; j++)
335 t += fabs(pan->
gain[i][j]);
336 if (t > -1
E-5 && t < 1
E-5) {
340 "Degenerate coefficients while renormalizing\n");
343 for (j = 0; j < link->
channels; j++)
344 pan->
gain[i][j] /= t;
358 for (j = 0; j < link->
channels; j++) {
359 r =
snprintf(cur, buf +
sizeof(buf) - cur,
"%s%.3g i%d",
360 j ?
" + " :
"", pan->
gain[i][j], j);
361 cur +=
FFMIN(buf +
sizeof(buf) - cur, r);
406 #define OFFSET(x) offsetof(PanContext, x)
437 .priv_class = &pan_class,
void av_frame_set_channels(AVFrame *frame, int val)
double gain[MAX_CHANNELS][MAX_CHANNELS]
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
#define AV_OPT_FLAG_AUDIO_PARAM
struct AVFilterChannelLayouts * in_channel_layouts
static int config_props(AVFilterLink *link)
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
const char * name
Pad name.
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AV_LOG_VERBOSE
Detailed information.
static const AVFilterPad pan_inputs[]
static const AVOption pan_options[]
A filter pad used for either input or output.
A link between two filters.
libswresample public header
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 AV_OPT_FLAG_FILTERING_PARAM
a generic parameter which can be set by the user for filtering
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
static int query_formats(AVFilterContext *ctx)
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
struct AVFilterChannelLayouts * out_channel_layouts
static int are_gains_pure(const PanContext *pan)
uint64_t channel_layout
Channel layout of the audio data.
audio channel layout utility functions
int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
Set a customized remix matrix.
static void skip_spaces(char **arg)
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.
static const AVFilterPad outputs[]
int format
agreed upon media format
A list of supported channel layouts.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int64_t out_channel_layout
#define AV_LOG_INFO
Standard information.
static const AVFilterPad inputs[]
char * av_strdup(const char *s)
Duplicate a string.
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map)
Set a customized input channel mapping.
Describe the class of an AVClass context structure.
int channel_map[MAX_CHANNELS]
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
enum MovChannelLayoutTag * layouts
AVFILTER_DEFINE_CLASS(pan)
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()...
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
int channels
Number of channels.
AVFilterContext * dst
dest filter
static av_cold int init(AVFilterContext *ctx)
uint8_t ** extended_data
pointers to the data planes/channels.
int nb_samples
number of audio samples (per channel) described by this frame
static av_cold void uninit(AVFilterContext *ctx)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
static const AVFilterPad pan_outputs[]