41#define MAX_CHANNELS 64
69 int len, channel_id = 0;
73 if (sscanf(*
arg,
"%7[A-Z]%n", buf, &
len) >= 1) {
78 *rchannel = channel_id;
84 if (sscanf(*
arg,
"c%d%n", &channel_id, &
len) >= 1 &&
86 *rchannel = channel_id;
102 double gain = pan->
gain[
i][j];
106 if (gain != 0. && gain != 1.)
109 if (gain && nb_gain++)
120 int out_ch_id, in_ch_id,
len, named, ret, sign = 1;
121 int nb_in_channels[2] = { 0, 0 };
127 "pan filter needs a channel layout and a set "
128 "of channel definitions as parameter\n");
146 "af_pan supports a maximum of %d channels. "
147 "Feel free to ask for a higher limit.\n",
MAX_CHANNELS);
158 "Expected out channel name, got \"%.8s\"\n",
arg);
165 "Channel \"%.8s\" does not exist in the chosen layout\n", arg0);
172 "Invalid out channel name \"%.8s\"\n", arg0);
176 if (used_out_ch[out_ch_id]) {
178 "Can not reference out channel %d twice\n", out_ch_id);
182 used_out_ch[out_ch_id] = 1;
186 }
else if (*
arg ==
'<') {
191 "Syntax error after channel name in \"%.8s\"\n", arg0);
199 if (sscanf(
arg,
"%lf%n *%n", &gain, &
len, &
len) >= 1)
203 "Expected in channel name, got \"%.8s\"\n",
arg);
207 nb_in_channels[named]++;
208 if (nb_in_channels[!named]) {
210 "Can not mix named and numbered channels\n");
216 "Input channel id %d is not supported\n", in_ch_id);
220 if (used_in_ch[in_ch_id]) {
222 "Can not reference in channel %d twice\n", in_ch_id);
226 used_in_ch[in_ch_id] = 1;
227 pan->
gain[out_ch_id][in_ch_id] = sign * gain;
233 }
else if (*
arg !=
'+') {
276 char buf[1024], *cur;
296 "af_pan supports a maximum of %d channels. "
297 "Feel free to ask for a higher limit.\n",
MAX_CHANNELS);
316 if (pan->
gain[
i][j]) {
334 if (t > -1
E-5 && t < 1
E-5) {
338 "Degenerate coefficients while renormalizing\n");
342 pan->
gain[
i][j] /= t;
355 r =
snprintf(cur, buf +
sizeof(buf) - cur,
"%s%.3g i%d",
356 j ?
" + " :
"", pan->
gain[
i][j], j);
357 cur +=
FFMIN(buf +
sizeof(buf) - cur,
r);
407#define OFFSET(x) offsetof(PanContext, x)
428 .p.priv_class = &pan_class,
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
static const AVFilterPad pan_inputs[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static av_cold void uninit(AVFilterContext *ctx)
static const AVOption pan_options[]
static void skip_spaces(char **arg)
static int are_gains_pure(const PanContext *pan)
static int config_props(AVFilterLink *link)
static AVFormatContext * ctx
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
int ff_parse_channel_layout(AVChannelLayout *ret, int *nret, const char *arg, void *log_ctx)
Parse a channel layout or a corresponding integer representation.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
static __device__ float fabs(float a)
static const uint16_t channel_layouts[7]
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
#define AV_OPT_FLAG_FILTERING_PARAM
A generic parameter which can be set by the user for filtering.
#define AV_OPT_FLAG_AUDIO_PARAM
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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().
int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map)
Set a customized input channel mapping.
int swr_alloc_set_opts2(struct SwrContext **ps, const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, const AVChannelLayout *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.
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *const *out_arg, int out_count, const uint8_t *const *in_arg, int in_count)
Convert audio.
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride)
Set a customized remix matrix.
int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout *channel_layout, int search_flags)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Memory handling functions.
enum MovChannelLayoutTag * layouts
static int config_props(AVBitStreamFilterLink *link)
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A list of supported channel layouts.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
AVChannelLayout ch_layout
Channel layout of the audio data.
uint8_t ** extended_data
pointers to the data planes/channels.
double gain[MAX_CHANNELS][MAX_CHANNELS]
int channel_map[MAX_CHANNELS]
AVChannelLayout out_channel_layout
The libswresample context.
libswresample public header