58 const LADSPA_Descriptor *
desc;
69 #define OFFSET(x) offsetof(LADSPAContext, x)
70 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
80 {
"nb_samples",
"set the number of samples per requested frame",
OFFSET(nb_samples),
AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX,
FLAGS },
91 LADSPA_Data *values,
int print)
93 const LADSPA_PortRangeHint *
h = s->
desc->PortRangeHints + map[ctl];
95 av_log(ctx, level,
"c%i: %s [", ctl, s->
desc->PortNames[map[ctl]]);
97 if (LADSPA_IS_HINT_TOGGLED(h->HintDescriptor)) {
98 av_log(ctx, level,
"toggled (1 or 0)");
100 if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
101 av_log(ctx, level,
" (default %i)", (
int)values[ctl]);
103 if (LADSPA_IS_HINT_INTEGER(h->HintDescriptor)) {
104 av_log(ctx, level,
"<int>");
106 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
107 av_log(ctx, level,
", min: %i", (
int)h->LowerBound);
109 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
110 av_log(ctx, level,
", max: %i", (
int)h->UpperBound);
113 av_log(ctx, level,
" (value %d)", (
int)values[ctl]);
114 else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
115 av_log(ctx, level,
" (default %d)", (
int)values[ctl]);
117 av_log(ctx, level,
"<float>");
119 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor))
120 av_log(ctx, level,
", min: %f", h->LowerBound);
122 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor))
123 av_log(ctx, level,
", max: %f", h->UpperBound);
126 av_log(ctx, level,
" (value %f)", values[ctl]);
127 else if (LADSPA_IS_HINT_HAS_DEFAULT(h->HintDescriptor))
128 av_log(ctx, level,
" (default %f)", values[ctl]);
131 if (LADSPA_IS_HINT_SAMPLE_RATE(h->HintDescriptor))
132 av_log(ctx, level,
", multiple of sample rate");
134 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
135 av_log(ctx, level,
", logarithmic scale");
138 av_log(ctx, level,
"]\n");
152 !(s->
desc->Properties & LADSPA_PROPERTY_INPLACE_BROKEN))) {
226 unsigned long *
map, LADSPA_Data *values)
228 const LADSPA_PortRangeHint *
h = s->
desc->PortRangeHints + map[ctl];
229 const LADSPA_Data lower = h->LowerBound;
230 const LADSPA_Data upper = h->UpperBound;
232 if (LADSPA_IS_HINT_DEFAULT_MINIMUM(h->HintDescriptor)) {
234 }
else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(h->HintDescriptor)) {
236 }
else if (LADSPA_IS_HINT_DEFAULT_0(h->HintDescriptor)) {
238 }
else if (LADSPA_IS_HINT_DEFAULT_1(h->HintDescriptor)) {
240 }
else if (LADSPA_IS_HINT_DEFAULT_100(h->HintDescriptor)) {
242 }
else if (LADSPA_IS_HINT_DEFAULT_440(h->HintDescriptor)) {
244 }
else if (LADSPA_IS_HINT_DEFAULT_LOW(h->HintDescriptor)) {
245 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
246 values[ctl] =
exp(log(lower) * 0.75 + log(upper) * 0.25);
248 values[ctl] = lower * 0.75 + upper * 0.25;
249 }
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h->HintDescriptor)) {
250 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
251 values[ctl] =
exp(log(lower) * 0.5 + log(upper) * 0.5);
253 values[ctl] = lower * 0.5 + upper * 0.5;
254 }
else if (LADSPA_IS_HINT_DEFAULT_HIGH(h->HintDescriptor)) {
255 if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
256 values[ctl] =
exp(log(lower) * 0.25 + log(upper) * 0.75);
258 values[ctl] = lower * 0.25 + upper * 0.75;
287 if (s->
desc->activate)
331 unsigned long *nb_inputs,
unsigned long *nb_outputs)
333 LADSPA_PortDescriptor pd;
336 for (i = 0; i < desc->PortCount; i++) {
337 pd = desc->PortDescriptors[i];
339 if (LADSPA_IS_PORT_AUDIO(pd)) {
340 if (LADSPA_IS_PORT_INPUT(pd)) {
342 }
else if (LADSPA_IS_PORT_OUTPUT(pd)) {
349 static void *
try_load(
const char *dir,
const char *soname)
355 ret = dlopen(path, RTLD_LOCAL|RTLD_NOW);
365 const char *label = s->
desc->Label;
366 LADSPA_PortRangeHint *
h = (LADSPA_PortRangeHint *)s->
desc->PortRangeHints +
375 if (LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) &&
378 "%s: input control c%ld is below lower boundary of %0.4f.\n",
379 label, port, h->LowerBound);
383 if (LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) &&
384 value > h->UpperBound) {
386 "%s: input control c%ld is above upper boundary of %0.4f.\n",
387 label, port, h->UpperBound);
399 LADSPA_Descriptor_Function descriptor_fn;
400 const LADSPA_Descriptor *
desc;
401 LADSPA_PortDescriptor pd;
403 char *p, *
arg, *saveptr =
NULL;
404 unsigned long nb_ports;
417 char *paths =
av_strdup(getenv(
"LADSPA_PATH"));
418 const char *separator =
":";
445 descriptor_fn = dlsym(s->
dl_handle,
"ladspa_descriptor");
446 if (!descriptor_fn) {
458 for (i = 0; desc = descriptor_fn(i); i++) {
472 desc = descriptor_fn(i);
478 if (desc->Label && !strcmp(desc->Label, s->
plugin))
484 nb_ports = desc->PortCount;
497 for (i = 0; i < nb_ports; i++) {
498 pd = desc->PortDescriptors[i];
500 if (LADSPA_IS_PORT_AUDIO(pd)) {
501 if (LADSPA_IS_PORT_INPUT(pd)) {
504 }
else if (LADSPA_IS_PORT_OUTPUT(pd)) {
508 }
else if (LADSPA_IS_PORT_CONTROL(pd)) {
509 if (LADSPA_IS_PORT_INPUT(pd)) {
512 if (LADSPA_IS_HINT_HAS_DEFAULT(desc->PortRangeHints[i].HintDescriptor))
518 }
else if (LADSPA_IS_PORT_OUTPUT(pd)) {
529 "The '%s' plugin does not have any input controls.\n",
533 "The '%s' plugin has the following input controls:\n",
547 if (!(arg =
av_strtok(p,
" |", &saveptr)))
551 if (sscanf(arg,
"c%d=%f", &i, &val) != 2) {
552 if (sscanf(arg,
"%f", &val) != 1) {
690 if (s->
desc->deactivate)
692 if (s->
desc->cleanup)
713 char *res,
int res_len,
int flags)
718 if (sscanf(cmd,
"c%ld", &port) + sscanf(args,
"%f", &value) != 2)
738 .priv_class = &ladspa_class,
static void set_default_ctl_value(LADSPAContext *s, int ctl, unsigned long *map, LADSPA_Data *values)
const char const char void * val
static int request_frame(AVFilterLink *outlink)
This structure describes decoded (raw) audio or video data.
static int config_output(AVFilterLink *outlink)
Main libavfilter public API header.
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
enum AVMediaType type
AVFilterPad type.
#define AV_CH_LAYOUT_STEREO
struct AVFilterChannelLayouts * in_channel_layouts
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
const char * name
Pad name.
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.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void count_ports(const LADSPA_Descriptor *desc, unsigned long *nb_inputs, unsigned long *nb_outputs)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
AVFILTER_DEFINE_CLASS(ladspa)
A filter pad used for either input or output.
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
A link between two filters.
AVFilterPad * input_pads
array of input pads
#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.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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
const LADSPA_Descriptor * desc
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
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
char * av_asprintf(const char *fmt,...)
int channels
number of audio channels, only used for audio.
audio channel layout utility functions
unsigned nb_inputs
number of input pads
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
static av_cold int init(AVFilterContext *ctx)
GLsizei GLboolean const GLfloat * value
static int set_control(AVFilterContext *ctx, unsigned long port, LADSPA_Data value)
AVFilterContext * src
source filter
static const AVFilterPad inputs[]
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad outputs[]
int format
agreed upon media format
A list of supported channel layouts.
static int config_input(AVFilterLink *inlink)
static void * try_load(const char *dir, const char *soname)
static const AVOption ladspa_options[]
#define AV_LOG_INFO
Standard information.
unsigned long nb_outputcontrols
char * av_strdup(const char *s)
Duplicate a string.
AVSampleFormat
Audio sample formats.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
Rational number (pair of numerator and denominator).
static int query_formats(AVFilterContext *ctx)
const char * name
Filter name.
const VDPAUPixFmtMap * map
static int connect_ports(AVFilterContext *ctx, AVFilterLink *link)
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
#define flags(name, subs,...)
static void print_ctl_info(AVFilterContext *ctx, int level, LADSPAContext *s, int ctl, unsigned long *map, LADSPA_Data *values, int print)
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()...
const OptionDef options[]
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
AVFilterContext * dst
dest filter
static const AVFilterPad ladspa_outputs[]
static enum AVSampleFormat sample_fmts[]
int(* config_props)(AVFilterLink *link)
Link configuration callback.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
uint8_t ** extended_data
pointers to the data planes/channels.
#define AVERROR_EXTERNAL
Generic error in an external library.
unsigned long nb_inputcontrols
int nb_samples
number of audio samples (per channel) described by this frame
static void print(AVTreeNode *t, int depth)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.